4

您好,我想使用 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;
}

但找不到最近的地方

就像我在“美国加利福尼亚州圣地亚哥”那么我想得到类似的结果

Gaslamp/Downtown,
Pacific Beach,
Ocean Beach,
Uptown,
Hillcrest,
Mission Valley, Fashion Valley,
North Park,

但不是这个,我只得到两个值

Mission Valley East,
塞拉梅萨

所以任何人都可以帮助我我必须通过什么类型,这样我就可以获得上面的结果而不是下面的结果

4

3 回答 3

5

由于未知原因,我之前的答案已被版主删除,我正在重新发布更多上下文,因为它是当前正确的答案:

您似乎正在尝试返回附近的地理位置(支持的地点类型中第二个列表中的任何内容)。不幸的是,Places API 不是为此而设计的,它旨在返回附近机构的列表(支持的地点类型中的第一个列表中的任何内容)和最多两个localityorpolitical类型的结果,以帮助识别您正在执行地点的区域搜索请求。

这在此处的文档中有所说明: https ://developers.google.com/places/documentation/search#PlaceSearchResponses

"results" contains an array of Places, with information about each. See Place Search Results for information about these results. The Places API returns up to 20 establishment results per query. Additionally, political results may be returned which serve to identify the area of the request.

If you type filter your Place Search request by a geographic location type like locality or political, you will filter out the establishment results and only be left with the area identity results.

A Places API - Feature Request for returning nearby localities has been filed here: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4434

If you believe this would be a useful feature please make sure your star the request to let us know you are interested in seeing it added.

于 2012-09-20T02:06:09.007 回答
0

双半径 = 5000 是 5 公里,刚好超过 3 英里。如果你增加半径,你应该返回更多的地方

于 2012-09-19T20:57:41.390 回答
0

您应该考虑到最大 50Km 的距离,并且有以下不同的类型:机构、住宿、水疗中心、酒吧、教堂、place_of_worship 等。

于 2012-09-19T21:09:08.160 回答