Getting Location Name from Longitude and Latitude in BingMap

后端 未结 3 1373
故里飘歌
故里飘歌 2021-01-07 15:15

I am a WP7 developer. I have longitude and latitude of a location. Is there anyway to get the info the location defined by the coordinate ie longitude and latitude. Thank yo

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-07 15:45

    You can make use of a web service provided by Microsoft that returns the city, state and country based on the latitude and longitude you provide.

    Create a web service reference in your project by providing the link http://msrmaps.com/TerraService2.asmx

    I have named the service as myTerraService

    myTerraService.TerraServiceSoapClient client = new myTerraService.TerraServiceSoapClient();
            client.ConvertLonLatPtToNearestPlaceCompleted += new EventHandler(client_ConvertLonLatPtToNearestPlaceCompleted);
            client.ConvertLonLatPtToNearestPlaceAsync(new myTerraService.LonLatPt { Lat = latitude, Lon = longitude });
        }
    
        void client_ConvertLonLatPtToNearestPlaceCompleted(object sender, myTerraService.ConvertLonLatPtToNearestPlaceCompletedEventArgs e)
        {
            string location = e.Result; // this string will have city, state, country
        }
    

提交回复
热议问题