Skip to content

StyleFunctions on vector layers? #431

Answered by ghettovoice
Koli0842 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @Koli0842 ,
yes, style functions is supported by any vector layer.

To apply it you can use vl-style-func component

<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…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Koli0842
Comment options

Answer selected by Koli0842
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants