Reputation: 420
I search a method to find if my current location is on the path define by aPolyline.
In google maps a function exist isLocationOnEdge, but I cannot find a similar function in Here maps API.
Upvotes: 1
Views: 750
Reputation:
This could be achieved using an approach an below
//global variable
var polyline;
polyline = new H.map.Polyline(strip);
map.addObject(polyline);
function liesOnPolyline(coords){
// get objects at the coordinates (pixel coordinates, can be converted from lat, lon using map.geoToScreen )
var objects = map.getObjectsAt(coords.x, coords.y);
// iterate through the array to check if polyline can be retrieved here
var withinPolyline = false;
for (var object in objects) {
if(objects[object] === polyline){
withinPolyline = true;
break;
}
}
console.log("lies within Polyline"+withinPolyline );
}
Upvotes: 1