JSFiddle - React, Tailwind, and code Playground
by jeffersonswartz
HTML
<!DOCTYPE html>
<html>
<head>
<title>Leaflet.draw drawing and editing tools</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.draw.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.draw.js"></script>
</head>
<body>
<div id="map" style="width: 400px; height: 400px; border: 1px solid #ccc"></div>
<button id="changeColor">Rectangle -> Blue</button>
<script>
var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
map = new L.Map('map', {layers: [], center: new L.LatLng(51.509, -0.08), zoom: 14 });
var drawnItems = new L.FeatureGroup();
map.addLayer(drawnItems);
var polyLayers = [];
var polygon1 = L.polygon([
[51.509, -0.08],
[51.503, -0.06],
[51.51, -0.047]
]);
L.
polygon1.addTo(map);
polyLayers.push(polygon1)
// Add the layers to the drawnItems feature group
for(layer of polyLayers) {
//drawnItems.addLayer(layer);
}
</script>
</body>
</html>