andrija1987 / google-maps-utility-library-v3

Automatically exported from code.google.com/p/google-maps-utility-library-v3
Apache License 2.0
0 stars 0 forks source link

MarkerClusterer- Cluster disappears if max zoom is hit and cluster can not be broken #210

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use any browser I have seen
2. put two markers in the exact same spot
3. click on cluster
4. Map will zoom in and cluster is there
5. click on cluster again and cluster is gone

Expected result:
Even if markerClusterer can not break the cluster the icon should always be 
there.

Actual result:
If you are already zoomed in all the way and click on an "un-breakable" cluster 
the cluster icon for that cluster will disappear.

Here is my fix starting at line 144 of 2.0.15 (this fix only works for my 
implementation it will needed to be updated for all cases):

google.maps.event.addDomListener(this.div_, "click", function (e) {
        cMouseDownInCluster = false;
        if (!cDraggingMapByCluster) {
            var theBounds;
            var mz;
            var mc = cClusterIcon.cluster_.getMarkerClusterer();
            /**
             * This event is fired when a cluster marker is clicked.
             * @name MarkerClusterer#click
             * @param {Cluster} c The cluster that was clicked.
             * @event
             */
            google.maps.event.trigger(mc, "click", cClusterIcon.cluster_);
            google.maps.event.trigger(mc, "clusterclick", cClusterIcon.cluster_); // deprecated name

            // The default click handler follows. Disable it by setting
            // the zoomOnClick property to false.
            if (mc.getZoomOnClick()) {
                // Zoom into the cluster.
                mz = mc.getMaxZoom();
                theBounds = cClusterIcon.cluster_.getBounds();
                mc.getMap().fitBounds(theBounds);
                // There is a fix for Issue 170 here:
                setTimeout(function () {
                    mc.getMap().fitBounds(theBounds);
                    // Don't zoom beyond the max zoom level
                    if (mz !== null && (mc.getMap().getZoom() > mz)) {
                        mc.getMap().setZoom(mz + 1);
                    }
                    // getting the type the map is and what the zoom is set to
                    var mapType = mc.getMap().getMapTypeId();
                    var mapZoomLvl = mc.getMap().getZoom();

                    //if the zoom is set to the highest zoom we could have a cluster that is unbreakable.
                    // To make sure the cluster does not disappear repaint() is used. The repaint()
                    //function does a recalculation of all clusters and reprints them, thus if it did not
                    //break it will re print our cluster.
                    if ((mapZoomLvl == 21 && mapType == "roadmap") ||
                        (mapZoomLvl==20 && mapType == "hybrid"))
                    {
                        mc.repaint();//The Sites can not be broken repaint it on the screen
                    }
                }, 100);

            }

            // Prevent event propagation to the map:
            e.cancelBubble = true;
            if (e.stopPropagation) {
                e.stopPropagation();
            }
        }
    });

Version: keydragzoom r364

Browser / Operating System:
Win 7 IE 9 & Chrome

Original issue reported on code.google.com by prs.j...@gmail.com on 12 Nov 2012 at 8:09

GoogleCodeExporter commented 8 years ago
forgot to mention the portion I added is from 173 to 185 or 
from: // getting the type the map is and what the zoom is set to
To: mc.repaint();//The Sites can not be broken repaint it on the screen

Original comment by prs.j...@gmail.com on 12 Nov 2012 at 8:12

GoogleCodeExporter commented 8 years ago
Thanks for this patch. I also added '(mapZoomLvl==15 && mapType == "terrain")' 
for terrain map types.

Original comment by wal...@nceas.ucsb.edu on 13 Dec 2013 at 12:53

GoogleCodeExporter commented 8 years ago
dfghdfgh

Original comment by renzosta...@gmail.com on 5 Mar 2015 at 1:36