I'm using mapbox and loading multiple geojson layers on to the map, like so:
...
var aLayer = L.mapbox.featureLayer('/a.geojson');
var bLayer = L.mapbox.featureLayer('/b.geojson');
var cLayer = L.mapbox.featureLayer('/c.geojson');
var layers = {
LayerA: aLayer,
LayerB: bLayer,
LayerC: cLayer
}
...
layers.LayerA.addTo(map).on('ready', function(e) {
map.fitBounds(LayerA.getBounds(), {animate: true});
});
L.control.layers(layers).addTo(map);
Each geojson feature contains a number of properties; the title and description display correctly within the tooltips, for instance.
Where I'm having trouble is accessing these properties with other interactions. I'm adjusting the style of each polygon on hover, like so:
LayerA.on('mouseover', function(e)
{
e.layer.setStyle({
weight: 2,
fillOpacity: 0.7
});
if (!L.Browser.ie && !L.Browser.opera) {
e.layer.bringToFront();
}
});
LayerA.on('mouseout', function(e)
{
e.layer.setStyle({
weight: 0.5,
fillOpacity: 0.5
});
});
Any attempt to access the properties within the interactions, via e.layer
or e.target
, fails. I assume the tooltip working means they are available, but can't work out where I've gone wrong...?