2014-10-20 6 views
0

방금 ​​전단지로 시작합니다. 내 질문에 내가 MarkerClusterGroup이 추가 고민이맞춤 마커가있는 전단지 클러스터링

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

미안 같이지도에 추가 된 사용자 정의 마커를 클러스터링 할 수있는 방법입니다.

여기에 작업 바이올린을 찾아주세요 : 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>.")); 

:

는 여기에 몇 가지 예제 코드입니다.