Hi,
I'm building an application where users can click on the map to download a map tile. I can see that the ArcGISTiledMapServiceLayer has a getTileUrl() method, but has anyone got any idea about how I can identify a particular tile beneath a user's map click?
The Silverlight API has a TileLoading event, but I can't find anything similar in the ArcGIS Server API for JavaScript. My idea was to attach a click event handler to each tile as it loads, and then use getTileUrl(coords) to locate the required tile.
What would also be great to do is add a feature layer graticule to identify the individual tiles, but I can't figure out a good way to do this.
I would really appreciate any suggestions.
Thanks,
Mark
Solved! Go to Solution.
Mark, I could be wrong, but I believe the issue you'll find with this use case is that the dom nodes used for the tiled service are below all graphics layers, so normal events will not be raised for them. One possible solution is to compare the 'map click location' with the coordinates of all the dom nodes of the tiled layer. Probably not the most elegant of solutions, but it seems to work:
Mark,
you could use the identify task identifytask-amd | API Reference | ArcGIS API for JavaScript
Here is an example: Display identify results in popup | ArcGIS API for JavaScript
Hope this helps!
Tim
Thanks Tim ... but would that help me identify individual map
tiles?
I made this fiddle quickly. Here you can click on the map and it returns the tiles for you that you clicked on.
In my example a popup appears.
Thanks Tim, I really appreciate your efforts, but does this
tell me how to access the map tile? I apologize if I'm missing
something.
Basically, I want to be able to click on a tile and see the
individual tile URL.
Mark
Mark,
my bad, I missunderstood. Let me see if I can figure this out
Tim
Thanks Tim - I really appreciate your help!
Mark,
just to understand, this would be an example link that you would like to retrieve?
http://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/0/0/0
Tim
Hi Tim,
Yes! That's just it!
Ideally I'd like to be able to retrieve any features within the
tile space too, but let's start with that.
If there was an event that got fired when a tile loads, I could
use that to hook up a click event handler, but I can't seem to
find any such event, so I'm at a loss.
Thank you.
Mark
Mark, I could be wrong, but I believe the issue you'll find with this use case is that the dom nodes used for the tiled service are below all graphics layers, so normal events will not be raised for them. One possible solution is to compare the 'map click location' with the coordinates of all the dom nodes of the tiled layer. Probably not the most elegant of solutions, but it seems to work: