Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Leaflet — get all tile URLs given geographic bounds, tile layer and zoom
function getTileUrls(bounds, tileLayer, zoom) {
var min = map.project(bounds.getNorthWest(), zoom).divideBy(256).floor(),
max = map.project(bounds.getSouthEast(), zoom).divideBy(256).floor(),
urls = [];
for (var i = min.x; i <= max.x; i++) {
for (var j = min.y; j <= max.y; j++) {
var coords = new L.Point(i, j);
coords.z = zoom;
urls.push(tileLayer.getTileUrl(coords));
}
}
return urls;
}
@fgrs

This comment has been minimized.

Copy link

commented Nov 13, 2014

what gets passed in as a second parameter tileLayer?

@johndpope

This comment has been minimized.

Copy link

commented Dec 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.