JSFiddle - React, Tailwind, and code Playground

by mbahl

HTML

<script src="https://npmcdn.com/@turf/[email protected]/turf.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css">
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://api.mapbox.com/mapbox.js/plugins/leaflet-geodesy/v0.1.0/leaflet-geodesy.js"></script>
<div id="map"></div>

CSS

#map {
  height: 500px;
}

JavaScript

var map = L.map("map").setView([2,14.0], 7);

L.tileLayer('https://stamen-tiles.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png', {
  attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

var poly1 = turf.polygon([[
  [-122.801742, 45.48565],
  [-122.801742, 45.60491],
  [-122.584762, 45.60491],
  [-122.584762, 45.48565],
  [-122.801742, 45.48565]
]]);

var poly2 = turf.polygon([[
  [-122.520217, 45.535693],
  [-122.64038, 45.553967],
  [-122.720031, 45.526554],
  [-122.669906, 45.507309],
  [-122.723464, 45.446643],
  [-122.532577, 45.408574],
  [-122.487258, 45.477466],
  [-122.520217, 45.535693]
]]);

var intersection = turf.intersect(poly1, poly2);
var polygon = turf.polygon([[[11, 0], [22, 4], [31, 0], [31, 11], [21, 15], [11, 11], [11, 0]]]);
var point = turf.point([61, 5]);

var tangents = turf.polygonTangents(point, polygon)
var line1 = //turf.lineString([[126, -11], [129, -21]]);
 turf.polygon([[[126, -11], [129, -21], [146, -23],[126, -11]]]);
var line2 = 
 turf.polygon([[[127, -10], [130, -20], [147, -22],[127, -10]]]);
//turf.lineString([[123, -18], [131, -14]]);
//var intersects = turf.lineIntersect(line1, line2);
//document.getElementById("output").innerHTML = JSON.stringify(intersects) ;
var test = turf.lineString([[12, 2.1], [14, 2.3],[17, 1.8]]);
var test2 = turf.lineString([[12, 2.3], [14, 2.1], [17, 2.3]]);

var testpoly2 = turf.polygon([[
  [12, 2.1],
  [14.2, 2.1],
  [14.2, 1.5],
  [12, 1.5],
  [12, 2.1],
]]);

var testpoly1 = turf.polygon([[
  [12.2, 2.3],
  [14.4, 2.3],
  [14.4, 1.7],
  [12.2, 1.7],
  [12.2, 2.3],
]]);

var station = turf.point([12.01, 2.1]);

var inter =  turf.lineIntersect(test, test2);
var interPoly =  turf.lineIntersect(testpoly1, testpoly2);
var intersection = turf.intersect(testpoly1, testpoly2);

var circ = turf.circle([12.2, 1.2], 120, {steps: 30});
var circStrike = turf.lineString([[10.2, 1.2],[12.2, .6], [14.2, 1.2]]);
var circLineInterSect =  turf.lineIntersect(circ,...