I am trying to create a map with leaflet.js where I can switch between different tile layers. It works great with file servers that serve tiles with standard x, y, and z (oom) schemes. However, Microsoft Bing uses its own quadkey scheme. I found a JavaScript function to convert xyz to quad, but I don't know how to use it. Check out my example:
function toQuad(x, y, z) { var quadkey = ''; for ( var i = z; i >= 0; --i) { var bitmask = 1 << i; var digit = 0; if ((x & bitmask) !== 0) { digit |= 1;} if ((y & bitmask) !== 0) { digit |= 2;} quadkey += digit; } return quadkey; }; var openstreetmap = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}), arcgissat = L.tileLayer('http://{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {subdomains: ['server', 'services'], attribution: '© <a href="http://www.arcgis.com/">ArcGIS esri</a>'})
Basically, I just donβt know how to call a JavaScript function inside a variable declaration using the values ββ{x}, {y} and {z} that leafletjs provides.
user168080
source share