【问题标题】:Leaflet clustering with custom markers带有自定义标记的传单聚类
【发布时间】:2014-10-20 21:04:09
【问题描述】:

我只是从传单开始。我的问题是如何将自定义标记聚集到像这样添加到地图中的位置

var LeafIcon = L.Icon.extend({
options: {
    iconSize:     [38, 95],     
    shadowSize:   [50, 64], 
    iconAnchor:   [22, 94], 
    popupAnchor:  [-3, -10]
    }
});

var greenIcon = new LeafIcon({iconUrl: 'http://leafletjs.com/docs/images/leaf-green.png'}),
redIcon = new LeafIcon({iconUrl: 'http://leafletjs.com/docs/images/leaf-red.png'}),
orangeIcon = new LeafIcon({iconUrl: 'http://leafletjs.com/docs/images/leaf-orange.png'});


L.marker([51.5, -0.071], {icon: greenIcon}).bindPopup("<p>ok</p><p>tada</p>.").addTo(map);
L.marker([51.5, -0.073], {icon: redIcon}).bindPopup("I am a red leaf.").addTo(map);
L.marker([51.5, -0.076], {icon: orangeIcon}).bindPopup("I am an orange leaf.").addTo(map);

我正在努力将其添加到 MarkerClusterGroup。

请在这里找到一个工作小提琴:http://jsfiddle.net/6uovronb/

谢谢!

【问题讨论】:

    标签: leaflet markerclusterer


    【解决方案1】:

    我更新了您的 fiddle 并将您的标记添加到标记组。

    这里有一些示例代码:

    var markers = new L.MarkerClusterGroup();
        markers.addLayer(L.marker([51.5, -0.071], {
            icon: greenIcon
        }).bindPopup("<p>ok</p><p>tada</p>."));
    

    在一个稍微不相关的说明中,我从未使用过标记集群,但这是一个非常漂亮的传单插件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-01
      • 1970-01-01
      相关资源
      最近更新 更多