D
D
Denissssss2018-08-13 13:44:36
Yandex maps
Denissssss, 2018-08-13 13:44:36

Yandex maps API: how to get polyline coordinates on mousemove?

The path (polyline) is displayed on the map, there are other data for each pair of coordinates (speed, etc.). How can you get which part of the path the mouse is hovering over, an index or something else that will allow you to correlate with other data.
I would like something by analogy with Autoscan + (demo / demo) - point on the map to the path and see the mark on the chart.
The variant with the search for the nearest point is not suitable (the waypoints can be close).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denissssss, 2018-08-15
@Denissssss

I did: I
take the mouse coordinates (ev.get('coords')) and look for the nearest UPD
point :

var mousePos = ev.get('coords');
var indexNearest =  ev.originalEvent.target.geometry.getClosest(mousePos).closestPointIndex;

ILineStringGeometryAccess

F
freeExec, 2018-08-13
@freeExec

It's simple, geometry class 6: along the track segment, build a buffer with the desired gap - like a rectangle, split it into two triangles and check if the mouse enters it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question