Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Offsetting the markers isn't a real solution if they're located in the same building. What you might want to do is modify the markerclusterer.js like so:</p> <ol> <li><p>Add a prototype click method in the MarkerClusterer class, like so - we will override this later in the map initialize() function:</p> <pre><code>MarkerClusterer.prototype.onClick = function() { return true; }; </code></pre></li> <li><p>In the ClusterIcon class, add the following code AFTER the clusterclick trigger:</p> <pre><code>// Trigger the clusterclick event. google.maps.event.trigger(markerClusterer, 'clusterclick', this.cluster_); var zoom = this.map_.getZoom(); var maxZoom = markerClusterer.getMaxZoom(); // if we have reached the maxZoom and there is more than 1 marker in this cluster // use our onClick method to popup a list of options if (zoom &gt;= maxZoom &amp;&amp; this.cluster_.markers_.length &gt; 1) { return markerClusterer.onClickZoom(this); } </code></pre></li> <li><p>Then, in your initialize() function where you initialize the map and declare your MarkerClusterer object:</p> <pre><code>markerCluster = new MarkerClusterer(map, markers); // onClickZoom OVERRIDE markerCluster.onClickZoom = function() { return multiChoice(markerCluster); } </code></pre> <p>Where multiChoice() is YOUR (yet to be written) function to popup an InfoWindow with a list of options to select from. Note that the markerClusterer object is passed to your function, because you will need this to determine how many markers there are in that cluster. For example:</p> <pre><code>function multiChoice(mc) { var cluster = mc.clusters_; // if more than 1 point shares the same lat/long // the size of the cluster array will be 1 AND // the number of markers in the cluster will be &gt; 1 // REMEMBER: maxZoom was already reached and we can't zoom in anymore if (cluster.length == 1 &amp;&amp; cluster[0].markers_.length &gt; 1) { var markers = cluster[0].markers_; for (var i=0; i &lt; markers.length; i++) { // you'll probably want to generate your list of options here... } return false; } return true; } </code></pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload