Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Aug 3, 2015 · 7 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

Same issue on Mac/Safari + Firefox

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

@GoogleCodeExporter
Copy link
Author

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

  • Changed state: NeedsMoreInfo

@GoogleCodeExporter
Copy link
Author

[deleted comment]

1 similar comment
@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant