获取一个点附近的政治位置 - 谷歌地图API V3

Get political locations near by a point - Google Maps API V3

本文关键字:位置 谷歌地图 V3 API 一个 获取      更新时间:2023-09-26

我需要在谷歌地图上找到一个点附近的城市、城镇、社区等。我使用谷歌地方服务,但我只得到酒店,商店等,没有政治地点。

例如,尝试在 10000 米半径内获取巴黎的所有政治场所(100,rue de la Parcheminerie,75005 PARIS)。

你只得到一个结果:巴黎[地方性,政治]类型。

没有关于其他社区、城镇、城市等的信息。

然后,尝试使用 100000 米半径和零结果。

示例代码:

 //vars map, centerPoint, radius was previously set  
 function getPlacesOnRadius() {
        var request = {
            location: centerPoint,
            radius: radius * 1000,
            types: ['political']
        };
        var service = new google.maps.places.PlacesService(map);
        service.search(request, callback);
    }
    function callback(results, status) {
        if (status == google.maps.places.PlacesServiceStatus.OK) {
            for (var i = 0; i < results.length; i++) {
                var place = results[i];
                //createMarker(results[i]);
            }
        }
    }

顺便说一句,我已经设置了政治类型。

没有自己尝试过,但是在阅读文档后,我会假设如果您不指定您想要的地方类型,它只会返回主要城市。你能尝试设置类型=你想要的返回并告诉我们它是否仍然不起作用吗?:)

要么这样做,要么尝试发布您用于调用 Web 服务的代码并遍历结果数据,以便我们查看是否可以在那里执行某些操作。