Select to view content in your preferred language

identify if Point within Polygon

2162
2
Jump to solution
01-14-2020 12:41 AM
Kae_WoeiKang
Emerging Contributor

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
Emerging Contributor

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

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