identify if Point within Polygon

1845
2
Jump to solution
01-14-2020 12:41 AM
Kae_WoeiKang
New Contributor II

I have a Point which obtained through a long press MotionEvent.

Point mapPoint = mMapView.screenToLocation(new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())));

However, I need to verify if the point is lying within the polygon. I can't find any API in Geometry which allows me to check if the point is located inside the polygon. 

Any idea?

0 Kudos
1 Solution

Accepted Solutions
ShellyGill1
Esri Contributor

Hi Kae,

The GeometryEngine class has lots of geometry-on-geometry spatial operations - you can try the GeometryEngine.contains static method - GeometryEngine (ArcGIS Runtime SDK for Android 100.7.0) . There's a sample that demonstrates this method, along with a lot of other spatial relationships like intersects, within, etc - Spatial Relationships | ArcGIS for Developers .

Hope this helps,

Shelly

View solution in original post

2 Replies
ShellyGill1
Esri Contributor

Hi Kae,

The GeometryEngine class has lots of geometry-on-geometry spatial operations - you can try the GeometryEngine.contains static method - GeometryEngine (ArcGIS Runtime SDK for Android 100.7.0) . There's a sample that demonstrates this method, along with a lot of other spatial relationships like intersects, within, etc - Spatial Relationships | ArcGIS for Developers .

Hope this helps,

Shelly

Kae_WoeiKang
New Contributor II

Yes, Thanks! I just found the functions which works like magic.

boolean isContain = GeometryEngine.contains(p, ltLn);