2014-10-20 110 views
0

我剛從傳單開始。我的問題是我怎麼能聚集哪些地方添加到地圖中這樣傳單與自定義標記集羣

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); 

I'm努力增加這一個MarkerClusterGroup自定義標記。

請在這裏找到工作小提琴:http://jsfiddle.net/6uovronb/

的感謝!

回答

0

我更新了您的fiddle並將您的標記添加到標記組。

下面是一些示例代碼:

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

在一個稍微不相關的說明,我從來沒有使用標記集羣但是這是一個非常漂亮的小冊子插件。