0

I have the following script to plot points on a Google Map using an KML file of points:

function initialize() {
    var myLatlng = new google.maps.LatLng(49.496675,-102.65625);
    var mapOptions = {
        zoom: 4,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    var mcOptions = {gridSize: 50, maxZoom: 15};

    markers = [];
    markerclusterer  = new MarkerClusterer(map, [], mcOptions);
    var infoWindow = new google.maps.InfoWindow({maxWidth:800});


    var myParser = new geoXML3.parser({
        map: map, singleInfoWindow:true,
        createMarker:function(placemark){
            //Constructing marker for each Placemark node, and then add it to the markclustere
            var point = new google.maps.LatLng(placemark.point.lat, placemark.point.lng);
            var marker = new google.maps.Marker({position:point});
            markerclusterer.addMarker(marker);

            google.maps.event.addListener(marker, "click", function(){
                    var marker_lat = marker.getPosition().lat();
                    var marker_lng = marker.getPosition().lng();
                    infoWindow.close(); 
                    infoWindow.setOptions({maxWidth:800});
                    content = "<strong>" + placemark.name + "</strong><br>" + placemark.description;
                    infoWindow.setContent(content);
                    infoWindow.open(map, marker);
                });
                markerclusterer.addMarker(marker);
            }

    });

        myParser.parse('/staff/people/index.kml') ;
}
google.maps.event.addDomListener(window, 'load', initialize);

I am trying to figure out how I can get a count of the number of points it plotted so I can update a div. I know how to update the div, just not sure how to get the count.

Any assistant would be greatly appreciated.

Thanks!

Pete
  • 467
  • 7
  • 20

1 Answers1

0

The length of the .markers array or the .placemarks array will give you the number of markers (if all the placemarks are markers).

myParser.docs[0].markers.length

or

myParser.docs[0].placemarks.length

similar question (counts markers in each polygon)

example from it

Community
  • 1
  • 1
geocodezip
  • 158,664
  • 13
  • 220
  • 245