calvinmetcalf / shapefile-js

Convert a Shapefile to GeoJSON. Not many caveats.
http://calvinmetcalf.github.io/shapefile-js/
MIT License
735 stars 230 forks source link

Set view automatically based on the shapefile #154

Closed tongwang closed 3 years ago

tongwang commented 3 years ago

Hi there,

Is there a way to determine the geographical center of the shapefile and the area it covers so that we can set the view of the map optimally as opposed to hardcoding the view, as shown in all the demos? Thanks!

calvinmetcalf commented 3 years ago

yes you can call getBounds() on the layer and then pass that to map.fitBounds()