JSFiddle - React, Tailwind, and code Playground

by Pavlos Tsagkis

HTML

<script src="https://openlayers.org/en/v4.2.0/build/ol.js"></script>
<link rel="stylesheet" href="https://openlayers.org/en/v4.2.0/css/ol.css">
<div id="map" class="map"></div>

JavaScript

var image = new ol.style.Circle({ 
        radius: 5,
        fill: null,
        stroke: new ol.style.Stroke({color: 'red', width: 1}) 
      });

      var styles = {
        'Point': new ol.style.Style({ 
          image: image
        }),
        'LineString': new ol.style.Style({
          stroke: new ol.style.Stroke({ 
            color: 'green',
            width: 1
          })
        }),
        'MultiLineString': new ol.style.Style({
          stroke: new ol.style.Stroke({
            color: 'green',
            width: 1
          })
        }),
        'MultiPoint': new ol.style.Style({
          image: image
        }),
        'MultiPolygon': new ol.style.Style({
          stroke: new ol.style.Stroke({
            color: 'yellow',
            width: 1
          }),
          fill: new ol.style.Fill({ 
            color: 'rgba(255, 255, 0, 0.1)'
          })
        }),
        'Polygon': new ol.style.Style({
          stroke: new ol.style.Stroke({
            color: 'blue',
            lineDash: [4],
            width: 3
          }),
          fill: new ol.style.Fill({
            color: 'rgba(0, 0, 255, 1)'
          })
        }),
        'GeometryCollection': new ol.style.Style({
          stroke: new ol.style.Stroke({
            color: 'magenta',
            width: 2
          }),
          fill: new ol.style.Fill({
            color: 'magenta'
          }),
          image: new ol.style.Circle({
            radius: 10,
            fill: null,
            stroke: new ol.style.Stroke({
              color: 'magenta'
            })
          })
        }),
        'Circle': new ol.style.Style({
          stroke: new ol.style.Stroke({
            color: 'red',
            width: 2
          }),
          fill: new ol.style.Fill({
            color: 'rgba(255,0,0,0.2)'
          })
        })
      }; 

      var styleFunction = function(feature) {
        return styles[feature.getGeometry().getType()];
      };

      var geojsonObject = {
      ...