如何将自定义图块集添加为 mapbox.js 图层?
How can I add a custom tileset as a mapbox.js layer?
我正在使用 mapbox.js 在我的站点上显示具有不同图层的地图,但是我无法将我的自定义图块集加载为一个图层。尝试在 _setTileJSON() 中加载时失败
这是我的 js 代码:
var map = L.mapbox.map('map', null, { zoomControl: false });
var layer1 = L.mapbox.tileLayer('mapbox.outdoors');
layer1.setZIndex(1).addTo(map);
这个非常有用,但是当我使用我的自定义 tileset id 而不是 'mapbox.outdoors'
时,我收到错误 tile_layer.js:49 Uncaught TypeError: Cannot read property '1' of null
。有什么想法吗?
提前致谢。
克里斯蒂娜
您似乎正在尝试显示 vector tileset with mapbox.js. Mapbox.js supports raster tilesets。
要显示矢量瓦片集 - 使用 mapbox-gl-js instead. Here is a basic example: Custom style example
或者,您可以使用 Mapbox Studio Classic 或 Tilemill(不再积极开发)从您的数据生成栅格图块集并将生成的 .mbtiles
上传到 Mapbox 以供 [=20= 使用].
我正在使用 mapbox.js 在我的站点上显示具有不同图层的地图,但是我无法将我的自定义图块集加载为一个图层。尝试在 _setTileJSON() 中加载时失败
这是我的 js 代码:
var map = L.mapbox.map('map', null, { zoomControl: false });
var layer1 = L.mapbox.tileLayer('mapbox.outdoors');
layer1.setZIndex(1).addTo(map);
这个非常有用,但是当我使用我的自定义 tileset id 而不是 'mapbox.outdoors'
时,我收到错误 tile_layer.js:49 Uncaught TypeError: Cannot read property '1' of null
。有什么想法吗?
提前致谢。
克里斯蒂娜
您似乎正在尝试显示 vector tileset with mapbox.js. Mapbox.js supports raster tilesets。
要显示矢量瓦片集 - 使用 mapbox-gl-js instead. Here is a basic example: Custom style example
或者,您可以使用 Mapbox Studio Classic 或 Tilemill(不再积极开发)从您的数据生成栅格图块集并将生成的 .mbtiles
上传到 Mapbox 以供 [=20= 使用].