Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
1  
What are you trying to do? Checking if a Point is within a Polygon is one of the most basic things in GIS. But Unless we know exactly what you are trying to achieve or solve, it will be very difficult to answer this question. –  Devdatta Tengshe Nov 23 '12 at 3:13
    
I want to know if it can be determined if a given lat/long point is within a polygon using ESRI's javascript API and if so, how? –  ngramsky Nov 23 '12 at 3:29
    
Maybe this example can help you a bit more: gis.stackexchange.com/questions/40502/… –  iamgin Nov 24 '12 at 9:29
add comment

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
    
So that will tell me if A polygon contains that corresponding lat/long point, but how would I find ANY polygon (within the shape file) that contains that lat/long point? Is the only solution to loop through all know polygons? –  ngramsky Nov 23 '12 at 19:02
    
That is why I had asked you what you want to do. If you have a mapserverice, and want to find out which polygon, the point is in, then you would have to use either a query task or an identify task. Please clarify exactly what you want to do. –  Devdatta Tengshe Nov 24 '12 at 5:03
    
Given a shapefile containing many polygons I would like to know if it is possible to see if one lat/long point is contained in ANY of the polygons contained in said shapefile. I'm rather new to ERSI but I believe I would like to make such a query using their webservices. Thus, can I, with on call, see if a lat/long is contained in ANY polygon within that published shapefile? If not, what are my options, if any? –  ngramsky Nov 24 '12 at 5:13
    
@ngramsky You need to run a query task. –  Devdatta Tengshe Nov 24 '12 at 5:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.