leaflet#Coords TypeScript Examples
The following examples show how to use
leaflet#Coords.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LiveAtlasTileLayer.ts From LiveAtlas with Apache License 2.0 | 6 votes |
// @method createTile(coords: Object, done?: Function): HTMLElement
// Called only internally, overrides GridLayer's [`createTile()`](#gridlayer-createtile)
// to return an `<img>` HTML element with the appropriate image URL given `coords`. The `done`
// callback is called when the tile has been loaded.
createTile(coords: Coords, done: DoneCallback) {
const tile = this.tileTemplate.cloneNode(false) as LiveAtlasTileElement;
this.loadQueue.push(tile);
tile.onload = () => {
URL.revokeObjectURL(tile.src); //Revoke the object URL as we don't need it anymore
this._tileOnLoad(done, tile);
this.loadingTiles.delete(tile);
this.tickLoadQueue();
};
tile.onerror = () => {
this._tileOnError(done, tile, LiveAtlasTileLayer.genericLoadError);
this.loadingTiles.delete(tile);
this.tickLoadQueue();
};
tile.url = this.getTileUrl(coords);
tile.callback = done;
this.tickLoadQueue();
return tile;
}
Example #2
Source File: OverviewerTileLayer.ts From LiveAtlas with Apache License 2.0 | 6 votes |
getTileUrl(coords: Coords): string {
let url = this.options.prefix;
const zoom = coords.z;
if(coords.x < 0 || coords.x >= Math.pow(2, zoom) ||
coords.y < 0 || coords.y >= Math.pow(2, zoom)) {
url += '/blank';
} else if(zoom === 0) {
url += '/base';
} else {
for(let z = zoom - 1; z >= 0; --z) {
const x = Math.floor(coords.x / Math.pow(2, z)) % 2;
const y = Math.floor(coords.y / Math.pow(2, z)) % 2;
url += '/' + (x + 2 * y);
}
}
url += `.${this.options.imageFormat}`;
// if(typeof overviewerConfig.map.cacheTag !== 'undefined') {
// url += '?c=' + overviewerConfig.map.cacheTag;
// }
return this.options.baseUrl + url;
}
Example #3
Source File: DynmapTileLayer.ts From LiveAtlas with Apache License 2.0 | 5 votes |
createTile(coords: Coords, done: DoneCallback) {
const tile = super.createTile(coords, done);
tile.tileName = this.getTileName(coords);
this._namedTiles.set(tile.tileName, tile);
return tile;
}