aytee / 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

Using Zoom Control try zooming in after max zoom, Markers disappear. #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Demo link or sample code:
http://google-maps-utility-library-
v3.googlecode.com/svn/tags/markerclusterer/1.0/examples/simple_example.html

What steps will reproduce the problem?
1. Zoom in to a any particular until you reach the maximum zoom.
2. Click on the Zoom In Control.
3. The marker disappears.

Expected result:
The marker should remain or the zoom event should be avoided after the map 
has reached the maximum zoom

Actual result:
The marker disappears.

Version: ###

Browser / Operating System:
FF3 / WIN

Cyril

Original issue reported on code.google.com by cyrils...@gmail.com on 3 Jun 2010 at 10:41

GoogleCodeExporter commented 9 years ago
Same issue on Mac/Safari + Firefox

Original comment by merul.pa...@gmail.com on 9 Oct 2010 at 4:57

GoogleCodeExporter commented 9 years ago
Are you still seeing a problem if you try the latest version?

Original comment by lu...@google.com on 31 Mar 2011 at 6:03

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It seems the following is happening:

1. When the maximum zoom level is reached, the map zoom_changed event is fired. 
2. That results in cMarkerClusterer.resetViewport_(false) being called, which 
removes all the markers/cluster icons from the map.
3. The map idle event is *not* called (since the zoom level has not changed, 
since we are at the maximum zoom level), which results in markers/cluster icons 
not being recreated. 

I think the zoom_changed event shouldn't be fired in the first place.

The following workarrounds work for me, I'm not sure if it's the most clean way 
to tackle the issue though:

    // Add the map event listeners
    var resetViewport = false;
    this.listeners_ = [
    google.maps.event.addListener(this.getMap(), "zoom_changed", function () {
        resetViewport = true;
    }),
    google.maps.event.addListener(this.getMap(), "idle", function () {
        if (resetViewport)
            cMarkerClusterer.resetViewport_(false);

        cMarkerClusterer.redraw_();
    })

OR

var lastZoom = this.getMap().getZoom();
    var redraw = false;
    this.listeners_ = [
    google.maps.event.addListener(this.getMap(), "zoom_changed", function () {
        if (this.getZoom() != lastZoom) {
            cMarkerClusterer.resetViewport_(false);
            redraw = true;
            lastZoom = this.getZoom();
        }
    }),
    google.maps.event.addListener(this.getMap(), "idle", function () {
        if (redraw) {
            cMarkerClusterer.redraw_();
            redraw = false;
        }
    })

Original comment by g...@superpointer.com on 16 Aug 2011 at 2:09

GoogleCodeExporter commented 9 years ago
Hi, 
I had the same problem on one of my maps...
I solved it by using ">=" instead of ">"

Because, when we reach the maximum zoom, we need to display all the markers, we 
can't cluster it anymore...

line 457 :
if (this.map_.getZoom() >= this.markerClusterer_.getMaxZoom())

Line 508
if (this.map_.getZoom() > this.markerClusterer_.getMaxZoom()) {

Also, i have another problem... When using an Hybrid map or a Satellite map..
Becase the real max zoom is not equal to the theorical one... in my case, the 
theorical one is 22, and the real one is 19..
My problem is that the function to get the real zoom on hybrid or satellite map 
is a asynchronous call to google servers.. and so, when my callback function is 
called, i don't know anymore on wich cluster i asked (especially if i did 
multiple requests..)

The fact is, my markers are so close that they could be separated only with a 
big zoom... and the maximum zoom don't reach this level, so i need to display 
them at the max zoom...

Hope the first part helps..
Hope the second one will find an answer...

Marc

Original comment by MarcPoly...@gmail.com on 1 Sep 2011 at 6:52

GoogleCodeExporter commented 9 years ago
I have this on v2.0.7 also. The problem is that The maps API throws a 
zoom_changed every time you click a zoom control, even if it doesn't result in 
the zoom changing (duh!). I've worked around it in a similar way to the above 
by adding a currentZoom property and a check/return in the zoom_changed 
listener.

Original comment by tim.poul...@gmail.com on 26 Jan 2012 at 8:27