locked
Latitude/longitude RRS feed

  • Question

  • How can i work with longitude and latitude??

    i mean:

    1. How can i get the Latitude and longitude of a especific address or zip-code?
    2. Can i get the lat/long of a selected area by click it or selecting it with the mouse wheel????
    Thursday, May 17, 2007 11:57 PM

Answers

  • Latitude and Longtitude in Virtual Earth are encapsulated by javascript VELatLong class objects.  You can establish references to them with a variety of methods.  The easiest way to get started would be to use some of the VEMap methods, along the lines of:

     

    var x = VEMap.GetCenter();
    alert('Map Center Lat: ' + x.Latitude + ', Map Center Long: ' + x.Longitude);

    For finding same by address or zip code, you can do the same thing...just search the SDK for VEFindResult classes...they have latlong as a public property.  Lastly, for intercepting input device events, read up in the SDK on the new VEMap Events.  Here's a sample I use in IE to keep data populated in the browser Status Bar:

     

    // ****************************************************

    // Pan, Zoom Event Handlers

    function EndPanHandler(e)

    {

    currentLatLong = map.GetCenter();

    currentZoom = map.GetZoomLevel();

    UpdateStatusBar(currentLatLong,currentZoom);

    }

    function EndZoomHandler(e)

    {

    currentLatLong = map.GetCenter();

    currentZoom = map.GetZoomLevel();

    UpdateStatusBar(currentLatLong,currentZoom);

    }

     

    // ****************************************************

    // Status Bar Display

    function UpdateStatusBar(velatlong,zoom)

    {

    self.status = ('Latitude: ' + velatlong.Latitude + ' Longitude: ' + velatlong.Longitude + ' Zoom: ' + zoom);

    }

    Friday, May 18, 2007 1:26 PM