通过邮政编码和对象名称查找位置

发布于 2024-09-14 12:04:39 字数 123 浏览 5 评论 0原文

我想创建一个应用程序,通过邮政编码和对象名称(例如麦当劳)来显示经度、纬度。我尝试通过谷歌地图地理编码器来做到这一点,但我的想法是错误的,因为地理编码器返回了奇怪的结果。也许有人知道通过邮政编码/名称获取位置的服务或策略,请告诉我。

I wanted to create app that will longitude, latitude by zip and name of object (for example mcdonalds). I tried to do that via google maps geocoder but my idea was wrong because geocoder returned weird results. Maybe someone know a service or strategy of getting location by zip/name please let me know.

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

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

发布评论

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

评论(2

∝单色的世界 2024-09-21 12:04:39

您可以通过在maps.google.com 搜索框中使用相同的搜索字符串来测试Google Geocoder。例如“McDonalds 2000 Australia",返回适当的地理编码结果。包括国家在内吗?这可能会澄清搜索结果。

You can test out the Google Geocoder by using the same search string in the maps.google.com search box. For example "McDonalds 2000 Australia", returns appropriate geocoding results. Are you including the country? That might clarify the search results.

一片旧的回忆 2024-09-21 12:04:39

标签中的reverse-geocoding 表示具有给定纬度和经度的地理位置。

如果你想对某些东西进行地理编码,你应该使用 Google Maps Geocode API。

http://maps.google.com/maps/api/geocode/json?address=Sydney&sensor=false

在 result 中,您有:

{
  "status": "OK",
  "results": [ {
    "types": [ "locality", "political" ],
    "formatted_address": "Sydney Nowa Południowa Walia, Australia",
    "address_components": [ {
      "long_name": "Sydney",
      "short_name": "Sydney",
      "types": [ "locality", "political" ]
    }, {
      "long_name": "Nowa Południowa Walia",
      "short_name": "NSW",
      "types": [ "administrative_area_level_1", "political" ]
    }, {
      "long_name": "Australia",
      "short_name": "AU",
      "types": [ "country", "political" ]
    } ],
    "geometry": {
      "location": {
        "lat": -33.8671390,
        "lng": 151.2071140
      },
      "location_type": "APPROXIMATE",
      "viewport": {
        "southwest": {
          "lat": -33.8764033,
          "lng": 151.1911066
        },
        "northeast": {
          "lat": -33.8578737,
          "lng": 151.2231214
        }
      },
      "bounds": {
        "southwest": {
          "lat": -33.8797030,
          "lng": 151.1970330
        },
        "northeast": {
          "lat": -33.8559920,
          "lng": 151.2229770
        }
      }
    }
  } ]
}

results 数组中,您有结果对象。坐标位于geometry->location中。
没有比这更简单的了。

以下是参考:http://code.google .com/intl/pl-PL/apis/maps/documentation/geocoding/#GeocodingRequests

reverse-geocoding from your tags means geolocation with given latitude and longitude.

If you want to geocode something you should just use Google Maps Geocode API.

http://maps.google.com/maps/api/geocode/json?address=Sydney&sensor=false

In result you have:

{
  "status": "OK",
  "results": [ {
    "types": [ "locality", "political" ],
    "formatted_address": "Sydney Nowa Południowa Walia, Australia",
    "address_components": [ {
      "long_name": "Sydney",
      "short_name": "Sydney",
      "types": [ "locality", "political" ]
    }, {
      "long_name": "Nowa Południowa Walia",
      "short_name": "NSW",
      "types": [ "administrative_area_level_1", "political" ]
    }, {
      "long_name": "Australia",
      "short_name": "AU",
      "types": [ "country", "political" ]
    } ],
    "geometry": {
      "location": {
        "lat": -33.8671390,
        "lng": 151.2071140
      },
      "location_type": "APPROXIMATE",
      "viewport": {
        "southwest": {
          "lat": -33.8764033,
          "lng": 151.1911066
        },
        "northeast": {
          "lat": -33.8578737,
          "lng": 151.2231214
        }
      },
      "bounds": {
        "southwest": {
          "lat": -33.8797030,
          "lng": 151.1970330
        },
        "northeast": {
          "lat": -33.8559920,
          "lng": 151.2229770
        }
      }
    }
  } ]
}

In results array you have result objects. Coordinates are just in geometry->location.
Nothing simplier.

Here is reference: http://code.google.com/intl/pl-PL/apis/maps/documentation/geocoding/#GeocodingRequests

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