Vector tiles with polygon from GeoJSON in OpenLayers

This tutorial shows how to add a polygon feature from external GeoJSON to your vector tiles map. If you don’t know how to display vector tiles map follow this tutorial Vector tiles in OpenLayers.

Add GeoJSON layer to vector map

Insert the following GeoJSON vector layer definition snippet below the line of olms.apply(map, styleJson); and don’t forget to set z-index because otherwise your geojson layer might be hidden below some layers of basemap.

Summary

To properly add GeoJSON to OpenLayers map you need to create a new vector layer and give z-index to this layer.

Related examples