Created
December 13, 2012 13:38
-
-
Save stoolrossa/4276435 to your computer and use it in GitHub Desktop.
Example of S3TileMapServiceLayer class using the ArcGIS Javascript API, with a fixed definition of the map service details within the class definition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dojo.require("esri.map"); | |
dojo.require("esri.layers.tiled"); | |
dojo.require("dojo/string"); | |
var map; | |
function init() { | |
dojo.declare("S3TiledMapServiceLayer", esri.layers.TiledMapServiceLayer, { | |
constructor: function(externalS3TileCacheUrl) { | |
this._s3TileUrl = externalS3TileCacheUrl; | |
this.spatialReference = new esri.SpatialReference({ "wkid":4283 }); | |
this.initialExtent = (this.fullExtent = new esri.geometry.Extent(152.260192894019, -27.6147957518947, 153.686679767014, -26.9985153513847, this.spatialReference)); | |
this.tileInfo = new esri.layers.TileInfo({ | |
"rows" : 256, | |
"cols" : 256, | |
"dpi" : 96, | |
"format" : "PNG32", | |
"compressionQuality" : 0, | |
"origin" : { | |
"x" : -400, | |
"y" : 9006799.25474099 | |
}, | |
"spatialReference" : { | |
"wkid" : 4283 | |
}, | |
"lods" : [ | |
{"level" : 0, "resolution" : 4.75892201166056E-05, "scale" : 20000}, | |
{"level" : 1, "resolution" : 3.56919150874542E-05, "scale" : 15000}, | |
{"level" : 2, "resolution" : 2.37946100583028E-05, "scale" : 10000} | |
] | |
}); | |
this.loaded = true; | |
this.onLoad(this); | |
}, // constructor | |
getTileUrl: function(level, row, col) { | |
return this._s3TileUrl | |
+ "/L" + dojo.string.pad(level.toString(), 2, '0') | |
+ "/R" + dojo.string.pad(row.toString(16), 8, '0') | |
+ "/C" + dojo.string.pad(col.toString(16), 8, '0') | |
+ ".png"; | |
} // getTileUrl | |
}); | |
var initExtent = new esri.geometry.Extent({ "xmin": 152.260192894019, "ymin": -27.6147957518947, "xmax": 153.686679767014, "ymax": -26.9985153513847, "spatialReference": { "wkid": 4283} }); | |
map = new esri.Map("map",{extent:initExtent}); | |
var tiledLayer = new S3TiledMapServiceLayer("https://<S3_BUCKET>.s3.amazonaws.com/_alllayers"); | |
map.addLayer(tiledLayer); | |
dojo.connect(map, 'onLoad', function(theMap) { | |
//resize the map when the browser resizes | |
dojo.connect(window, 'resize', map,map.resize); | |
}); | |
} | |
dojo.addOnLoad(init); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment