[GIS] Check if lat/long point is within shape

arcgis-javascript-api

I'm a bit new to ESRI and GIS so forgive me if this is a simple question.

Looking at this example ESRI Javascript sample (source code is here) I see you can click on a shape (via a published shape file) and if the point upon which you click is within a shape an action fires.

Is it possible to send a lat/long via some mechanism and IF that lat/long is within the shape the same (or similar) action fires?

or

Can I see if a lat/long is contained within ANY polygon that is contained in a published shapefile.

If my understanding of the ESRI javascript API is correct the point that the mouse is clicked does translate to a lat/long location.

Best Answer

If both your polygon and point geometry objects are on the client side, you can use the Polygon.contains() method