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

set max zoom for map #3

Closed
mapsam opened this issue Mar 26, 2015 · 1 comment
Closed

set max zoom for map #3

mapsam opened this issue Mar 26, 2015 · 1 comment

Comments

@mapsam
Copy link
Member

mapsam commented Mar 26, 2015

right now there are some unnecessary zoom events with L.markerCluster() that can be fixed by maxZoom

@mapsam
Copy link
Member Author

mapsam commented Mar 26, 2015

so markerCluster seems to not have included a new update that spiderfys if the zoom is unecessary. There's a nice pull request in the markercluster repo that makes sure zoom is necessary and if it isn't spiderfy occurs. Leaflet/Leaflet.markercluster#415

This needs to be updated in the source code for markercluster since it's not in their distribution version yet.

Here's the code to replace the _zoomOrSpiderfy function with:

_zoomOrSpiderfy: function (e) {
    var map = this._map;
    if (e.layer._bounds._northEast.equals(e.layer._bounds._southWest)){
      if (this.options.spiderfyOnMaxZoom) {
        e.layer.spiderfy();
    }
    } else if (map.getMaxZoom() === map.getZoom()) {
      if (this.options.spiderfyOnMaxZoom) {
        e.layer.spiderfy();
      }
    } else if (this.options.zoomToBoundsOnClick) {
      e.layer.zoomToBounds();
    }

    // Focus the map again for keyboard users.
    if (e.originalEvent && e.originalEvent.keyCode === 13) {
      map._container.focus();
    }
},

@mapsam mapsam mentioned this issue Mar 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants