Hey, I'm looking to add a custom feature layer (weather layer).
I've got the documentation which basically saying to call the URL and get the relevant data:
"http://maps.customweather.com/cw_tiles/5-5imZ7MogxLQSd-NFMPy5aPfZAEBj3axcJeJeBh38PtBSPb_cgTv hRqEAQhlNSI/synoptic_temp/"+Tile2Quad(a.x,a.y,b)+".png";
However as you can see, i need to pass some arguments to the url, which are the extent basically.
This code example is for Google maps.
here is the Tile2Quad function:
function Tile2Quad(tx, ty, zl) {
var quad = "";
for (var i = zl; i > 0; i--) {
var mask = 1 << (i - 1);
var cell = 0;
if ((tx & mask) !=
0) {
cell++;
}
if ((ty & mask) != 0) {
cell += 2;
}
quad += cell;
}
return quad;
}
The question is, how can i convert this code to esri, get the Geometry, and add this weather layer to my application.
Thanks
Solved! Go to Solution.
I haven't tested this, but it seems to me you could use a WebTiledLayer and override the getTileURL function like so:
var layer = new WebTiledLayer({
id: "myLayerID",
visible: true,
urlTemplate: "http://maps.customweather.com/cw_tiles/5-5imZ7MogxLQSd-NFMPy5aPfZAEBj3axcJeJeBh38PtBSPb_cgTvhRqEAQhlNSI/synoptic_temp/{level}/{col}/{row}.png"
});
layer.getTileUrl = function(zl, ty, tx) {
var quad = "";
for (var i = zl; i > 0; i--) {
var mask = 1 << (i - 1);
var cell = 0;
if ((tx & mask) != 0) {
cell++;
}
if ((ty & mask) != 0) {
cell += 2;
}
quad += cell;
}
return "http://maps.customweather.com/cw_tiles/5-5imZ7MogxLQSd-NFMPy5aPfZAEBj3axcJeJeBh38PtBSPb_cgTvhRqEAQhlNSI/synoptic_temp/" + quad + ".png";
};
Note that the urlTemplate value in the constructor is bogus, but that's ok because it will never be used.
I haven't tested this, but it seems to me you could use a WebTiledLayer and override the getTileURL function like so:
var layer = new WebTiledLayer({
id: "myLayerID",
visible: true,
urlTemplate: "http://maps.customweather.com/cw_tiles/5-5imZ7MogxLQSd-NFMPy5aPfZAEBj3axcJeJeBh38PtBSPb_cgTvhRqEAQhlNSI/synoptic_temp/{level}/{col}/{row}.png"
});
layer.getTileUrl = function(zl, ty, tx) {
var quad = "";
for (var i = zl; i > 0; i--) {
var mask = 1 << (i - 1);
var cell = 0;
if ((tx & mask) != 0) {
cell++;
}
if ((ty & mask) != 0) {
cell += 2;
}
quad += cell;
}
return "http://maps.customweather.com/cw_tiles/5-5imZ7MogxLQSd-NFMPy5aPfZAEBj3axcJeJeBh38PtBSPb_cgTvhRqEAQhlNSI/synoptic_temp/" + quad + ".png";
};
Note that the urlTemplate value in the constructor is bogus, but that's ok because it will never be used.