locked
setting start and end post codes RRS feed

  • Question

  • i have trying to use Virtual map on my web site, athough it seems to work OK, i canot find a method/ script   on here to allow me to enter my start and end Postcodes to generate a route. can only one suggest a forum topic or website  for me to find this ?

     

    thanks in advance

    Sunday, June 10, 2007 12:25 PM

Answers

  • Hey chris do you just want to show the default search box? that method is if you make your own. Try:

    Code Snippet
           function GetMap()
             { 
                map = new VEMap('myMap');
                map.LoadMap();
                map.ShowFindControl();
             }

     


    John.

    Monday, June 18, 2007 10:49 PM
    Moderator

All replies

  •  

    var From = "FromPostcode" + ", UK";

    var To = "ToPostcode" + ", UK";

    function GetMap()
     {
           map = new VEMap('myMap');
           map.LoadMap();
           map.GetRoute(From, To);
     }

    Note you need to add ", UK "  to the postcode

    Sunday, June 10, 2007 1:44 PM
  • thank you for trying to help me with thid, but i still have an issue, i have done as you suggested,, but now i get  a window with a start  place, and does not allow me to enter mymy own start place, if i accep the suggested start place it suggests a finsh place which was somwehere in russia

     

    need to undertand how i get get t to allow me to enter my own start and finish places

     

    can you please help me

    Sunday, June 17, 2007 1:29 PM
  • added my code here

     

     

    <html>

    <head>

    <title></title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>

    <script>

    var map = null;

    var clickEvent = null;

    var zoomLevel = 3;

    var From = "FromPostcode" + ", UK";

    var To = "ToPostcode" + ", UK";

    function GetMap()

    {

    map = new VEMap('myMap');

    map.LoadMap();

    map.SetZoomLevel(zoomLevel);

    txtZoom.value = zoomLevel;

    map.AttachEvent("onclick", GetLatLong);

    latLong = map.GetCenter();

    divInfo.innerHTML = latLong;

    }

    function GetLatLong(e)

    {

    //Get the pixel coordinates from the click event, convert to LatLong value

    var x = e.mapX;

    var y = e.mapY;

    pixel = new VEPixel(x, y);

    latLong = map.PixelToLatLong(pixel);

    divInfo.innerHTML = latLong;

    }

    function SetCenterAndZoom()

    {

    map.SetCenterAndZoom(latLong, zoomLevel);

    }

    function SetCenter()

    {

    map.SetCenter(latLong);

    }

    function SetZoom()

    {

    map.SetZoomLevel(zoomLevel);

    }

    function ZoomIn()

    {

    //Increase zoom level by a factor of 1

    map.ZoomIn();

    txtZoom.value = map.GetZoomLevel();

    }

    function ZoomOut()

    {

    //Decrease zoom level by a factor of 1

    map.ZoomOut();

    txtZoom.value = map.GetZoomLevel();

    }

    function ValidateEntry()

    {

    //Check to make sure zoom level is within range

    if (txtZoom.value > 0 && txtZoom.value <= 19) zoomLevel = txtZoom.value;

    else alert("Enter a value between 1 and 19.");

    }

    // Dashboard hide & show calls

    function HideDashboard()

    {

    map.HideDashboard();

    }

    function ShowDashboard()

    {

    map.ShowDashboard();

    }

    // 3D Navigation hide & show calls

    function Hide3DNav()

    {

    map.Hide3DNavigationControl();

    }

    function Show3DNav()

    {

    if (map.GetMapMode() == 1)

    {

    map.SetMapMode(VEMapMode.Mode3D);

    }

    map.Show3DNavigationControl();

    }

    // Find Control hide & show calls

    function HideFindControl()

    {

    map.HideFindControl();

    }

    function ShowFindControl()

    {

    map.ShowFindControl();

    }

    // Mini Map hide & show calls

    function HideMiniMap()

    {

    map.HideMiniMap();

    }

    function ShowMiniMap()

    {

    if (map.GetMapMode() == 2)

    {

    map.SetMapMode(VEMapMode.Mode2D);

    }

    map.ShowMiniMap(200, 100);

    }

    function SetScaleBar(distanceUnit)

    {

    map.SetScaleBarDistanceUnit(distanceUnit);

    }

    function GetMap()

    {

    map = new VEMap('myMap');

    map.LoadMap();

    map.GetRoute(From, To);

    }

    </script>

    </head>

    <body onload="GetMap();" style="font-family: Arial">

    <div id='myMap' style="position:relative; width:704px; height:500px; z-index: 100; left: 0px; top: 0px;"></div>

    <input id="ShowMiniMap" type="button" value="ShowMiniMap" onclick="ShowMiniMap()" style="z-index: 113; left: 880px; position: absolute; top: 248px">

    <input id="HideMiniMap" type="button" value="HideMiniMap" onclick="HideMiniMap()" style="z-index: 113; left: 756px; position: absolute; top: 248px">

    <input id="ShowFindControl" type="button" value="ShowFindControl" onclick="ShowFindControl()" style="z-index: 113; left: 880px; position: absolute; top: 208px">

    <input id="HideFindControl" type="button" value="HideFindControl" onclick="HideFindControl()" style="z-index: 113; left: 732px; position: absolute; top: 208px">

    <input id="Show3DNav" type="button" value="Show3DNav" onclick="Show3DNav()" style="z-index: 113; left: 880px; position: absolute; top: 168px">

    <input id="Hide3DNav" type="button" value="Hide3DNav" onclick="Hide3DNav()" style="z-index: 113; left: 772px; position: absolute; top: 168px">

    <input id="HideDashboard()" type="button" value="HideDashboard" onclick="HideDashboard()()" style="z-index: 113; left: 880px; position: absolute; top: 128px">

    <input id="ShowDashboard" type="button" value="ShowDashboard" onclick="ShowDashboard()" style="z-index: 113; left: 728px; position: absolute; top: 128px">

    <input id="btnZoomOut" type="button" value="Zoom out by 1" onclick="ZoomOut()" style="z-index: 113; left: 880px; position: absolute; top: 88px">

    <input id="btnZoomIn" type="button" value="Zoom in by 1" onclick="ZoomIn()" style="z-index: 113; left: 756px; position: absolute; top: 88px">

    <input id="btnSetZoom" type="button" value="Set Zoom" onclick="SetZoom()" style="z-index: 113; left: 880px; position: absolute; top: 48px">

    <input id="btnSetCenter" type="button" value="Set Center" onclick="SetCenter()" style="z-index: 113; left: 776px; position: absolute; top: 48px">

    <input id="btnSetCZ" type="button" value="Set Center and Zoom" onclick="SetCenterAndZoom()" style="z-index: 101; left: 776px; position: absolute; top: 16px">

    <input id="GetRoute" type="button" value="GetRoute" onclick="GetRoute()" style="z-index: 113 left: 840px; position: absolute; top: 284px; left: 836px;">

    Click the map to select a center point.<br />

    <div id="divInfo"><br />&nbsp;</div>

    Zoom Level: <input id="txtZoom" type="text" value="" onchange="ValidateEntry()"/><br />

    <br />

    <br />

    <br />

    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

    <div id="links">

    </div>

    </body>

    </html>

     

     

    Sunday, June 17, 2007 2:01 PM
  • var From = "FromPostcode" + ", UK";

    var To = "ToPostcode" + ", UK";

     

    Typically the From and To would be edit box values, within your web page. 

    The From value would be FromPostcode plus comma UK

    To would be the same if going to another postcode.  ie ToPostcode plus comma UK

    The declared variables are only used to show the example values.

     

    Duncan Garratt

    http://www.gis-logic.co.uk/

     

     

    Sunday, June 17, 2007 2:17 PM
  •  

     

    problem is -

    map.GetRoute(From, To)

    does not generate an input box ?

    Monday, June 18, 2007 6:28 PM
  • Hey chris do you just want to show the default search box? that method is if you make your own. Try:

    Code Snippet
           function GetMap()
             { 
                map = new VEMap('myMap');
                map.LoadMap();
                map.ShowFindControl();
             }

     


    John.

    Monday, June 18, 2007 10:49 PM
    Moderator