cluster infowindow using markercluster.js

1,887 views
Skip to first unread message

Giovanni

unread,
Oct 19, 2010, 12:12:22 PM10/19/10
to Google Maps JavaScript API v3
Hi there,

I am using Luke's markercluster.js (v3) to display XML points.
Sometimes happens that point
have same location, so I would like to open an info window over the
cluster and render the XML info.

I was able to do it into an alert call, but I would like to use the
google.maps.event.addListener
and the infowindow.open.
What I did so far is set a for loop into the ClusterIcon class

foo = ""
for(i=0; i < this.cluster_.markers_.length; i++) {

foo = foo + this.cluster_.markers_[i].idx + " " +
this.cluster_.markers_[i].position + "\n"
}

alert(foo);

Any suggestions? Thank you, Giovanni

Luke Mahé

unread,
Oct 19, 2010, 8:33:10 PM10/19/10
to google-map...@googlegroups.com
Hi Giovanni,

What you can do is listen to the clusterclick event on the MarkerClusterer and your callback will be passed the cluster that was clicked.

From the cluster you can get all markers by calling getMarkers() and the center by calling getCenter(); and with that information you can open a infowindow with what ever content you want.

Hope this helps.

- Luke


--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Giovanni Zambotti

unread,
Oct 25, 2010, 12:03:55 PM10/25/10
to google-map...@googlegroups.com
Dear Luke,

thank you for your suggestion. Since I would like to use a mouse over I have modified a little bit you original
"markerclusterer.js". The script works but I can not get work the MOUSEOUT Event. Any suggestion?
Here the site (http://cga-3.hmdc.harvard.edu/cluster/index_v4.html)
Here what I did:

ClusterIcon.prototype.triggerClusterOver = function() {
    //var markerClusterer = this.cluster_.getMarkerClusterer();
   
    // Trigger the clusterclick event.
    //google.maps.event.trigger(markerClusterer, 'mouseover', this.cluster_);

   
    foo = ""   
    for(i=0; i < this.cluster_.markers_.length; i++) {   
        foo = foo + this.cluster_.markers_[i].idx + " " + this.cluster_.markers_[i].position + "<br />";       
        //foo = foo + data.photos[this.cluster_.markers_[i].idx].photo_id + "\n"
    }   
   
    var infowindow = new google.maps.InfoWindow({ content: foo });
    infowindow.setPosition(this.cluster_.getCenter());
    if (infowindow.view) {
        infowindow.close();
    }
    else{       
        infowindow.open(map);
    }
};
--
Giovanni Zambotti
34 Prince st, Cambridge MA
02139 USA
Phone: (617) 492 - 0359

raje...@matchpointgps.com

unread,
Jan 2, 2017, 5:17:51 PM1/2/17
to Google Maps JavaScript API v3
HI,

I need a small help on showing info-window on clusters.
i would like to describe my problem in brief,
i have 'n' numbers of markers on my map and on each click of marker respective infowindow is shown.
now, i have cluster which has this markers in them.so when user clicks on particular cluster it should open an infowindow showing all the list of markers in them.
and when user clicks on those markers in infowindow it should open up a respective infowindow for that markers alongside of cluster markers.
please help me with this.

Sudip Barman

unread,
Jan 3, 2017, 4:28:59 AM1/3/17
to Google Maps JavaScript API v3
Hi Rajendra,
Use this documentation to get all your answers.

Thanks,
Sudip Barman
Reply all
Reply to author
Forward
0 new messages