使用 TerraService 或其他方式的 GPS 位置和城市名称
我有一个简单的应用程序,它通过 GPS 检索当前位置并显示我当前的位置。问题是我用于获取城市名称的 Web 服务 (TerraService) 不起作用带有非英文字符。 我还希望能够自定义返回数据的格式。现在它可以给我“1km SW Bart, Redmond, United States”,这不太好。 您知道如何自定义它并使其能够处理非英文字符吗?
GeoCoordinateWatcher myGPS;
myGPS = new GeoCoordinateWatcher();
myGPS.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(myGPS_PositionChanged);
myGPS.Start();
void myGPS_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
double myLatitude = e.Position.Location.Latitude; //do what you want with myLatitude and myLongtitude
double myLongtitude = e.Position.Location.Longitude;
GPSServiceReference.TerraServiceSoapClient client = new GPSServiceReference.TerraServiceSoapClient();
client.ConvertLonLatPtToNearestPlaceCompleted += new EventHandler<GPSServiceReference.ConvertLonLatPtToNearestPlaceCompletedEventArgs>(client_ConvertLonLatPtToNearestPlaceCompleted);
client.ConvertLonLatPtToNearestPlaceAsync(new GPSServiceReference.LonLatPt { Lat = myLatitude, Lon = myLongtitude });
}
I have a simple app that is retrieving the current location via GPS and displays my current location. The problem is that the web service I'm using for getting the city name (TerraService) doesn't work with non English characters.
Also I want to be able to customize the format of the returned data. Now it can give me "1km SW Bart, Redmond, United States" and thats not good.
Do you know how to customize it and get it to work with non English characters?
GeoCoordinateWatcher myGPS;
myGPS = new GeoCoordinateWatcher();
myGPS.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(myGPS_PositionChanged);
myGPS.Start();
void myGPS_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
double myLatitude = e.Position.Location.Latitude; //do what you want with myLatitude and myLongtitude
double myLongtitude = e.Position.Location.Longitude;
GPSServiceReference.TerraServiceSoapClient client = new GPSServiceReference.TerraServiceSoapClient();
client.ConvertLonLatPtToNearestPlaceCompleted += new EventHandler<GPSServiceReference.ConvertLonLatPtToNearestPlaceCompletedEventArgs>(client_ConvertLonLatPtToNearestPlaceCompleted);
client.ConvertLonLatPtToNearestPlaceAsync(new GPSServiceReference.LonLatPt { Lat = myLatitude, Lon = myLongtitude });
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论