作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一张 Google map 。我正在使用 GeoJSON.js当用户鼠标悬停在一个区域上时显示多边形的库。然而,这会将光标从十字准线切换到手指指针。如何继续使用十字准线光标?
我在 mapOptions 中定义了十字光标:
draggableCursor: 'crosshair'
我是否需要将多边形的可点击属性设置为 false 为 a comment to this question implies ?如果是这样,我如何使用 GeoJSON.js 执行此操作?
JusticeMap.org -- Website that I'm working on and having the issue
最佳答案
经过一些尝试,我发现唯一的方法是从多边形中删除可点击选项。为此,找到 showFeature 函数并将此代码添加到末尾:
function modifyPolygon(polygon){
//TODO check if the parameter is really a polygon. maybe you can check an apposite flag to
//choose between different polygons
polygon.setOptions({clickable: false});
}
//Shows a feature - main function
function showFeature(geojson, clear, style){
[...]
modifyPolygon(currentFeature_or_Features);
}
因为您已经设置了 draggableCursor: 'crosshair'
光标也会在多边形上保持十字准线。我使用在 GitHub 上找到的代码对此进行了测试(使用 index.htm 和 GeoJSON.js)并且有效。
关于google-maps - 谷歌地图 - GeoJSON.js - 替换光标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22080806/
leaflet:一个开源并且对移动端友好的交互式地图 JavaScript 库 中文文档: https://leafletjs.cn/reference.html 官网(英文): ht
我是一名优秀的程序员,十分优秀!