Reputation: 329
I have a map with a circle drawn on it placed in the center of the map. Circle is always present on the map. Radius of the circle is adjustable by the user. On each radius change I am calling fitBounds like this:
leafletData.getMap().then(function(map){
var currentDiameter = L.circle(map.getCenter(), $scope.radius);
map.fitBounds(currentDiameter.getBounds());
});
Sometimes fitBounds moves the center of the map. I have tried recentering the map after each fitBounds call but it is not ideal.
Thanks in advance
Upvotes: 1
Views: 716
Reputation: 19049
It shouldn't be possible to get the bounds of a circle until it has been added to a map, for the same reasons as bug #4740.
Upvotes: 2