StyleFunctions on vector layers? #431
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @Koli0842 , To apply it you can use <template>
<vl-layer-vector>
<vl-style-func : factory ="newStyleFunc"/>
</vl-layer-vector>
</template>
<script>
export default {
methods: {
newStyleFunc () {
// feature - instance of ol/Feature https://openlayers.org/en/v5.3.0/apidoc/module-ol_Feature-Feature.html
// resolution - float value of current view resolution
return (feature, resolution) => {
return ol/Style || Array<ol/Style> || null
},
},
},
}
</script> Style function is just a function that should return ol/Style, array of ol/Style or null (actually hides a feature) for the feature arg. It is called very often by OpenLayers render engine, so don't put here any heavy operations. Usually it is useful to build some complex or dynamic feature prop-based styling. Several examples in VueLayers:
Regarding use case: I'm not sure that is possible to build heatmap similar to vl-layer-heatmap with style function. |
Beta Was this translation helpful? Give feedback.
Hello @Koli0842 ,
yes, style functions is supported by any vector layer.
To apply it you can use
vl-style-func
componentStyle function is just a function that should return ol/Style, array of ol/Style or null (actually hides…