I have been playing with polylinemeasure:change
and I see I can get the value of the total distance easily with currentLine.distance
.
But how can I get the value of each pathline distance and its bearing?
This is the furthest I went:
// Define some maps options
var mapOptions = {
center: [20.27, -157],
zoom: 7
};
//Create a map and assign it to the map div
var map = L.map("leafletMapid", mapOptions);
// Add a baselayer
var baselayer = L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png", {
attribution:
'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
baselayer.addTo(map);
// Create polylineMeasure
const pMeasure = L.control.polylineMeasure();
pMeasure.addTo(map);
map.on("polylinemeasure:change", (currentLine) => {
console.log(currentLine.distance);
});
You can see this example here: https://codesandbox.io/s/polylinemeasure-from-points-forked-xux7si?file=/src/index.js