var mapReady = true,
tilesReady = false;
leafletLayer.on('loading', function() {
tilesReady = false;
});
leafletMap.on('movestart', function() {
mapReady = false;
});
leafletLayer.on('load', function() {
tilesReady = true;
if (mapReady) {
this.leafletLayer.fire('tilesready');
}
}.bind(this));
leafletMap.on('moveend', function() {
mapReady = true;
if (tilesReady) {
this.leafletLayer.fire('tilesready');
}
}.bind(this));
function urlToTileCoords(url) {
var coordRegex = /.*\/(\d+)\/(\d+)\/(\d+)\.png$/;
var coords = coordRegex.exec(url);
return coords && {
z: coords[1],
x: coords[2],
y: coords[3]
};
}
}
TileDataSet.prototype.embedLeaflet = function() {
if (!this.model.div) {
console.log("ERR: Tried to embed leaflet map into a headless model, or before model div was initialized.");
return;
}
ABM.Util.insertLayer(this.model.div, this.leafletMap.getContainer(), this.model.world.pxWidth+"px", this.model.world.pxHeight+"px", 15);