-1

May I know how to get more than 10 data results from Google Map when using the radarSearch method that can retrieved 200 results and getDetails method? I want all the marker information is listed down in the white space below the map. However, I only get 10 of it. May I know the problem? The 10 result stay the same and may only change 1 of them when the browser is refresh for a few times.

Here is the code that I used to retrieve the information from Google Map and create the marker. I used the radar Search method to perform the search.

   function callback(results, status) {
    if (status !== google.maps.places.PlacesServiceStatus.OK) {
      console.error(status);
      return;
    }
    for (var i = 0, result; result = results[i]; i++) {
      addMarker(result);
    }
  }

  function addMarker(place) {
    var placesList = document.getElementById('test');
    var marker = new google.maps.Marker({
      map: map,
      position: place.geometry.location,
      icon: {
        url: 'http://maps.gstatic.com/mapfiles/circle.png',
        anchor: new google.maps.Point(10, 10),
        scaledSize: new google.maps.Size(10, 17)
      }
    });


      service.getDetails(place, function(result, status) {
        if (status !== google.maps.places.PlacesServiceStatus.OK) {
          console.error(status);
          return;
        }

        iname = result.name;
        iLatitude = [result.geometry.location.lat()];
        iLongitude = [result.geometry.location.lng()];
        iAddress = [result.formatted_address];

      placesList.innerHTML += '<li>' + iname +'&nbsp;&nbsp;&nbsp;&nbsp;'+ iAddress + '</li>';
      });
  }

ScreenShot of the result. The marker result is nearly 200, while the listed down data only consists of 10

Lewer Smith
  • 15
  • 1
  • 5
  • There are quotas and rate limits on the place service (check the status returned, you are logging it) – geocodezip Nov 21 '16 at 14:37
  • @geocodezip, Sir, does it due to the getDetails got quota? As what I know from the documentation is the search method got quota, but there are no clear statement about the quota of getDetails. Sir, may you explain in more detail. Thank you. – Lewer Smith Nov 21 '16 at 14:52
  • All google's service are subject to a quota and a rate limit, `getDetails` is no different (you should be logging the status `OVER_QUERY_LIMIT` after the 10th item) – geocodezip Nov 21 '16 at 14:54
  • @geocodezip, Sir can I resolve the OVER_QUERY_LIMIT problem with the solution that you proposed in the forum http://stackoverflow.com/questions/14014074/google-maps-api-over-query-limit-per-second-limit? – Lewer Smith Nov 21 '16 at 15:11

1 Answers1

1

Actually the problem is due to the OVER_QUERY_LIMIT issue, it can be bypass when the time sent request is delayed, setTimeout method can be implemented to avoid OVER_QUERY_LIMIT problem.

Replace with the code below. Can retrieve all the marker data on the map,(currently I have 148 restaurants marker on the Google Map)

   service.getDetails(place, function(result, status) {
        if (status === google.maps.places.PlacesServiceStatus.OK) {

        iname = result.name;
        iLatitude = [result.geometry.location.lat()];
        iLongitude = [result.geometry.location.lng()];
        iAddress = [result.formatted_address];

        placesList.innerHTML += '<li>' + iname + ''+ iAddress + '</li>';
        }

        else if (status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
        setTimeout(function() {
            addMarker(place);
        }, 200);
    }
      });
Lewer Smith
  • 15
  • 1
  • 5