2014-01-21 4 views

답변

0

popup.openOn(map) 대신 popup.addTo(map)을 사용하십시오.

또한 closeOnClickcloseButton으로 지정할 수 있습니다.

var popup = L.popup({closeButton : false, closeOnClick : false}) 
    .setLatLng([tweet.y, tweet.x]) // Or something 
    .setContent(html) 
    .addTo(map); 
+0

덕분에, 이것이 제가 찾고 있었던 것입니다. –

0

openPopup 메서드를 사용하여 프로그래밍 방식으로 마커 팝업을 열 수 있습니다. 다음은 live demo뿐만 아니라 약간의 자바 스크립트로이 작업을 수행하는 방법입니다.

var map = L.mapbox.map('map', 'examples.map-zr0njcqy'); 

// wait until the markers are loaded, so we know that `map.markerLayer.eachLayer` 
// will actually go over each marker 
map.markerLayer.on('ready', function(e) { 
    // when a user clicks the button run the `clickButton` function. 
    // Thanks to function hoisting in Javascript, we can define the function 
    // after we reference it here. 
    document.getElementById('open-popup').onclick = clickButton; 
}); 

function clickButton() { 
    map.markerLayer.eachLayer(function(marker) { 
     // you can replace this test for anything else, to choose the right 
     // marker on which to open a popup. by default, popups are exclusive 
     // so opening a new one will close all of the others. 
     marker.openPopup(); 
    }); 
} 
+0

감사합니다. 덕분에 –

관련 문제