google-maps-api-3kmlmarkerclusterergeoxml3

Parsing a .kml file with geoxml3 for markerclusterer: markers not popping up infowindow


I've got a map with markers loaded from a .kml file, and I'm using geoxml3 to parse it, and markerclusterer to cluster them. I've added some code to try and have the and tags on each of the markers in the kml file to be on an infoWindow when the user clicks on a marker. For some reason though, when I click on the marker, it doesn't create the infoWindow. I've previously added a console.log to make sure that it was recognizing the click, and it was, it just doesn't seem to want to make the infowindow.

You can view the page at http://tanagerproductions.com/test/site2/testmap.html

The .kml file is at http://tanagerproductions.com/test/site2/js/locations.kml


Solution

  • Looks like you are using the trunk version of geoxml3. That isn't really supported anymore. If you use the polys or the kmz branch, they are both supported.

    Here is a version of your page using the polys branch.

    Here is the updated createMarker function:

    createMarker:function(placemark){
        var point = placemark.latlng;
        var info = "<pre" + placemark.name + "<br /><br />" + placemark.description + "</pre>";
        var marker = new google.maps.Marker({position:point});
    
        google.maps.event.addListener(marker, "click", function(){
            infoWindow.setContent(info);
            infoWindow.open(map, marker);
        });
        markerclusterer.addMarker(marker);
    }
    

    You may just need the infoWindow.content = info; => infoWindow.setContent(info); change.

    (historical note, "trunk" version doesn't exist on github, so link below doesn't work anymore)
    Working version using the trunk geoxml3 version, so the only issue was the infoWindow.content is no longer supported in the API.