Google 地方无法找到地图 API 可以找到的位置
Google Places not finding location that Maps API does
以下 link(地图 API)将肯辛顿圣地亚哥视为一个街区。
https://maps.googleapis.com/maps/api/geocode/json?address=kensington,%20san%20diego
{
"results" : [
{
"address_components" : [
{
"long_name" : "Kensington",
"short_name" : "Kensington",
"types" : [ "neighborhood", "political" ]
},
{
"long_name" : "San Diego",
"short_name" : "San Diego",
"types" : [ "locality", "political" ]
},
{
"long_name" : "San Diego County",
"short_name" : "San Diego County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "California",
"short_name" : "CA",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Kensington, San Diego, CA, USA",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 32.777394,
"lng" : -117.0968502
},
"southwest" : {
"lat" : 32.755116,
"lng" : -117.1127622
}
},
"location" : {
"lat" : 32.7668062,
"lng" : -117.1058848
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 32.777394,
"lng" : -117.0968502
},
"southwest" : {
"lat" : 32.755116,
"lng" : -117.1127622
}
}
},
"place_id" : "ChIJQXneX0pU2YARsIgYMQOsyks",
"types" : [ "neighborhood", "political" ]
}
],
"status" : "OK"
}
下面的link(地方API)找不到
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=36.26361161176487,-115.12227065576182&keyword=kensignton,%20san%20diego&rankby=distance(当然,如果没有 API 键,这个将无法工作,但即使有键,它也会以 ZERO_RESULTS 响应)
{
"html_attributions" : [],
"results" : [],
"status" : "ZERO_RESULTS"
}
但是我不能使用地图 api 找到我附近的星巴克(我试过了,它把我送到了加拿大)。那么...我怎样才能搜索星巴克、街区或地址并获得合理的结果
我不确定你所说的 "as a neighborhood" 是什么意思,但是下面的 link 将 return 圣地亚哥肯辛顿(一定要使用你的 API 密钥). returned 的细节与地图搜索明显不同。
对于此类搜索,请尝试使用文本搜索而不是附近搜索,并将 'keyword, or name' 替换为 'query'。
转到此页面并滚动到标题为 'Text Search Requests' 的部分以了解更多信息。
https://developers.google.com/places/web-service/search
以下 link(地图 API)将肯辛顿圣地亚哥视为一个街区。 https://maps.googleapis.com/maps/api/geocode/json?address=kensington,%20san%20diego
{
"results" : [
{
"address_components" : [
{
"long_name" : "Kensington",
"short_name" : "Kensington",
"types" : [ "neighborhood", "political" ]
},
{
"long_name" : "San Diego",
"short_name" : "San Diego",
"types" : [ "locality", "political" ]
},
{
"long_name" : "San Diego County",
"short_name" : "San Diego County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "California",
"short_name" : "CA",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Kensington, San Diego, CA, USA",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 32.777394,
"lng" : -117.0968502
},
"southwest" : {
"lat" : 32.755116,
"lng" : -117.1127622
}
},
"location" : {
"lat" : 32.7668062,
"lng" : -117.1058848
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 32.777394,
"lng" : -117.0968502
},
"southwest" : {
"lat" : 32.755116,
"lng" : -117.1127622
}
}
},
"place_id" : "ChIJQXneX0pU2YARsIgYMQOsyks",
"types" : [ "neighborhood", "political" ]
}
],
"status" : "OK"
}
下面的link(地方API)找不到 https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=36.26361161176487,-115.12227065576182&keyword=kensignton,%20san%20diego&rankby=distance(当然,如果没有 API 键,这个将无法工作,但即使有键,它也会以 ZERO_RESULTS 响应)
{
"html_attributions" : [],
"results" : [],
"status" : "ZERO_RESULTS"
}
但是我不能使用地图 api 找到我附近的星巴克(我试过了,它把我送到了加拿大)。那么...我怎样才能搜索星巴克、街区或地址并获得合理的结果
我不确定你所说的 "as a neighborhood" 是什么意思,但是下面的 link 将 return 圣地亚哥肯辛顿(一定要使用你的 API 密钥). returned 的细节与地图搜索明显不同。
对于此类搜索,请尝试使用文本搜索而不是附近搜索,并将 'keyword, or name' 替换为 'query'。
转到此页面并滚动到标题为 'Text Search Requests' 的部分以了解更多信息。 https://developers.google.com/places/web-service/search