Executing Driving Directions in virtual earth
Did you find the title amazing? How can we implement driving directions though the Microsoft Virtual Earth? Oh yes, it is quite a simple job. You can implement driving directions in this virtual earth program, here is how? Firstly, you need to make a pop-up menu to set the starting-point and end-point for your journey. After setting the menus precisely, you can discover how to build the code that will retrieve the directions for your journey. Now finalize a specific route on map. You will require a basic HTML page that displays the virtual earth map to start this work.
The very first thing you will need to define is a way for the user. This will allow you to define the end-points and starting points of the map. Start building the HTMP menu and then add it to the body. Then you can add different styles to define the menu. Then figure out a way that will make your menu appear as well as disappear. If you want the menu to appear when the user right clicks on the map, then should design a JavaScript method to show the map attach it with the ‘oncontextmenu’ event of our map.
Now write the JavaScript for displaying your menu. Here we need two global variables like popuplat and popuplon. These two variables define the position of the cursor after starting the process of adding start and end-points. The next step is to create shells for start and end directions. When the menu opens, the Virtual earth map control has no way of knowing when there is an occurrence of other mouse events. We are unable to capture a “click” event and thus, we cannot close the map.
Remember, every menu function closes the window by calling to RemovePopupMenu () function. Thus, at this stage you should have a virtual earth map with a pop-up menu that will close the menu on selecting any option. For executing the driving directions in Microsoft virtual earth, you should follow the following steps in a systematic order: Remove the existing start-pin and endpin and then create a pushpin for the start. Store the longitude and latitude in VELatLong object. Then finally close the popup menu.
Add more than two variables and then create the pushpin in Set Start method. Likewise, if the pushpin does not exist then the Delete Pushpin () method crafts an exception. When we try to insert a new pushpin with the same ID as an existing pushpin then we must perform a workaround. When we want to make use of custom pushpin, replace the null third parameter with a URL to an image. Now our application must show our popup menu and allow us to create pushpins for the start points and the end-points.
The actual magic of driving directions contains a single call to VEMap object. By passing out start point, end-point and some other parameters to GetRoute method, we can draw route on map.
Technorati Tags: Microsoft, virtual earth, using virtual earth,
Tags: Microsoft Virtual Earth
























