Select to view content in your preferred language

IdentifyGraphicsOverlayAsync: how to get polyline MapPoint tapped?

104
3
Monday
Jube
by
New Contributor

Is there any way to get the precise MapPoint tapped on a polyline in ScenView?

With SceneView.GeoViewTapped I get a GeoViewInputEventArgs with a Location property but it only represents a MapPoint on the surface, not the MapPoint on the polyline graphic I tapped (and is null if I tap the polyline from below, toward the sky).

Using IdentifyGraphicsOverlayAsync() and IdentifyGraphicsOverlayResult I get the polyline but there is nothing to get the precise MapPoint tapped, such as its index or distance from the beginning of the polyline.

Thanks for your help.

0 Kudos
3 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

You can call GeometryEngine method NearestVertex to get part and point indexes. Parameters will be polyline from IdentifyGraphicsOverlayResult and tapping MapPoint

0 Kudos
Jube
by
New Contributor

Thanks for you help.

Unfortunatly, it may lead to incorrect position due to the altitude of the polyline while the tapped point is on the ground (see attached picture).

Also, the Location is null when the polyline is tapped from below toward the sky (see 2nd attached picture).

Thanks,
Julien

0 Kudos
dotMorten_esri
Esri Notable Contributor

There is no location where you tapped on the line. The identify is done with some pixel tolerance and finds any geometry intersecting within that distance visually. Since a line is infinitely thin, you most likely didn't actually click the line but right next to it. The identify operation is all done in the rendered pixel space, so the calculation for where they intersect isn't ever made.
The best you get is to nearest vertex like @GKmieliauskas points out. I get that gets tricky in 3D since you're really talking about the nearest point between the polyline and the ray from the camera to the location on the surface. There's no out-of-the box way to calculate this position, so you might be in for doing a little bit of 3D trigonometry between those two line segments.