Select to view content in your preferred language

Adding 3rd party Weather Layer

622
1
Jump to solution
07-25-2022 01:22 AM
orahlagi
Occasional Contributor

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

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

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.

View solution in original post

1 Reply
JoelBennett
MVP Regular Contributor

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.