Select to view content in your preferred language

How does the mapView determines which graphic is selected to display callout?

2370
7
01-03-2012 07:58 PM
AnoopMohandas
Emerging Contributor
How does the mapView determines which graphic is selected when the graphics added intersects each other?
Is there a way to override this selection.

Till SDK 2.0.1 the callout of topmost graphic was shown. But with SDK 2.1 callout for underneath graphic is being shown.
I need to revert back to the earlier behavior. 

Any help would be appreciated
0 Kudos
7 Replies
PaulLohr
Frequent Contributor
Not sure how to do what you are asking. What about putting the AGSGraphics into their AGSGraphicsLayer in reverse order? Of course this could be a problem if the AGSGraphics are the result of a query.
0 Kudos
AnoopMohandas
Emerging Contributor
Thanks Paul,
The graphics are not added as a result of query. They are added one by one.

Somehow the graphic with point geometry is overwhelmed by the underlying graphic with polygon geometry. I have two versions of application for 2.0 & 2.1 SDK  and the former is working fine.
0 Kudos
PaulLohr
Frequent Contributor
So you have:
-an AGSGraphicsLayer with points
and
-an AGSGraphicsLayer with polygons
correct?

If this is the case, does the order in which the layers are added to the AGSMapView affect which layer responds to a tap when a polygon intersects a point?

Maybe I am suggesting things that you have already tried.

Paul Lohr
0 Kudos
AnoopMohandas
Emerging Contributor
App has a single graphics Layer maintained as the top most layer if sketch layer is not added.
I found that the graphics are added in the correct order, even then the callout being shown is wrong.

Anyone with insight of the internal logic for selection of graphics, please share the info


Regards,
Anoop
0 Kudos
NimeshJarecha
Esri Regular Contributor
If there are multiple graphics at tap location then it finds the closest (distance) one and shows the callout. Earlier (before v2.1) it used to show the callout for the first graphic from the graphics found at tap location.

Hope this helps!

Regards,
Nimesh
0 Kudos
AnoopMohandas
Emerging Contributor
Thank you Nimesh.

Can you mention the significance of this change? And also where can I override the selection of graphic?

The closest one seemed to be implementing mapView:didClickAtPoint:mapPoint:graphics method of AGSMapViewTouchDelegate. Process the touch event, find out the which graphics should be shown. And show the callout by showCalloutAtPoint:forGraphic:animated method.


Regards,
Anoop
0 Kudos
NimeshJarecha
Esri Regular Contributor
When there are multiple graphics found at tap location then showing callout at first graphic is not correct. Logically it has to be the closest from the tap location. This is the significance of the change. You are on a right track as far as how to show callout on desired graphic.

Regards,
Nimesh
0 Kudos