Hello,
In my Laravel 6/blade/jquery 3/leaflet / turf app
I need to 1)show set of markers and 2) to join them with polylines.
Next I need 3) when user click on map to define is it polyline area and if yes 4) show popup
action menu and with “Add item” option selected to 5) split points on edge of selected
polyline into 2 polylines and 1 more marker.
I make it as :
const points = [
{title:'title #1 ', lat:52.509, lng:-3.08},
{title:'title #2 ', lat:51.503, lng:-1.06},
{title:'title #3 ', lat:49.51, lng:-2.47}
];
var mymap = L.map('mapid').setView([51.505, -0.09], 7);
var popup = L.popup();
function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(mymap);
}
mymap.on('click', onMapClick);
drawPoints()
function drawPoints() {
points.forEach(point => {
const latlngs = L.marker([point.lat, point.lng]).addTo(mymap)
.bindPopup(point.title);//.openPopup();
// const ret= L.polyline(latlngs, { color: 'red' }).addTo(mymap)
// var polyline = new L.Polyline(latlngs, {
// weight: 10, // THIS WAY DOES NOT WORK TOO
// }).addTo(mymap);
var polyline = new L.Polyline(point.lat, point.lng, {
weight: 10,
}).addTo(mymap);
})
} // function drawPoints () {
As result I have set of markers, but not polylines between markers.
How to show polylines and please give hints how to make steps 3), 4), 5)must be done with which methods?
Thanks!