从 BingMap 中的经度和纬度获取位置名称

发布于 2025-01-02 07:56:19 字数 68 浏览 7 评论 0原文

我是一名 WP7 开发人员。我有一个位置的经度和纬度。无论如何,是否可以获取坐标定义的位置信息,即经度和纬度。 谢谢你!!

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 you!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吝吻 2025-01-09 07:56:19

是的,您可以通过 Bing 地图 REST API 执行此操作,您需要执行反向地理编码。这是通过 GET 执行以下请求来完成的:

http://dev.virtualearth.net/REST/v1/Locations/47.64054,-122.12934?o=xml&key=BingMapsKey

它将返回 XML 格式的地址:

<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1">
  <Copyright>
    Copyright © 2011 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.
  </Copyright>
  <BrandLogoUri>
    http://dev.virtualearth.net/Branding/logo_powered_by.png
  </BrandLogoUri>
  <StatusCode>200</StatusCode>
  <StatusDescription>OK</StatusDescription>
  <AuthenticationResultCode>ValidCredentials</AuthenticationResultCode>
  <TraceId>
    dd31ffaf098f4406b7ecdd0da36680ff
  </TraceId>
  <ResourceSets>
    <ResourceSet>
      <EstimatedTotal>1</EstimatedTotal>
      <Resources>
        <Location>
          <Name>1 Microsoft Way, Redmond, WA 98052</Name>
          <Point>
            <Latitude>47.640568390488625</Latitude>
            <Longitude>-122.1293731033802</Longitude>
          </Point>
          <BoundingBox>
            <SouthLatitude>47.636705672917948</SouthLatitude>
            <WestLongitude>-122.137016420622</WestLongitude>
            <NorthLatitude>47.6444311080593</NorthLatitude>
            <EastLongitude>-122.1217297861384</EastLongitude>
          </BoundingBox>
          <EntityType>Address</EntityType>
          <Address>
            <AddressLine>1 Microsoft Way</AddressLine>
            <AdminDistrict>WA</AdminDistrict>
            <AdminDistrict2>King Co.</AdminDistrict2>
            <CountryRegion>United States</CountryRegion>
            <FormattedAddress>1 Microsoft Way, Redmond, WA 98052</FormattedAddress>
            <Locality>Redmond</Locality>
            <PostalCode>98052</PostalCode>
          </Address>
          <Confidence>Medium</Confidence>
          <MatchCode>Good</MatchCode>
          <GeocodePoint>
            <Latitude>47.640568390488625</Latitude>
            <Longitude>-122.1293731033802</Longitude>
            <CalculationMethod>Interpolation</CalculationMethod>
            <UsageType>Display</UsageType>
            <UsageType>Route</UsageType>
          </GeocodePoint>
        </Location>
      </Resources>
    </ResourceSet>
  </ResourceSets>
</Response>

Yes, you can do this via the Bing Maps REST API, you need to perform a reverse geocode. This is done by GET-ing the following request:

http://dev.virtualearth.net/REST/v1/Locations/47.64054,-122.12934?o=xml&key=BingMapsKey

Which will return the address in XML format:

<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1">
  <Copyright>
    Copyright © 2011 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.
  </Copyright>
  <BrandLogoUri>
    http://dev.virtualearth.net/Branding/logo_powered_by.png
  </BrandLogoUri>
  <StatusCode>200</StatusCode>
  <StatusDescription>OK</StatusDescription>
  <AuthenticationResultCode>ValidCredentials</AuthenticationResultCode>
  <TraceId>
    dd31ffaf098f4406b7ecdd0da36680ff
  </TraceId>
  <ResourceSets>
    <ResourceSet>
      <EstimatedTotal>1</EstimatedTotal>
      <Resources>
        <Location>
          <Name>1 Microsoft Way, Redmond, WA 98052</Name>
          <Point>
            <Latitude>47.640568390488625</Latitude>
            <Longitude>-122.1293731033802</Longitude>
          </Point>
          <BoundingBox>
            <SouthLatitude>47.636705672917948</SouthLatitude>
            <WestLongitude>-122.137016420622</WestLongitude>
            <NorthLatitude>47.6444311080593</NorthLatitude>
            <EastLongitude>-122.1217297861384</EastLongitude>
          </BoundingBox>
          <EntityType>Address</EntityType>
          <Address>
            <AddressLine>1 Microsoft Way</AddressLine>
            <AdminDistrict>WA</AdminDistrict>
            <AdminDistrict2>King Co.</AdminDistrict2>
            <CountryRegion>United States</CountryRegion>
            <FormattedAddress>1 Microsoft Way, Redmond, WA 98052</FormattedAddress>
            <Locality>Redmond</Locality>
            <PostalCode>98052</PostalCode>
          </Address>
          <Confidence>Medium</Confidence>
          <MatchCode>Good</MatchCode>
          <GeocodePoint>
            <Latitude>47.640568390488625</Latitude>
            <Longitude>-122.1293731033802</Longitude>
            <CalculationMethod>Interpolation</CalculationMethod>
            <UsageType>Display</UsageType>
            <UsageType>Route</UsageType>
          </GeocodePoint>
        </Location>
      </Resources>
    </ResourceSet>
  </ResourceSets>
</Response>
眼藏柔 2025-01-09 07:56:19

您可以利用 Microsoft 提供的 Web 服务,根据您提供的纬度和经度返回城市、州和国家/地区。

通过提供链接 http://msrmaps.com/TerraService2.asmx 在项目中创建 Web 服务引用

我已将该服务命名为 myTerraService

myTerraService.TerraServiceSoapClient client = new myTerraService.TerraServiceSoapClient();
        client.ConvertLonLatPtToNearestPlaceCompleted += new EventHandler<myTerraService.ConvertLonLatPtToNearestPlaceCompletedEventArgs>(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
    }

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<myTerraService.ConvertLonLatPtToNearestPlaceCompletedEventArgs>(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
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文