I have displayed vector tiles layers with "application/vnd.mapbox-vector-tile" format in Open Layers 3.While creating vector tile I have applied only image style. I want to display labels for existing vector tile layer when user click on button.

While creating vector tile layer I am able to display labels because we will get features so I can apply text style. But in my case when user wants see labels they click on button that time labels has to display.

How to achieve that?

  • Define two styles: one without labels and one with labels. For initial layer display use first style, upon button click apply second style to vector layer with setStyle method. – TomazicM May 29 '19 at 10:45
  • For vector layer we set but vector tile layer how to set it – veena hosur May 29 '19 at 10:53
  • If you are displaying labels your style is almost certainly a function. If your button sets a global displayLabels variable to true/false you could use that in the function to determine if text should be included. – Mike May 29 '19 at 10:53
  • I am not getting features from vector tile to add style – veena hosur May 29 '19 at 10:56
  • OpenLayers will almost certainly be using the layer style to style features, it doesn't make sense to set a style on individual features in vector tiles. – Mike May 29 '19 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.