question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Snapping the map to the bounds of the geojson layer

See original GitHub issue

Hey, just wanted to see if you had advice for snapping the map to the boundaries of the geojson layer? I know how I’d do it in vanilla JS, but since the geojson is initialized inside a child component, I’m not sure the best place to hook into it in order to fire the .getBounds() and .fitBounds() calls. My guess is to do it on mounted and again on updated using a ref to the map and geojson layer but wanted to see if this was already thought through by chance?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
timwiscommented, Sep 12, 2017

FYI, watch didn’t quite work because it’s executed prior to the DOM updates, so this.$refs.geojsonLayer is not defined yet. I ended up calling it during the updated lifecycle hook.

0reactions
timwiscommented, Sep 11, 2017

That sounds perfect, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Snapping the map to the bounds of the geojson layer · Issue #76
Hey, just wanted to see if you had advice for snapping the map to the boundaries of the geojson layer? I know how...
Read more >
Geting fitBounds and removeLayers to work in Leaflet
I have been unsuccessful getting fitBounds to work. When the map loads a category of markers from the dropdown, I want any existing...
Read more >
Working with large GeoJSON sources in Mapbox GL JS | Help
Tools like geojsplit make the process of breaking up GeoJSON sources manageable. Once the data has been divided, each source can be added...
Read more >
Finding center and zoom level in leaflet, given a list of lat-long ...
The easiest way is with a LatLngBounds object. You can then have the map fitBounds. Or get its center manually if you prefer....
Read more >
Maps & Geocoding with Vega-Lite and Leaflet | TUTORIAL ...
Mapping Layers on Leaflet's Maps: Polygons/Areas/Boundaries · Notice here how we're creating a new layer called grandCentralLayer , which takes in geoJSON info ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found