【问题标题】:Mapbox-gl-js gives typeerror: 't' is undefined with tilesMapbox-gl-js 给出 typeerror: 't' is undefined with tiles
【发布时间】:2018-01-31 19:11:20
【问题描述】:

问题链接:https://khuts.org/webmap/osm-bright-style/mines.html mapbox-street 图层和瓦片图层均未显示。 该地图有一个使用 tileserver-php 提供的 mbtiles 文件。该错误指的是 tile-coord.js,其中似乎没有任何属性“t”。

我该如何解决这个问题?

【问题讨论】:

  • 你能扩展你的问题吗?您如何创建导致问题的图层?
  • 相关代码为 map.on('style.load', function() { map.addSource("operating", { "type": "vector", "data": "@987654322 @" }); map.addLayer({ "id": "operating", "type": "circle", "source": "operating", "paint": { "circle-radius": 10, "circle-颜色": "#ccc" } });

标签: mapbox-gl-js mbtiles


【解决方案1】:

在这里看到您的comment,您需要更改创建数据源的方式。 vector 源不接受 data 选项,您需要提供 tiles(磁贴 url 数组)或 url(指向 TileJSON 文件的 url):

map.addSource('my-source', {
  type: 'vector',
  // either "tiles"
  tiles: ['http://my-tile-server/{z}/{x}/{y}'],
  // or "url"
  url: 'http://my-tile-server/tiles.json'
});

如果您使用的是tileserver-php,它同时支持: - 平铺网址(z/x/y) - 平铺 jsons

请参阅其“支持的协议”文档:https://github.com/klokantech/tileserver-php#supported-protocols

【讨论】:

  • 不幸的是,我无法在托管的共享服务器上安装 node / npm,这就是选择 tileserver-php 的原因。我将不得不从档案中提取瓷砖并以这种方式提供它们。感谢您的回复。
  • 我更新了我的答案。 tileserver-php 还公开了 tile url 和 tile.json。
猜你喜欢
  • 1970-01-01
  • 2018-05-17
  • 1970-01-01
  • 2020-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多