Closed wendellwt closed 2 years ago
Hello @wendellwt , this should help:
<vl-map ref="map">
<vl-layer-vector ref="pointsLayer"> ....</vl-layer-vector>
</vl-map>
<script>
export default {
methods: {
redrawPoints () {
// by direct ref
// vuelayers v0.11.x
this.$refs.pointsLayer.$layer.changed();
// vuelayers v0.12.x
this.$refs.pointsLayer.refresh(); // this.$refs.pointsLayer.$layer.changed(); should work too
// through map ref
this.$refs.map.getLayerById('pointsLayer').changed();
},
},
}
</script>
To get s layer instance by id you need to use getLayerById
method. getOverlayById
returns ol/Overlay
instances by id.
Perfect! That's just what I was looking for.
And thanks again for a terrific component!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Quick question: How do I get a vector layer to call its style on the components? I would think it would be something like:
this.$refs.my_map_ref.getOverlayById("my_vector_lyr_id").redraw(); // does not work
Any map movement or resize correctly causes it to be redrawn. I would like to force it without the move or resize.
As a result of other calculations, the styleFactory for items in that layer have changed some of the colors. However, without any map event, vuelayers doesn't "know" that the layer need to be redrawn. What command will force features to be redrawn (so the styleFactory will re-run?