views:

179

answers:

1

I need infoWindow to be opened instead of zooming in map, when clicking on the ClusterMarker. I am using Gmaps util library MarkerClusterer for creating cluster of markers. I tried changing following line in markerclusterer.js

ClusterMarker_.prototype = new GOverlay();

with

ClusterMarker_.prototype = new GMarker();

so that I can get the openInfoWindow() function in the clustermarker, but that didnt worked out. Got some error. If possible, Please suggest solution so that this can be done with MarkerClusterer. Or else any other library which will be able to do this. Any help will be appreciated.

A: 

You are probably better off modifying the click event for the marker in markerclusterer.js starting on line 672.

Currently:

  GEvent.addDomListener(div, "click", function () {
    var pos = map.fromLatLngToDivPixel(latlng);
    var sw = new GPoint(pos.x - padding, pos.y + padding);
    sw = map.fromDivPixelToLatLng(sw);
    var ne = new GPoint(pos.x + padding, pos.y - padding);
    ne = map.fromDivPixelToLatLng(ne);
    var zoom = map.getBoundsZoomLevel(new GLatLngBounds(sw, ne), map.getSize());
    map.setCenter(latlng, zoom);
  });

Change to something like:

  GEvent.addDomListener(div, "click", function () {
    map.openInfoWindowHtml(latlng, "Put your infowindow content here");
  });

Obviously, depending on how much you want to abstract things, you could do a couple of things:

  • Add configuration options to MarkerClusterer to specify whether to do zoom in functionality or infowindow functionality
  • Define a callback function setup where you specify what function MarkerClusterer will call when a cluster is clicked.
Mark
Because I didnt digged out properly in the API, I wasn't aware that i can open infoWindow using map object, thought only GMarker can do that. And was trying to make my ClusterNarker_ a GMarker. But that didnt worked out. Thanks for the redirection. Maybe this will work out. But I have to wait till monday to check out if it works.Thanks again
vishwanath