gpt4 book ai didi

javascript - 如何使用 Google Places API 获取邮政编码?

转载 作者:行者123 更新时间:2023-12-02 16:28:57 25 4
gpt4 key购买 nike

我使用 Google Places API 来实现自动完成。

我注意到 Google Places API 不返回某些地址的邮政编码:

网址:https://maps.googleapis.com/maps/api/place/autocomplete/json?input=3&types=address&language=en&key=MY_KEY

预测之一:

description = "3rd Avenue, NY, United States";
id = b9ea1b2047021e7b8f4d1e2d2033b4baafcc8d21;
"matched_substrings" = (
{
length = 1;
offset = 0;
}
);
"place_id" = Eh0zcmQgQXZlbnVlLCBOWSwgVW5pdGVkIFN0YXRlcw;
reference = "CjQhAAAAZddDjaWNLgFtHPG-JqwGI9W4kfxDj0DwYLQ9WtzJ8BdKJ-q7qu0YcrGHfdYCs_6-EhB6ZULyxVK-yFVOMmjt17XIGhT76Ln6Cy1sukn0DMKMLiqMADMmbg";
terms = (
{
offset = 0;
value = "3rd Avenue";
},
{
offset = 12;
value = NY;
},
{
offset = 16;
value = "United States";
}
);
types = (
route,
geocode
);

而且,当我调用这个地方的详细信息时,它甚至不返回邮政编码。

网址:https://maps.googleapis.com/maps/api/place/details/json?reference=CjQhAAAAtTsm_rHPRkKVkTBCXhFiRX7hjWshEAchbcqQslgpJaZEaDWyzqGzWsMmaZItCGO7EhCzWXberoKVpm0eIMJd8Uk2GhQxEpgyR_XiYLsvU3tc43ZsrK_M2Q&language=en&key=MY_KEY

结果:

"html_attributions" =     (
);
result = {
"address_components" = (
{
"long_name" = "3rd Ave";
"short_name" = "3rd Ave";
types = (
route
);
},
{
"long_name" = Manhattan;
"short_name" = Manhattan;
types = (
"sublocality_level_1",
sublocality,
political
);
},
{
"long_name" = "New York";
"short_name" = NY;
types = (
locality,
political
);
},
{
"long_name" = "New York County";
"short_name" = "New York County";
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
);
}
);
"adr_address" = "<span class=\"street-address\">3rd Ave</span>, <span class=\"locality\">New York</span>, <span class=\"region\">NY</span>, <span class=\"country-name\">USA</span>";
"formatted_address" = "3rd Ave, New York, NY, USA";
geometry = {
location = {
lat = "40.769058";
lng = "-73.9611034";
};
};
icon = "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png";
id = b9ea1b2047021e7b8f4d1e2d2033b4baafcc8d21;
name = "3rd Ave";
"place_id" = ChIJAScMMupYwokRnhWalEuqcnc;
reference = "CoQBfQAAACR4npz_DDE5pbhlslJYJ6h4obSF9CIvnIvEfySMR_FNLUFCfGGYOM858hmM8_FibAaO0AlA0Qq7EhFqorMoTh6jzknlsXRmwX2sMVSgqGX6YgGmzPPvlqHTOdAuXbWMYuKACZXiiJN4F4xpWmWgwqIXPRKU6qg0f8e3b-N9q5vQEhBHvnjfb7TBlz18IhaVnX1yGhTwAeuiDacEGbUVezjTvMQhXzK1Kw";
scope = GOOGLE;
types = (
route
);
url = "https://maps.google.com/maps/place?q=3rd+Ave,+New+York,+NY,+USA&ftid=0x89c258ea320c2701:0x7772aa4b949a159e";
vicinity = Manhattan;
};
status = OK;

如何使用 Google Places API 获取邮政编码?

最佳答案

这些结果可能太大,无法使用单个唯一的邮政编码。如果您对返回的位置进行反向地理编码(这不会是“使用 Google Places API”),它(可能)将有一个邮政编码(至少返回的最精确的结果会),但这是否有用还有待确定见过。

关于javascript - 如何使用 Google Places API 获取邮政编码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28470542/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com