I have exported a QGIS map to Leaflet using the qgis2leaf plugin. I am looking for some assistance as to how to highlight features (polylines) when the mouse hovers over it. I just want the polyline to stand out (become bold); i only want popups to appear when the feature is clicked (which I have already customized).
I have seen plenty of examples such as the Leaflet Cloropleth tutorial but I have two geojson files in my map that users can click between (so i'm guessing that any 'highlighting' code would need to be entered twice.
The two geojson files are exp_AllRoutesAM and exp_AllRoutesPM. Here is the leaflet code that shows how the exp_AllRoutesPM file is handled.
function pop_AllRoutesPM(feature, layer) {
var popupContent = '<b>Survey: ' + feature.properties.Survey + '</b>' + '<br/>' + 'Section: ' + feature.properties.Section + '<br/>' + 'Speed In 2013: ' + feature.properties.OUT_2013 + ' km/h' +'<br/>' + 'Speed In 2012: ' + feature.properties.OUT_2012 + ' km/h' +'<br/>' + 'Speed In 2011: ' + feature.properties.OUT_2011 + ' km/h' + '<br/>' + 'Speed In 2010: ' + feature.properties.OUT_2010 + ' km/h' + '<br/>' + 'Speed In 2009: ' + feature.properties.OUT_2009 + ' km/h' ;
layer.bindPopup(popupContent);
}
var exp_AllRoutesPMJSON = new L.geoJson(exp_AllRoutesPM,{
onEachFeature: pop_AllRoutesPM,
style: function (feature) {
return {weight: feature.properties.radius_qgis2leaf,
color: feature.properties.color_qgis2leaf,
opacity: feature.properties.transp_qgis2leaf,
fillOpacity: feature.properties.transp_fill_qgis2leaf};
}
});
feature_group.addLayer(exp_AllRoutesPMJSON);
//add comment sign to hide this layer on the map in the initial view.
exp_AllRoutesPMJSON.addTo(map);