Ich habe eine Webseite, die Google Maps und die MarkerCluster-API verwendet. Ich muss in der Lage sein, alle Cluster auf der Karte mit einer bestimmten Zoomstufe zu erhalten. Nehmen Sie diesen Code zum Beispiel:Google Maps MarkerCluster API: Wie bekomme ich Cluster außerhalb der Bildschirmansicht?
//Where the center of the screen will be
var center = new google.maps.LatLng(37.4419, -122.1419);
var options = {
'zoom': 13,
'center': center,
//Google map type
'mapTypeId': google.maps.MapTypeId.ROADMAP
};
//Create the google map
var map = new google.maps.Map(document.getElementById("map"), options);
//Create the marker clusters, where markers is an array of lat and longs
var mc = new MarkerClusterer(map, markers);
//Print all of the clusters at zoom level 13
console.log(mc.getTotalClusters());
Das Problem ist, wenn es 10 Cluster auf Zoomstufe 13, aber nur 7 sind innerhalb meines Bildschirms Grenzen, dann wird der obige Code würde drucken nur aus 7. brauche ich einen Weg Zugriff auf alle Cluster, auch wenn sie nicht auf dem Bildschirm sind.
Einfaches Beispiel dafür, wie die MarkerClusterer funktioniert: https://googlemaps.github.io/js-marker-clusterer/examples/simple_example.html
Hier sind einige Hinweise auf die MarkerCluster API:
https://googlemaps.github.io/js-marker-clusterer/docs/reference.html
https://googlemaps.github.io/js-marker-clusterer/docs/examples.html
https://developers.google.com/maps/articles/toomanymarkers
Das ist perfekt! Vielen Dank für die ausführliche Antwort! – Jaitnium