You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am new in LeafletJs and this plugin is really helpful.
I am trying to display a Corridor in realTime. For that, I update the coordinates using setLatLng.
My code is working with Polylines and Polygons, but when I try to use setLatLng I have an error: L.corridor.setLatLngs is not a function
Looking at the source code of leaflet-corridor, I realized that there is no function existing for this feature.
It is possible to have an aproach of how to write it myself?
The text was updated successfully, but these errors were encountered:
For future readers, I could resolve this by moving and modifying the functions to the main js file, and calling directly to the polyline.setLatLngs atributte:
var lineRed = L.polyline([ [40.702222, -73.979378], [41.702222, -73.979378] ], { color: 'red' }).addTo(map); function updateWeight() { const buffer = 1 currentZoom = map.getZoom(); // getMetersPerPixel var centerLatLng = map.getCenter(); // get map center var pointC = map.latLngToContainerPoint(centerLatLng); // convert to containerpoint (pixels) var pointX = L.point(pointC.x + 10, pointC.y); // add 10 pixels to x // convert containerpoints to latlng's var latLngX = map.containerPointToLatLng(pointX); var resultado = centerLatLng.distanceTo(latLngX) / 10; // calculate distance between c and x (latitude) buffer_new = buffer * 2 / resultado return buffer_new } map.on('zoomend', function() { currentZoom = map.getZoom(); console.log('zoom:', currentZoom) if (currentZoom !== 0) { updateWeight() console.log('new buffer:', buffer_new) lineRed.setStyle({ 'weight': buffer_new }); } }); lineRed.setLatLngs(latlng)
Hello, I am new in LeafletJs and this plugin is really helpful.
I am trying to display a Corridor in realTime. For that, I update the coordinates using setLatLng.
My code is working with Polylines and Polygons, but when I try to use setLatLng I have an error:
L.corridor.setLatLngs is not a function
Looking at the source code of leaflet-corridor, I realized that there is no function existing for this feature.
It is possible to have an aproach of how to write it myself?
The text was updated successfully, but these errors were encountered: