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

Strange behaviour / race condition when calling fitBounds during init #2484

Closed
oliwel opened this issue Feb 22, 2014 · 1 comment
Closed

Comments

@oliwel
Copy link

oliwel commented Feb 22, 2014

Init a map, place some markers on a featureGroup and call "fitBounds" on the group freezes the map if some (unknown) conditions are met.

Code to reproduce:

<body><head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
</head>
<html>
<div style="width:1200px;height:500px" id="map"></div>
<script>
var map = L.map('map').setView([48.5, 9.35], 13);
L.tileLayer('http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png').addTo(map);

var layer = L.featureGroup().addTo(self.map);
layer.addLayer( L.marker([ 48.65, 9.35 ]) );
layer.addLayer( L.marker([ 49.05, 6.35 ]) );
layer.addLayer( L.marker([ 48.95, 8.60 ]) );
map.fitBounds( layer.getBounds() );
</script>
</html>
</body>

The problem disappears when changing size, zoom or starting point or using one of the workarounds calling given in #2470 or #2021.

@mourner
Copy link
Member

mourner commented Feb 22, 2014

Thanks for the report, but lets not create duplicates of the issue.

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