I've tried map.fitBounds(geojsonFeature.getBounds());
and I get this error:
geojsonFeature.getBounds() is not a function.
Here is the code: http://jsfiddle.net/0aqxktov/
What is going wrong here?
Thanks in advance.
Your variable geojsonFeature
is just an object, there is no method named getBounds()
there, as you can easily check.
Instead of that, give your geoJSON layer a name...
var feature = L.geoJson(geojsonFeature).addTo(map);
And use that to call getBounds()
:
map.fitBounds(feature.getBounds());
Here is the updated JSFiddle: http://jsfiddle.net/qofrgm2k/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With