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.

How do I get the index of a clicked point from a tile in WMTS layer? I also want the tile row and column number corresponding to the clicked location. So I tried to set the extent of my WMTS layer to the clicked point. My code was something like this

dojo.declare("ogc.WMTSLayer", esri.layers.TiledMapServiceLayer, { 
constructor: function() { 
this.spatialReference = new esri.SpatialReference({ 
wkid: 3857 
}); 

this.initialExtent = new esri.geometry.Extent(point.x, point.y,- point.x,- point.y, this.spatialReference); 
this.fullExtent = new esri.geometry.Extent(point.x, point.y, - point.x, - point.y, this.spatialReference); 

this.tileInfo = new esri.layers.TileInfo({ 
"dpi": "90.71428571427429", 
"format": "image/png", 
"compressionQuality": 0, 
"spatialReference": { 
"wkid": "3857" 
}, 
"rows": 256, 
"cols": 256, 
"origin": { 
"x": -20037508.342789, 
"y": 20037508.342789
}, 
"lods": [{ 
.............
.............

} 
] 
}); 
this.loaded = true; 
this.onLoad(this); 
}, 

getTileUrl: function(level, row, col) { 

return "http://wmts.sample.com/public/wmts" + "? SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile" +  "&LAYER=test" + "&STYLE=_null" + "&FORMAT=image/png" + "&TILEMATRIXSET=3857" + "&TILEMATRIX=" + level + "&TILEROW=" + row + "&TILECOL=" + col + "&Threshold = 200"; 
} 
}); 

In this case I am able to get the row and column of the tile corresponding to my clicked point. But the extent of my rendered tile has my clicked point coordinates as I had used them to create my WMTS layer. So I am unable to use the WMTS tile extent co-ordinates to find my pixel coordinates mathematically. I would appreciate any suggestions as to how to work on this. Should I use the scale and resolution of the loaded tile in any way?

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.