2016-11-14 22 views
3

我很困惑,目前與谷歌地理編碼器。現在,如果我通過地址查詢「紐約市紐約市」,我得到的結果表明結果的類型是「類型」:[「locality」,「political」],但address_components中沒有局部地址。如果我查詢「坦佩,AZ」,同樣的事情。如果我搜索一個州,這些類型是administrative_area_level_1,但它只給了我在address_compenents中的國家。有任何想法嗎?谷歌地理編碼器遺漏類型地址組件

var geocoder = new google.maps.Geocoder(); 
geocoder.geocode({'address': "New York City, NY"}, function(results, status) { 
    if (status == google.maps.GeocoderStatus.OK) { 
     //do stuff 
    } else { 
     console.log("Geocode was not successful for the following reason: " + status); 
    } 

我對「紐約,紐約」

[{"address_components":[{"long_name":"New York","short_name":"NY","types":["administrative_area_level_1","political"]},{"long_name":"United States","short_name":"US","types":["country","political"]}],"formatted_address":"New York, USA","geometry":{"bounds":{"south":40.4773991,"west":-74.25908989999999,"north":40.9175771,"east":-73.7002721},"location":{"lat":40.7127837,"lng":-74.00594130000002},"location_type":"APPROXIMATE","viewport":{"south":40.4960439,"west":-74.2557349,"north":40.9152555,"east":-73.7002721}},"place_id":"ChIJOwg_06VPwokRYv534QaPC8g","types":["locality","political"]}] 

我很困惑,爲什麼它是告訴我結果是型城市(地區),但缺少當地的屬性。我希望當地的價值,「紐約」和格式化的地址在其中包括地方。謝謝!

+1

你在問什麼?你期待什麼「地點」?類型'[「locality」,「political」]'的結果是「New York」,狀態是long_name:「New York」或者short_name:「NY」。 – geocodezip

+2

我想我問爲什麼當我搜索紐約市,紐約時,地方屬性失蹤? –

+1

我編輯了我的原稿以顯示我的結果。 –

回答