Thank you CroNix - I had the same problem, and the changes you suggested fixed it:
- Declaring MarkerClusterer (var MarkerClusterer = null;) globally, at the top of the code - Not re-declaring the variable again later . Thanks again! On Thursday, 18 November 2010 03:53:42 UTC, CroNiX wrote: > > most likely it is an issue of scope due to where you are initially > declaring > var markerCluster = new MarkerClusterer(map,allMarkers, {gridSize: 5, > zoomOnClick: false}); > > It needs to be global. > > try doing: > var markerCluster = null; at the very TOP of your code before you do > anything else. Most likely you are declaring your map variable > somewhere like this needs to be done. > > then later where you have the > var markerCluster = new MarkerClusterer(map,allMarkers, {gridSize: 5, > zoomOnClick: false}); > > just remove the "var" and change it to: > markerCluster = new MarkerClusterer(map,allMarkers, {gridSize: 5, > zoomOnClick: false}); > > I think it will work then. > On Nov 17, 10:31 am, Martin Stjernegaard <mar...@starfarm.dk> wrote: > > Hi guys > > > > I'm working on a project where I need to implement the MarkerClusterer > > for the markers on the same location. That is already done, and big > > thanks to the people who created the MarkerClusterer. > > > > So what I want to do next is to open up an infowindow on the clusters > > that displays a list with the titles of the markers in the cluster. > > These titles needs to be clickable and open up the infowindow for the > > clicked marker. It is all showing up nicely, but the problem I'm > > facing is that i'm getting an error telling me that "clusterMarkers is > > not defined" when I click the links. > > > > I have seen elsewhere others using this piece of code to do the job, > > but somehow I can't make it work: > > google.maps.event.trigger(clusterMarkers[" + i + "], 'click' > > > > Here's my code so far: > > > > var markerCluster = new MarkerClusterer(map,allMarkers, {gridSize: 5, > > zoomOnClick: false}); > > var clusterMarkers = []; > > > > // Listen for a cluster to be cliced > > google.maps.event.addListener(markerCluster, 'clusterclick', > > function(cluster) { > > > > var content = ''; > > > > // Get info about the clustered markers > > clusterMarkers = cluster.getMarkers(); > > > > for(i=0; i<clusterMarkers.length;i++){ > > content += "<a href= > > \"javascript:google.maps.event.trigger(clusterMarkers[" + i + "], > > 'click')\">" + clusterMarkers[i].title + "</a><br />"; > > > > } > > > > // Convert lat/long from cluster object to a usable MVCObject > > var info = new google.maps.MVCObject; > > info.set('position', cluster.center_); > > > > var infowindow = new google.maps.InfoWindow(); > > infowindow.close(); > > infowindow.setContent(content); > > infowindow.open(map, info); > > > > I'm sorry that I don't have the project online so you can see it but I > > hope you can help me out anyway. > > > > Big thanks > > > > /Martin -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/DGfEizPh0KIJ. To post to this group, send email to google-maps-js-api-v3@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.