小编Jos*_*ung的帖子

通过Google Places API分页获得20多项结果

谷歌的演示有一个片段,通过分页捕获来自地方搜索的20多个结果:

    service.nearbySearch(request, resultList, function(status, results, pagination) {
    if (status != google.maps.places.PlacesServiceStatus.OK) {
     return;
    }
    resultList.addPlaces(results);
    if (pagination.hasNextPage) {
      resultList.button.onClick = pagination.nextPage;
    }
  });
Run Code Online (Sandbox Code Playgroud)

我在尝试将此片段整合到以下示例中时遇到问题,github中的另一个谷歌地图示例,gmaps-samples-v3:

 <!DOCTYPE html>
<html>
  <head>
    <title>Places Search Demo</title>
    <link rel="stylesheet" type="text/css"
          href="https://google-developers.appspot.com/css/screen.css">
    <link rel="stylesheet"
          href="https://www.google.com/cse/style/look/default.css" type="text/css">
    <script type="text/javascript"
            src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places">
    </script>
    <script type="text/javascript">
      var map;
      var places;
      var iw;
      var markers = [];

      function initialize() {
        var options = {
          zoom: 12,
          center: new google.maps.LatLng(22.279387,114.164579),
          mapTypeId: google.maps.MapTypeId.ROADMAP,
          streetViewControl: false
        };
        var mapCanvas = document.getElementById('map_canvas');
        map = new google.maps.Map(mapCanvas, …
Run Code Online (Sandbox Code Playgroud)

javascript google-places-api

4
推荐指数
1
解决办法
8214
查看次数

标签 统计

google-places-api ×1

javascript ×1