Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps JavaScript API Heatmap Layer- Limit of data points that can be displayed on the map?

I'm new to the Google Maps JavaScript API and I'm applying a heatmap layer on google maps, similarly to the example in the maps heatmap documentation:

https://developers.google.com/maps/documentation/javascript/examples/layer-heatmap

I'm loading a lot of datapoints for the heatmap but only a limited amount are displaying.

I don't see any issues with the data; when I cut the dataset into smaller chunks the heatmap appears in different places each time I load the map.

But I can see in the usage documentation (https://developers.google.com/maps/documentation/javascript/usage) that there's a limit of 2,500 requests per day, and I don't know what the definition of one request is in this scenario.

Is it that when the map loads with initMap(), the entire HeatmapLayer being applied is considered one single request?

Or is it that, when I'm creating a heatmap with 4,000 datapoints, each call to new google.maps.LatLng() for each datapoint is considered 4,000 separate requests?

like image 206
AnonyMouse Avatar asked Mar 08 '17 09:03

AnonyMouse


People also ask

How many markers can Google Maps API handle?

As far as I know there is no limit on how many markers you can add to a google-maps based map - however the performance of your map will decrease when you add a lot of them.

Which map layer allows you to show the concentration of data points by geographical location?

A heatmap is a visualization used to depict the intensity of data at geographical points. When the Heatmap Layer is enabled, a colored overlay will appear on top of the map.

What is the maximum number of markers or path vertices supported by the google Static maps API?

The maximum is 15. Note that this limit applies only to markers specified as a human-readable address that requires geocoding. It does not apply to markers specified with latitude/longitude coordinates. Too many geocoded polyline vertices requested (max is 15).

What can be seen in a heatmap?

A heat map shows a color-coded overlay of mouse (and tap) movement on a single website page. The 'popularity' of page elements is displayed using a color scale from red (the most popular parts of the page) to blue (the least-used parts of a page).


2 Answers

Following the example in the docs, I created an example that creates 10,000 points to plot on a heatmap, with no issue. So it can't be any kind of rate limit. There must be something else at play. This example does not even have an API key, so on the free plan.

Ten thousand heatmap point demo

<div id="map"></div>
<script>

        var map, heatmap;

  function initMap() {
    map = new google.maps.Map(document.getElementById('map'), {
      zoom: 2,
      center: {lat: 37.775, lng: -122.434},
    });

    heatmap = new google.maps.visualization.HeatmapLayer({
      data: getPoints(),
      map: map
    });
  }

  function getPoints() {

    var lotsOfMarkers = [];

    for( var i = 1; i <= 10000; i++) {

       var random = new google.maps.LatLng( (Math.random()*(85*2)-85), (Math.random()*(180*2)-180) );

        lotsOfMarkers.push(random);
    }

    return lotsOfMarkers;
  }
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?&libraries=visualization&callback=initMap">
</script>
like image 136
Paul Thomas Avatar answered Sep 21 '22 16:09

Paul Thomas


Well, the Google Maps JavaScript API has these following quotas if you check your developer console.

enter image description here

It means that you can load your map 25,000 times per day and the user can only make 1 request per second. While the unlimited here means that the maps can load simultaneosly.

So every time you call your API key like this, it count as a 1 load per day.

Note: The Daily quotas reset at midnight Pacific Time (PT)

like image 30
KENdi Avatar answered Sep 22 '22 16:09

KENdi