javascript - Check existence of point on leaflet route -


is there method on leaflet routing machine checks if specific point, e.g (lat,lng), inside routing polyline ?

there not, it's still doable using leaflet.geometryutil

take @ belongssegment function:

belongssegment(latlng, latlnga, latlngb, toleranceopt, nullable) → {boolean}  returns true if latlng belongs segment a-b 

so when route selected in routing machine, checking every segment of polyline if point belongs given tolerance:

var point = {your specific point}; ... map.on('routeselected', function(e) {     var route = e.route;     ispointonline(point, route.coordinates)); }) 

where ispointonline is

function ispointonline(point, path) {     (var = 0; < path.length - 1; i++) {         if (l.geometryutil.belongssegment(point, path[i], path[i + 1])) {             return true;         }     }     return false; } 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -