mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
js leafletRasterLayer: show console error if attempting to load a vector archive [#101]
This commit is contained in:
@@ -5,6 +5,7 @@ declare const document: any;
|
||||
import { PMTiles, Source, TileType } from "./index";
|
||||
|
||||
export const leafletRasterLayer = (source: PMTiles, options: any) => {
|
||||
let loaded = false;
|
||||
const cls = L.GridLayer.extend({
|
||||
createTile: function (coord: any, done: any) {
|
||||
const el: any = document.createElement("img");
|
||||
@@ -13,6 +14,16 @@ export const leafletRasterLayer = (source: PMTiles, options: any) => {
|
||||
el.cancel = () => {
|
||||
controller.abort();
|
||||
};
|
||||
if (!loaded) {
|
||||
source.getHeader().then((header) => {
|
||||
if (header.tileType == TileType.Mvt) {
|
||||
console.error(
|
||||
"Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details."
|
||||
);
|
||||
}
|
||||
});
|
||||
loaded = true;
|
||||
}
|
||||
source
|
||||
.getZxy(coord.z, coord.x, coord.y, signal)
|
||||
.then((arr) => {
|
||||
|
||||
Reference in New Issue
Block a user