贴个群号
WebGIS学习交流群461555818,欢迎大家。
源码
每一个图层添加的时候,都可以调用一下这个函数,id为图层添加时的图层id,监听地图的鼠标移入移出事件。preventDefault用来阻止其他默认事件,获取features ,如果有要素,就变为手指,移出时变回拖拽的手掌。
// 添加鼠标交互
addMouseReact (id) {
const self = this
this.map.on('mousemove', id, (e) => {
e.preventDefault()
const features = self.map.queryRenderedFeatures(e.point, {
layers: [id]
})
if (features.length > 0) {
self.map.getCanvas().style.cursor = 'pointer'
}
})
this.map.on('mouseleave', id, (e) => {
self.map.getCanvas().style.cursor = 'grab'
})
},


621

被折叠的 条评论
为什么被折叠?



