How to calculate tile X and Y for a weather tile
This section provides an example of a request to calculate the weather tile X and Y. Example
Request
You can use the calculated xTile and yTile as parameters in the weather API URL format:
https://weather.hereapi.com/v3/tile/{zoom}/{x}/{y}/{imageType}The weather layer may not be available in all areas, so check the documentation for any restrictions.
To calculate the x and y tile coordinates, you can use the following code snippet:
// Code to calculate tile coordinates
var lat = 53.647; // Latitude
var lon = 9.977; // Longitude
var z = 16; // Zoom level
var latRad, n, xTile, yTile;
latRad = lat * Math.PI / 180;
n = Math.pow(2, z);
xTile = n * ((lon + 180) / 360);
yTile = n * (1 - (Math.log(Math.tan(latRad) + 1 / Math.cos(latRad)) / Math.PI)) / 2;
console.log(xTile);
console.log(yTile);Response - HTTP 200
Updated 6 days ago