通过输入 Landmark 获取邮政编码 [英] Get postal code by entering Landmark
问题描述
我有一个文本框,用户将在其中输入一个地标,我必须检索该地标的邮政编码.我不知道如何完成这项任务.我需要一些帮助
Google 是您的最佳选择.在 Google Map API 上使用反向地理编码(地址查找)来检索邮政编码
<块引用><块引用>术语地理编码通常是指将人类可读的地址转换为地图上的位置.反过来做的过程,将地图上的位置翻译成人类可读的地址,是称为反向地理编码.
地理编码 API 支持直接使用 latlng 进行反向地理编码范围.例如,以下查询包含布鲁克林某个位置的纬度/经度值:
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true_or_false
此查询返回以下结果:
<代码>{"状态": "好的",结果": [ {类型":街道地址,"formatted_address": "275-291 Bedford Ave, Brooklyn, NY 11211, USA",address_components":[ {"long_name": "275-291","short_name": "275-291",类型":street_number}, {"long_name": "贝德福德大街","short_name": "贝德福德大街",类型":路线}, {"long_name": "纽约","short_name": "纽约",类型":[地方",政治"]}, {"long_name": "布鲁克林","short_name": "布鲁克林","类型": [ "administrative_area_level_3", "political"]}, {"long_name": "国王","short_name": "国王","类型": [ "administrative_area_level_2", "political"]}, {"long_name": "纽约","short_name": "纽约","类型": [ "administrative_area_level_1", "political"]}, {"long_name": "美国","short_name": "美国",类型":[国家",政治"]}, {"long_name": "11211","short_name": "11211",类型":postal_code}],
阅读更多:https://developers.google.com/maps/documentation/geocoding/#Types
I have a textbox, in which user will enter a Landmark and I have to retrieve a postal code of that landmark. I have no idea how to complete this task. I need some assisstance
Google is your best bet. Use Reverse Geocoding (Address Lookup) on Google Map API to retrieve the postal code
The term geocoding generally refers to translating a human-readable address into a location on a map. The process of doing the converse, translating a location on the map into a human-readable address, is known as reverse geocoding.
The Geocoding API supports reverse geocoding directly using the latlng parameter. For example, the following query contains the latitude/longitude value for a location in Brooklyn:
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true_or_false
This query returns the following result:
{
"status": "OK",
"results": [ {
"types": street_address,
"formatted_address": "275-291 Bedford Ave, Brooklyn, NY 11211, USA",
"address_components": [ {
"long_name": "275-291",
"short_name": "275-291",
"types": street_number
}, {
"long_name": "Bedford Ave",
"short_name": "Bedford Ave",
"types": route
}, {
"long_name": "New York",
"short_name": "New York",
"types": [ "locality", "political" ]
}, {
"long_name": "Brooklyn",
"short_name": "Brooklyn",
"types": [ "administrative_area_level_3", "political" ]
}, {
"long_name": "Kings",
"short_name": "Kings",
"types": [ "administrative_area_level_2", "political" ]
}, {
"long_name": "New York",
"short_name": "NY",
"types": [ "administrative_area_level_1", "political" ]
}, {
"long_name": "United States",
"short_name": "US",
"types": [ "country", "political" ]
}, {
"long_name": "11211",
"short_name": "11211",
"types": postal_code
} ],
Read more : https://developers.google.com/maps/documentation/geocoding/#Types
这篇关于通过输入 Landmark 获取邮政编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!