当前位置:   article > 正文

leaflet使用markercluster实现聚合_markerclustergroup

markerclustergroup

1、安装插件

npm install leaflet.markercluster

2、引入插件

  1. // 引入 leaflet.markercluster
  2. import "leaflet.markercluster/dist/MarkerCluster.css"
  3. import "leaflet.markercluster/dist/MarkerCluster.Default.css"
  4. import "leaflet.markercluster";

3、实例化markercluster

markerClusterGroup = L.markerClusterGroup()

4、添加点到markerClusterGroup

markerClusterGroup.addLayer(marker)

5、将markerClusterGroup添加到地图中

map.addLayer(markerClusterGroup)

6、设置聚合圈的颜色

  1. .marker-cluster-large div {
  2. background-color: rgba(254, 179, 0, 0.7) !important;
  3. color: #fff;
  4. }
  5. .marker-cluster-medium div {
  6. background-color: rgba(0, 167, 254, 0.7) !important;
  7. color: #fff;
  8. }
  9. .marker-cluster-small div {
  10. background-color: rgba(4, 241, 205, 0.7) !important;
  11. color: #fff;
  12. }
  13. .marker-cluster-small {
  14. background-color: rgba(4, 241, 205, 0.3);
  15. }
  16. .marker-cluster-medium {
  17. background-color: rgba(0, 167, 254, 0.3);
  18. }
  19. .marker-cluster-large {
  20. background-color: rgba(254, 179, 0, 0.3);
  21. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/234881
推荐阅读
相关标签
  

闽ICP备14008679号