locked
How to Get Directions and Routes

    Question

  • Hi all,

    I am trying to implement Virtual Earth control in a windows application.

    I am having the latitude and the longitude being read from the textboxes (which are being fethced from GPS NMEA data)

    1. I want them to be SHOWN ON THE MAP via a pushpin(Serving as the first point) on button click event in c#.
    2. How can i retrieve the location name?
    3. Also i want to get directions between two points. The first point should be the same  as in (1) ..The second point should be marked dynamically when i right click on the map at a particular location.
    4. And when i click a button the Directions to the Second point should be displayed.


    plz can anybody suggest me how to achieve the above functionalities....

    Monday, March 16, 2009 11:35 AM

Answers

  • Can you verify if your using a web browser control to load in the AJAX version of Virtual Earth or are you embedding the Virtual Earth 3D control directly into your windows Application. This will make a difference in how some of your questions will be handled.

    1) If your using the AJAX control you will need to use the onmousedown event to retrieve the pixel coordinates of the mouse, then use the VEMap.PixelToLatLong method to get the coordinates of the mouse, then create a pushpin shape with those coordinates and add it to the map. To get the event to hook into the C# you will need to catch the event on the javascript side and then make a call likie window.external."yourmethod()" This will invoke your c# method, if you have one by that name. If you want to do this with the 3D api without the AJAX map control then there is a completely different approach to take.

    2) If your using the AJAX control you can either use the VEMap.FindLocations method to reverse geocode the location (http://msdn.microsoft.com/en-us/library/cc469978.aspx). You can also connect to the Virtual Earth Web services and use the Geocoding service and make a call to the ReverseGeocode method. This virtual earth web services can also be used directly from the 3D api.

    3)With the AJAX control just make a call to the VEMap.GetDirections method, passing in the array of coordinates. The coordinates can be retrieved by the mouse by using the onmousedown event and the VEMap.PicelToLatLong method. You can also use the Virtual Earth web services to access the routing services.

    4) If you want to be able to show multiple routes on a map you will need to use client tokens with your map, and then enable the route geometry to be returned with the route request through the route options. You will then have to store this route information and draw the route as a polyline on the map.

    Take a look at the lkist of Virtual Earth resources here: http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/001db5dc-6fd3-4723-8654-971865ea281e
    Tuesday, March 17, 2009 2:25 PM

All replies

  • Can you verify if your using a web browser control to load in the AJAX version of Virtual Earth or are you embedding the Virtual Earth 3D control directly into your windows Application. This will make a difference in how some of your questions will be handled.

    1) If your using the AJAX control you will need to use the onmousedown event to retrieve the pixel coordinates of the mouse, then use the VEMap.PixelToLatLong method to get the coordinates of the mouse, then create a pushpin shape with those coordinates and add it to the map. To get the event to hook into the C# you will need to catch the event on the javascript side and then make a call likie window.external."yourmethod()" This will invoke your c# method, if you have one by that name. If you want to do this with the 3D api without the AJAX map control then there is a completely different approach to take.

    2) If your using the AJAX control you can either use the VEMap.FindLocations method to reverse geocode the location (http://msdn.microsoft.com/en-us/library/cc469978.aspx). You can also connect to the Virtual Earth Web services and use the Geocoding service and make a call to the ReverseGeocode method. This virtual earth web services can also be used directly from the 3D api.

    3)With the AJAX control just make a call to the VEMap.GetDirections method, passing in the array of coordinates. The coordinates can be retrieved by the mouse by using the onmousedown event and the VEMap.PicelToLatLong method. You can also use the Virtual Earth web services to access the routing services.

    4) If you want to be able to show multiple routes on a map you will need to use client tokens with your map, and then enable the route geometry to be returned with the route request through the route options. You will then have to store this route information and draw the route as a polyline on the map.

    Take a look at the lkist of Virtual Earth resources here: http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/001db5dc-6fd3-4723-8654-971865ea281e
    Tuesday, March 17, 2009 2:25 PM
  • Yes I am using a web browser control to load the map
    Wednesday, March 18, 2009 6:19 AM
  • i think i am gettin the idea.

    If you could plz just give me an example..
    Wednesday, March 18, 2009 6:41 AM