5
我在地圖上使用geoJSON繪製了多個點。當你點擊一個點時,地圖會放大到一點,並在另一個div中拉出一些信息。當我在mouseover事件上放置一個彈出窗口時,我的點擊功能不再起作用。在mouseover上彈出的單張消除點擊事件
這裏是我的點擊功能:
function fillInfo(e) {
var layer = e.target;
document.getElementById('infoBox').innerHTML = '<h2>' + layer.feature.properties.name + '</h2>' + '<h3>' + layer.feature.properties.address + '</h3></p>'
}
//Variable to set zoom level on click
var southLat = layer.feature.geometry.coordinates[0] + .022438;
var southLong = layer.feature.geometry.coordinates[1] - .003235;
var northLat = layer.feature.geometry.coordinates[0] - .022438;
var northLong = layer.feature.geometry.coordinates[1] + .003235;
map.fitBounds([[southLong, southLat], [northLong, northLat]]);
}
這裏是我的鼠標懸停功能:
function highlightFeature(e) {
var layer = e.target;
layer.bindPopup(layer.feature.properties.name)
.openPopup();
layer.setStyle({
weight: 5,
color: '#666',
dashArray: '',
fillOpacity: 0.7
});
if (!L.Browser.ie && !L.Browser.opera) {
layer.bringToFront();
}
}
在這裏,我打電話給他們:
function onEachFeature(feature, layer) {
layer.on({
click: fillInfo,
mouseover: highlightFeature,
mouseout: resetHighlight
});
}
這得到彈出罰款工作滾動,但該點不再響應點擊事件。
是的,那是它!太棒了,感謝您的幫助! – user1410712