Click to download a map tile

1864
10
Jump to solution
08-19-2014 06:44 AM
MarkLewin
New Contributor III

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

0 Kudos
1 Solution

Accepted Solutions
JohnGrayson
Esri Regular Contributor

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:

Edit fiddle - JSFiddle

View solution in original post

0 Kudos
10 Replies
TimWitt2
MVP Alum

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

0 Kudos
MarkLewin
New Contributor III

Thanks Tim ... but would that help me identify individual map

tiles?

0 Kudos
TimWitt2
MVP Alum

I made this fiddle quickly. Here you can click on the map and it returns the tiles for you that you clicked on.

Edit fiddle - JSFiddle

In my example a popup appears.

0 Kudos
MarkLewin
New Contributor III

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

0 Kudos
TimWitt2
MVP Alum

Mark,

my bad, I missunderstood. Let me see if I can figure this out

Tim

0 Kudos
MarkLewin
New Contributor III

Thanks Tim - I really appreciate your help!

0 Kudos
TimWitt2
MVP Alum

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

0 Kudos
MarkLewin
New Contributor III

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

0 Kudos
JohnGrayson
Esri Regular Contributor

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:

Edit fiddle - JSFiddle

0 Kudos