作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我从 mapbox 中获取了这个演示:
https://docs.mapbox.com/mapbox-gl-js/example/hover-styles/
我用自己的 GeoJson 文件替换了演示文件,代码在这里:
https://codepen.io/hiven/pen/rNYdvdg?editors=1112
我得到的错误是:
Error: The feature id parameter must be provided.
我不明白这是什么意思,因为此片段中提供了功能 ID:
map.addLayer({
'id': 'state-borders',
'type': 'line',
'source': 'states',
'layout': {},
'paint': {
'line-color': '#627BC1',
'line-width': 2
}
});
最佳答案
您必须将 generateId: true
添加到您的 addSource
方法参数中。
map.addSource('states', {
'type': 'geojson',
'data': 'https://hiven.github.io/map2/hexagons.geojson',
'generateId': true //This ensures that all features have unique IDs
});
关于缺少 Mapbox 要素 ID 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71198235/
我从 mapbox 中获取了这个演示: https://docs.mapbox.com/mapbox-gl-js/example/hover-styles/ 我用自己的 GeoJson 文件替换了演示
链接:http://www1.qhoach.com/ 当您拖动时,这张 map 会被平移...但是如果您拖动 KML 要素(带圆圈的图标),则什么也不会发生 最佳答案 首先,在您的应用程序中有四个级别
我是一名优秀的程序员,十分优秀!