汇总 Google 个地点数据

Summarize Google Places Data

我需要做一个总结一个特定地区(地区、城市、省或国家)的业务量的工作。 我想用Google个地方API,但是这个returns只用到60个地方。例如,在一个城市中,Google 地图中可以注册更多的 30,000 个地方。 我需要按类型(餐厅、咖啡、酒店、学校等...)汇总这些地方

我也知道有一项使用条款规定,任何人不得在个人数据库中存储 Google 个地方的任何信息。

我该如何开始这份工作,从哪里开始的一些线索已经帮助了我。

对于初学者,您可以参考 Google Maps Places API Documentation to learn more about the Places API. You can also implement it in the client side by using the Places Library 地图 JavaScript API。

要实现你想要的,你可以使用Places Nearby Search. You will use a location parameter to specify latitude/longitude around which to retrieve place information with a radius parameter set to a smaller value. Then use the type parameter to specify the type of place you want to get the count. Setting this lower value of radius and type of place is suggested to be inside the 60 results limit。此外,不要忘记在向地点 API.

你可以这样做 simple code 我在客户端创建的。

这是我设置参数请求的地方:

var request = {
    location: sydney,
    radius: '100',
    type: ['restaurant']
  };

这是调用 nearbySearch 请求的地方:

var service = new google.maps.places.PlacesService(map);

  service.nearbySearch(request, function(results, status) {
    if (status === google.maps.places.PlacesServiceStatus.OK) {
      for (var i = 0; i < results.length; i++) {
        createMarker(results[i]);
      }

      map.setCenter(results[0].geometry.location);

      document.getElementById("numPlaces").innerHTML = results.length;
      document.getElementById("typePlaces").innerHTML = request.type;
    }
  });
}

在调用 API 的脚本中设置了 API 键:

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places&callback=initMap" async defer></script>

希望对您有所帮助!