Maximum Google Maps Markers

I am not too good with javascript. Does anyone know how I can increase the number of markers displayed on Google Maps. I pull about 300 locations from a MySQL database, but it is only 50 or so.

Here is the code I'm using:

    <script type="text/javascript">
//<![CDATA[

var iconBlue = new GIcon(); 
iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
iconBlue.iconSize = new GSize(12, 20);
iconBlue.shadowSize = new GSize(22, 20);
iconBlue.iconAnchor = new GPoint(6, 20);
iconBlue.infoWindowAnchor = new GPoint(5, 1);

var iconRed = new GIcon(); 
iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
iconRed.iconSize = new GSize(12, 20);
iconRed.shadowSize = new GSize(22, 20);
iconRed.iconAnchor = new GPoint(6, 20);
iconRed.infoWindowAnchor = new GPoint(5, 1);

var customIcons = [];
customIcons["city"] = iconBlue;

function load() {
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(47.614495, -122.341861), 1);
    map.setMapType(G_SATELLITE_MAP);

    GDownloadUrl("map-xml.php", function(data) {
      var xml = GXml.parse(data);
      var markers = xml.documentElement.getElementsByTagName("geolocation");
      for (var i = 0; i < markers.length; i++) {
        var time = markers[i].getAttribute("time");
        var date = markers[i].getAttribute("date");
        var city = markers[i].getAttribute("city");
        var type = markers[i].getAttribute("city");
        var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                parseFloat(markers[i].getAttribute("lng")));
        var marker = createMarker(point, time, date, city, type);
        map.addOverlay(marker);
      }
    });
  }
}

function createMarker(point, time, date, city, type) {
  var marker = new GMarker(point, customIcons[type]);
  var html = "<b>Time:" + time + "<br />Date:" + date + "<br/>City:" + city +"</b>";
  GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowHtml(html);
  });
  return marker;
}
//]]>

thanks

+3
source share
3 answers

I think you are looking for Marker Manager .

+5
source

I suspect your markers are being built, but you do not see them for some reason.

Make sure you do not draw many markers in exactly one place. If you draw one marker exactly on top of another, it looks like one marker, not two.

, . , .

customIcons [type] , . , . Javascript. ?

, . , API .

+1

, 300 (http://bic-church.org/about/churches/map.asp). JSON. , - -?

Edit: An additional thought: if you notice that it constantly fails at some point, check the data integrity for this token. You may find that it is bad lat / long or something like that.

0
source

Source: https://habr.com/ru/post/1723689/


All Articles