Skip to content
Advertisement

Openlayers 6 – Show Geojson Label on polygon

please i’m working on openlayers and i can’t use attribute value as label for my GeoJSON vector file.

I want to show the text from properties “osmid” in my GeoJSON file as label.

here is my code

JavaScript

My Geojson file looks like this :

JavaScript

Advertisement

Answer

You need to use a style function where you set the text in the style to the value of the feature property

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement