Sid*_*mit 4 android google-maps google-maps-api-3 google-places-api
您好,我想使用 google place api 搜索最近的位置....
来自https://developers.google.com/places/documentation/supported_types我在我的代码中使用了类型来搜索最近的地方......
代码如下
try {
double radius = 5000; // 10000 meters
// get nearest places
nearPlaces = googlePlaces
.search(gps.getLatitude(), gps.getLongitude(), radius,
"sublocality|sublocality_level_4|sublocality_level_5|sublocality_level_3|sublocality_level_2|sublocality_level_1|neighborhood|locality|sublocality");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
但找不到最近的地方
就像如果我在“美国加利福尼亚州圣地亚哥”那么我想得到这样的结果
Gaslamp/Downtown,
Pacific Beach,
Ocean Beach,
Uptown,
Hillcrest,
Mission Valley, Fashion Valley,
North Park,
但不是这个,我只得到两个值,比如
Mission Valley East,
塞拉梅萨
所以任何人都可以帮助我我必须通过什么类型,这样我就可以得到上面的结果而不是下面的结果
我之前的答案因未知原因被版主删除,我重新发布更多上下文,因为它是当前正确的答案:
您似乎正在尝试返回附近的地理位置(支持的地点类型中第二个列表中的任何内容)。不幸的是,Places API 不是为此而设计的,它旨在返回附近机构的列表(受支持的地点类型中第一个列表中的任何内容)和最多两个locality或political类型的结果,以帮助识别您正在执行地点的区域搜索请求。
此处的文档中对此进行了说明:https : //developers.google.com/places/documentation/search#PlaceSearchResponses
“results”包含一个 Places 数组,以及每个 Places 的信息。有关这些结果的信息,请参阅地方搜索结果。Places API 每次查询最多返回 20 个建立结果。此外,可能会返回政治结果,用于识别请求的区域。
如果您按地理位置类型过滤您的地方搜索请求,例如locality或political,您将过滤掉建立结果,只留下区域标识结果。
Places API - 返回附近地点的功能请求已在此处提交:http : //code.google.com/p/gmaps-api-issues/issues/detail?id=4434
如果您认为这将是一个有用的功能,请确保您的明星请求让我们知道您有兴趣看到它被添加。
| 归档时间: |
|
| 查看次数: |
3256 次 |
| 最近记录: |