且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过输入 Landmark 获取邮政编码

更新时间:2023-02-21 19:39:07

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, ***lyn, 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 ***lyn:

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, ***lyn, 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": "***lyn",
      "short_name": "***lyn",
      "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