根据 lat & 获取邮政编码长的?

2022-01-14 00:00:00 geolocation javascript maps

是否有我可以 ping 通的服务或 API,并将 lat/long 作为参数传递,它会返回 lat/long 对所在的邮政编码?这是仅限美国,所以我不必担心国际代码等.

Is there a service or API I can ping, and pass in the lat/long as parameters, where it returns the zip code that lat/long pair is within? This is US-only, so I don't have to worry about international codes, etc.

我觉得谷歌地图的反向地理编码对我来说太重了.如果可能的话,我更喜欢更轻的东西.这将在 javascript 中完成.

I feel like Google Maps' reverse-geocoding is too heavy for me. I'd prefer something lighter, if possible. This will be done in javascript.

推荐答案

叫做反向地理编码(地址查找).要获取 lat: 40.714224, lng: -73.961452 的地址,请使用参数 latlng=40.714224,-73.961452& 查询 http://maps.googleapis.com/maps/api/geocode/jsonsensor=true (示例) 并返回 JSON 对象或使用 http://maps.googleapis.com/maps/api/geocode/xml 返回 XML 响应 (示例).它来自 Google,而且是免费的.

It is called Reverse Geocoding (Address Lookup). To get address for lat: 40.714224, lng: -73.961452 query http://maps.googleapis.com/maps/api/geocode/json with parameters latlng=40.714224,-73.961452&sensor=true (example) and it returns JSON object or use http://maps.googleapis.com/maps/api/geocode/xml to return XML response (example). It's from Google and it's free.

相关文章