console
<div id="mapid" style="width:100%; height: 100%;">
</div>
<script>
var mymap = L.map('mapid').setView([-2, 2], 5);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
maxZoom: 18,
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1
}).addTo(mymap);
var latlngs = [[-2, 2], [4, 2]];
var polyline = L.polyline(latlngs, {color: 'red'}).addTo(mymap);
L.polyline([[1, 1], [1, 2], [1, 3], [1, 4]], {color: 'green'}).addTo(mymap);
var line1 = turf.lineString(latlngs);
var line2 = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
var cross = turf.booleanCrosses(line1, line2);
console.log(cross)
<!-- 面和线 -->
var polygons = [[2, 1], [3, 2], [3, 3], [2, 4],[2, 1]]
L.polygon(polygons, {color: 'green'}).addTo(mymap);
cross = turf.booleanCrosses(line1, turf.polygon([polygons]));
console.log(cross)
<!-- 多面和线 -->
var polygons = [[[-2, 1], [-3, 2], [-3, 3], [-2, 4],[-2, 1]],[[-1.5, 1.5], [-2.5, 2], [-2.5, 2], [-1.5, 2],[-1.5, 1.5]]]
L.polygon(polygons, {color: 'green'}).addTo(mymap);
cross = turf.booleanCrosses(line1, turf.multiPolygon([polygons]));
console.log(cross)
</script>
html,body{
width: 100%;
height: 100%;
padding: 0px;
margin: 0px;
}