Leaflet Map Clustering + Marker Rotation

时间:2013-05-08 14:36:45

标签: leaflet

有没有人试过使用Leaflet Clustering Plugin + Marker Rotation Plugin?我试图与两者合作,但他们部分工作。

在第一个视图中,我可以看到一些聚类和一些孤立(和旋转)的标记。每次放大某些群集时,旋转的标记都会消失。有谁知道为什么会这样?

2 个答案:

答案 0 :(得分:1)

只需旋转标记,请使用:This Leaflet Plugin

在你的html中包含这个:

<script src="../leaflet-plugin/Marker.Rotate.js"></script>

创建一个标记:

var marker = new L.Marker(map.getCenter(), {iconAngle: 90});

a complete example

答案 1 :(得分:0)

找到Dave Leaver提供的解决方案..它完美无缺。

“如果没有_icon,你可以通过将旋转插件中的更新功能的开头更改为保释来破解它与L.MarkerClusterGroup一起使用(因此它并不比它已经糟糕):

update: function() {
    if (!this._icon) {
        return;
    }

问题是旋转插件正在覆盖变换并与其上的传单作斗争。 我建议使用带有旋转的子元素的DivIcon,这样传单可以愉快地更新变换以独立于旋转移动标记。

作为一个完全破碎的例子:

 var m = new L.Marker(getRandomLatLng(map), { icon: L.divIcon({html:'<img src="http://cdn.leafletjs.com/leaflet-0.5.1/images/marker-icon.png" style="-webkit-transform: rotate(39deg); -moz-transform:rotate(39deg);" />'})});"