javascript - 如何在 MarkerClusterGroup 中设置每个集群的选项
问题描述
我使用以下方式创建自己的 MarkerClusterGroup:
this.cluster = leaflet.markerClusterGroup({
zoomToBoundsOnClick: false,
showCoverageOnHover: false,
spiderfyDistanceMultiplier: 3,
spiderLegPolylineOptions: {
weight: 1.5,
color: "#1BA5D0",
lineCap: "butt",
dashArray: "10 10",
opacity: 0.5
}
});
如何为该组内的每个集群应用一些选项(就它实际上是leaflet.Marker而言)?特别是,我想设置riseOnHover: true
我发现有一些方法可以使用自定义窗格控制整个 MarkerClusterGroup 定位,但这不是我的情况
解决方案
最后,我想通了。选项可以在里面设置iconCreateFunction
:
this.cluster = leaflet.markerClusterGroup({
iconCreateFunction: cluster => {
cluster.options.riseOnHover = true;
}
});
推荐阅读
- typescript - 打字稿类型任意数量的通用字段
- reactjs - 如何修复 `...theme.mixins` 意外的 Token SyntaxError?
- testing - 使用 Jest 的 material-ui Dialog 组件测试问题
- angularjs - AngularJS ui-router 如何确定应用程序的根 url?
- javascript - 在任意深度更新 JS 对象
- c++ - ctypes,添加静态库时未定义的符号
- python-3.5 - python3.5.5 ImportError:没有名为request的模块
- c# - 部署后 Azure 功能不起作用
- mysql - 在颤振上向我的本地主机发出 HTTP 请求不起作用
- ios - PKPushRegistry.init() 后未调用 pushRegistry PKPushRegistry pushCredentials 委托方法