finding location based on latitude and longitude


  • Hello there,

    I want to be able to find location knowing its latitude and longitude. I tried using VEMap.Find but I can't pass the VEPlace object for the where parameter. SDK documentation states that the where parameter can indeed accept a VEPlace object but I haven't had any luck doing this. Also in my particular siutation the only piece of data I have is latitude and longitude of the location of interest and not its name. The VEPlace constructor actually validates attempts to pass null reference for the name part. Can I still search without providing the name? Here's the code I use to attempt to accomplish this.

    Code Snippet

    function findLocationByCoordinates(/*VELatLong*/coordinates)

            var place = new VEPlace("",coordinates);       map.Find(null,place,null,null,null,null,null,null,null,true,__handlefindLocationByCoordinates);


    When I run this, I get the following error

    Invalid what/where parameters; either 'what' or 'where' must be present

    Thank you
    Wednesday, August 08, 2007 10:42 AM


All replies

  • Use the "SetCenterAndZoom" method. See http://msdn2.microsoft.com/en-us/library/bb412439.aspx


    Wednesday, August 08, 2007 5:59 PM
  • This isn't an option for me since I am only interested in data that gets passed to the callback function and I really don't want to change the screen center or even navigate to the "closest match".
    Thursday, August 09, 2007 7:07 AM

    If you're looking to get the address based on a lat/long. E.g find out the country, state, address, base on the lat/long, then you're out of luck. VE doesn't do reverse geocoding.


    You might want to try Mappoint web service (not free), or search the web for other free services.

    Thursday, August 09, 2007 5:05 PM
  • I don't think I need to go as far as using MapPoint services. All I really need is a standard functionality provided by the Find method. I just can't get it to work correctly with the longitude and latiude data though documentation states that it is possible to use the VEPlace object but doesn't provide any sample.

    Thank you
    Friday, August 10, 2007 7:24 AM
  • I have not been able to get the Find method to work with a VEPlace object either.  The documentation says you can do it, but when I try, it generates the same error you are getting.


    I think this is either a bug in Virtual Earth or in the documentation, but I have not seen any official confirmation of it anywhere.  It is frustrating because I need this functionality too, and it appears to be there, but doesn't work.




    Tuesday, June 24, 2008 5:11 PM
  • What you need is VeMap.FindLocations. This takes a VeLatlong and returns the LocationName.


    Tuesday, June 24, 2008 7:09 PM