Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm having a problem integrating XML markers with MarkerClusterer. I need to integrate these two and show only the markers within bounds. I'm able to load the results in the XML to the map, but can not integrate the MarkerClusterer.

var customIcons = {
      Commercial: {
        icon: 'http://cdn1.iconfinder.com/data/icons/free-business-desktop-icons/32/Company.png',
      },
      Condo: {
        icon: 'http://cdn1.iconfinder.com/data/icons/REALVISTA/project_managment/png/32/agency.png',
      },
      Home: {
        icon: 'http://cdn1.iconfinder.com/data/icons/free-business-desktop-icons/32/Home.png',
      },
      Lot: {
        icon: 'http://cdn1.iconfinder.com/data/icons/Real-Estate-png/32/Lands.png',
      }
    };


function load() {
  var map = new google.maps.Map(document.getElementById("map"), {
    center: new google.maps.LatLng(<?php echo $lat ?>, <?php echo $long ?>),
    zoom: <?php echo $zoom ?>,
    mapTypeId: 'roadmap'
  });
  var infoWindow = new google.maps.InfoWindow;

  downloadUrl("mapxml.php", function(data) {
    var xml = data.responseXML;
    var markers = xml.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markers.length; i++) {
      var name = markers[i].getAttribute("name");
      var address = markers[i].getAttribute("address");
      var type = markers[i].getAttribute("type");
      var point = new google.maps.LatLng(
          parseFloat(markers[i].getAttribute("lat")),
          parseFloat(markers[i].getAttribute("lng")));
      var html = "<b>" + name + "</b> <br/>" + address;
      var icon = customIcons[type] || {};
      var marker = new google.maps.Marker({
        map: map,
        position: point,
        icon: icon.icon,
      });
      bindInfoWindow(marker, map, infoWindow, html);
    }
  });
}
share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.