使用 TerraService 或其他方式的 GPS 位置和城市名称

发布于 2025-01-04 18:08:02 字数 1201 浏览 0 评论 0原文

我有一个简单的应用程序,它通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文