JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MapBox Demo</title>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.0/mapbox-gl.js'></script>
<script src='https://npmcdn.com/@turf/turf/turf.min.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.0/mapbox-gl.css' rel='stylesheet' />
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.0.0/mapbox-gl-draw.css' type='text/css'/>
</head>
<body>
<div id='map' style="height: 600px"></div>
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.0.0/mapbox-gl-draw.js'></script>
<script>
mapboxgl.accessToken = "pk.eyJ1Ijoic2FxdWVpYiIsImEiOiJjamRiNzVuZ2EwMXFyMzNzNHY0ZDdmYmV2In0.3GWbkrNjeun4geOyJS-PIw";
/* eslint-disable */
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/mapbox/streets-v9', // stylesheet location
center: [55.2324,25.073], // starting position
zoom: 12 // starting zoom
});
// Draw map
var draw = new MapboxDraw({
displayControlsDefault: false,
controls: {
polygon: false,
trash: false
}
});
map.addControl(draw);
// Add zoom and rotation controls to the map.
map.addControl(new mapboxgl.NavigationControl());
var featureCollection = {
"type": "FeatureCollection",
"features": [
{
"type":"Feature",
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
53.34234777435083,
24.03841558494339
],
[
53.63384239941877,
23.980642073807147
],
[
...