0

I am zooming to the extent of a set of geoJSONs collected in a FeatureGroup with this call:

 map.fitBounds(myFeatureGroup.getBounds());

...I would like to extend the extent a bit; as it is the extent is right on the edge of the geoJSON.

Is there a way to do this? I am new to Leaflet (I am more familiar with the ArcGIS JS API, where i would use:

map.setExtent(fullExtent.expand(4))

1 Answer 1

2

Leaflet's map.fitBounds has an option padding which you can use like so:

map.fitBounds(polygon.getBounds(), { padding:[50,50] } );

JSFiddle demo: http://jsfiddle.net/1vjqjx6h/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.