How to fit view from extents?
See original GitHub issueHi, two stage problem.
- If I have working features and then try to wrap them in a vectorsource, the features disappear:
// Add marker for vehicle
vl-layer-vector
vl-source-vector(ref="vmarkers")
vl-feature(:id="'v_' + api" v-for="(data, api) in navSatFixData" :key="'v_' + api")
vl-geom-point(v-if="data && 'longitude' in data" :coordinates="[data.longitude, data.latitude]")
vl-style-box
vl-style-circle(:radius="api == activeApi ? 6 : 4")
vl-style-fill(:color="apis[api]['color-dark']")
vl-style-stroke(color="#666666" :width="api == activeApi ? 2 : 1")
- I would then like to use the vectorsource to determine the boundaries and zoom to autofit all the markers into view:
- https://stackoverflow.com/a/37385069
But
this.$refs.vmarkers.getExtent()
doesn’t exist?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to fit map view to a layer extent in OpenLayers5?
This was as easy as: const markerSource = new source.Vector(); //... map.getView().fit(markerSource.getExtent());.
Read more >Customizing your map extent—ArcMap | Documentation
A map extent defines the geographic boundaries for displaying GIS information within a data frame. These boundaries contain top, bottom, left, ...
Read more >View is automatically zoomed to extents in AutoCAD
From the UCS Manager, Settings tab, toggle the setting "Save UCS with viewport" (system variable: UCSVP).
Read more >camera zoom extents to fit - CGTalk - CGSociety
Hi.all I have search internet about camera zoom extents. but no good answer. so ... this just let object can in center of...
Read more >OpenLayers 4 - fit to extent of selected features - Stack Overflow
extent.extend(extent, feature.getGeometry().getExtent(); } map.getView().fit(extent ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just as a followup for anyone who comes across this, the fiddle above uses a 1 second timeout to hopefully wait for the layer features to be fully created on mount but that’s not always the case, and then you get an extents error from openlayers (https://openlayers.org/en/v5.3.0/doc/errors/#25). Instead I use a watcher on my coordinates variable, and also specifically test to make sure the extent is valid:
There are probably lots of ways to do this though.
Hi @fnoop , as for the first problem I have no idea why features are disappear. Can you provide test app that reproduces this behavior?
The second issue: not all methods of the openlayers are implemented in vuelayers components, but you can use original methods from ol object instance.
For
vl-source-*
components:Take a look for this fiddle https://jsfiddle.net/ghettovoice/br84dgq2/.