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

Any easy method to change center and zoom to fit a polygon layer #360

Closed
palewire opened this Issue Nov 4, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@palewire
Contributor

palewire commented Nov 4, 2011

In OpenLayers, you can do something slick like this:

var poly = wkt.read(' ... ');
var bounds = poly.geometry.getBounds();
map.zoomToExtent(bounds);

Is there a way to make that happen in Leaflet?

@palewire

This comment has been minimized.

Show comment
Hide comment
@palewire

palewire Nov 4, 2011

Contributor

Ah, I think figured it out. RTFM, jerkus. How's something like this look?

var southWest = new L.LatLng(34.0177295716, -118.470884195),
    northEast = new L.LatLng(34.0524049939, -118.430298),
    bounds = new L.LatLngBounds(southWest, northEast);
map.fitBounds(bounds);

And you could dynamically fill in those corners, and I think you'd be flying.

Contributor

palewire commented Nov 4, 2011

Ah, I think figured it out. RTFM, jerkus. How's something like this look?

var southWest = new L.LatLng(34.0177295716, -118.470884195),
    northEast = new L.LatLng(34.0524049939, -118.430298),
    bounds = new L.LatLngBounds(southWest, northEast);
map.fitBounds(bounds);

And you could dynamically fill in those corners, and I think you'd be flying.

@mourner

This comment has been minimized.

Show comment
Hide comment
@mourner

mourner Nov 4, 2011

Member

I didn't yet document it but you can also do polyline.getBounds(). As for WKT, there's no Leaflet parser for it but it would be quite easy to write, so I think such plugin will appear soon.

Member

mourner commented Nov 4, 2011

I didn't yet document it but you can also do polyline.getBounds(). As for WKT, there's no Leaflet parser for it but it would be quite easy to write, so I think such plugin will appear soon.

@mourner mourner closed this Nov 4, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment