I have a number of points plotted on my map using geoJSON. When you click a point, the map zooms to the point and pulls up some info in another div. When I put a popup on a mouseover event, my click function no longer works.
Here is my click function:
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]]);
}
Here is my mouseover function:
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();
}
}
And here I call them:
function onEachFeature(feature, layer) {
layer.on({
click: fillInfo,
mouseover: highlightFeature,
mouseout: resetHighlight
});
}
This gets the popup working fine on rollover, but the point no longer responds to the click event.