ロック済み Latitude and Longitude

  • Monday, June 02, 2008 7:01 PM
     
     

    Hi

    Is there any way with Virtual Earth to find a location using its longitude and latitude?

    What I reeally want is to know if you can turn on Latitude and Longitude like horizontal and vertical rulers in a paint program or so, on the map itself?

    Thanks

All Replies

  • Tuesday, June 03, 2008 2:42 PM
     
     
    So you want to display the lat/lon of the mouse cursor? When you move the mouse the lat/lon would update...maybe display it in a text box?

     

  • Tuesday, June 03, 2008 6:02 PM
     
     

    The VEMap object has an "onmousemove" event that fires whenever the cursor is moved while over the map.  When the event fires, the function which you have attached to that event will be called and a MapEvent object will be provided as a parameter.  The MapEvent object has mapX and mapY properties which refer to the postion (in pixels) of the cursor with regard to the map.  These pixel values can be converted to a latitude and longitude by using mapX and mapY to create a VEPixel object and then calling the PixelToLatLong() method of the VEMap object with the VEPixel object as a parameter.  This will return a VELatLong object which contains the information you are looking for.

     

    If this doesn't help, I could write up a code sample.

  • Friday, June 06, 2008 2:08 AM
     
     

    I just wanted to run a Visual Basic application and log on to the internet and get a map using a latitude and longitude and either using is offline or online.  Is there an easy way to do this and can you show the code in Visual Baisc Express 2008

  • Monday, February 23, 2009 9:39 AM
     
     
    I am also interested in using VEMap in my Visual Basic application.  I would also be interested in seeing some code for this.

    Thanks,

    RGecy 
    Visual Studio VB.Net 2005
  • Monday, February 23, 2009 1:30 PM
    Moderator
     
     Answered Has Code
    To answer the original poster's question, try this:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">  
    <head> 
      <title>Retrieve Latitude/Longitude using Virtual Earth</title> 
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2" type="text/javascript"></script> 
    <script type="text/javascript">  
    var map = null; // the map object  
     
    function DisplayCoords(e) {  
      // Retrieve the pixel position of the cursor  
      var pix = new VEPixel(e.mapX, e.mapY);  
      // Convert the pixel location to latitude / longitude  
      var pos = map.PixelToLatLong(pix);  
      // Update the page to display current cursor latitude / longitude  
      document.getElementById("Latitude").value = pos.Latitude;  
      document.getElementById("Longitude").value = pos.Longitude;  
    }  
     
    function GetMap() {  
      // Create a new map instance  
      map = new VEMap("divMap");  
      // Define the parameters for the map  
      map.LoadMap(new VELatLong(51.5, -0.1), 5, VEMapStyle.Road, false);  
      // Attach an event handler when you move the mouse across the map  
      map.AttachEvent("onmousemove", DisplayCoords);  
    }  
    </script> 
    </head> 
    <body onload="GetMap();">  
      <div id="divMap" style="position: relative; height: 300px; width:400px;"></div> 
      <label for="Latitude">Latitude</label><input id="Latitude" /> 
      <label for="Longitude">Longitude</label><input id="Longitude" /> 
    </body> 
    </html> 

    For the last two posters - I think there might be some confusion as to exactly what you are trying to do. "Virtual Earth" is a name used to describe several different technologies, but they all require an internet connection in some form or other, so you won't be able to develop an off-line solution using Virtual Earth.
    Most people think of Virtual Earth as a javascript-based web control (which is what is described in this thread), but I think you might be wanting to use the Virtual Earth Web Service, which is a SOAP-based service that you can access using Visual Basic .NET (or C#, or PHP etc.). For examples of how to use that, try http://blogs.msdn.com/virtualearth/archive/2008/09/26/getting-a-map-with-the-virtual-earth-web-service.aspx
    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
  • Monday, November 30, 2009 9:40 AM
     
     
    hello,

    I want to convert latitude and longitude in google maps to pixel (x,y) position. But i am new to javascript and doesnt know about it.
    Can you please help...

    Thanks
  • Monday, November 30, 2009 12:56 PM
    Moderator
     
     
    This is a Bing Maps forum. Try the following forum for Google related questions: http://googlemapsforum.com/

    Windows Live Developer MVP - http://rbrundritt.spaces.live.com