question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Markers cut off when using zoomToBoundsOnClick

See original GitHub issue

screen shot 2013-06-06 at 11 30 27 am

screen shot 2013-06-06 at 11 32 07 am

In the second image, you can see that after the zoom, the markers are partially outside the bounds. Is this an issue with the zoomToBoundsOnClick function not calculating the size of the markers, or something that I’m doing wrong? It does include the exact lat/lng point of the marker, but it seems like it should account for the markers so that you can actually click on them after the zoom.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
arnoldbirdcommented, Jun 28, 2013

In case it’s of use to others, I ended up setting zoomToBoundsOnClick to false and doing something like this to get finer control over the zoom…

markers.on(‘clusterclick’, function (a) { var bounds = a.layer.getBounds().pad(0.5); map.fitBounds(bounds); });

0reactions
int-uacommented, Jun 2, 2015

In my case @arnoldbird 's code was sometimes not zooming at all on small screens so I’ve added zooming in indefinitely if it failed to zoom in on cluster click:

markers.on('clusterclick', function (a) {
    previous_bounds = MAP.getBounds();
    bounds = a.layer.getBounds().pad(0.16);
    MAP.fitBounds(bounds);
    if (previous_bounds.equals(MAP.getBounds())) {
        MAP.zoomIn();
    }
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Limit Zoom level when markers are on the same position
I would like to limit the zoom level when user click on one cluster with a code like this : markers.on('clusterclick', function (a)...
Read more >
Showing popup with info about all markers in the clustered ...
To display popup upon marker cluster click with info about all the markers in the cluster, there are several things needed:.
Read more >
Leaflet.markercluster | Marker Clustering plugin for Leaflet
showCoverageOnHover: When you mouse over a cluster it shows the bounds of its markers. zoomToBoundsOnClick: When you click a cluster we zoom to...
Read more >
Leaflet Marker Cluster Group - JSFiddle - Code Playground
var markers = L.markerClusterGroup({. 5. spiderfyOnMaxZoom: true, ... zoomToBoundsOnClick: true ... Use jQuery to load date from GeoJSON file.
Read more >
https://raw.githubusercontent.com/rstudio/leaflet/...
Evaluate list members that are formulae, using the map data as the ... it shows the bounds #' of its markers #' @param...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found