I'm new to Mapbox and ran into the following problem:I'm loading marker positions from an external geojson and want to manipulate the looks of several markers filtered by an attribute like "title".My method seems to work for one kind but when I try to add more to the filter, changes are overwritten. At the end I want to use custom icon images for each of the markers but somehow I can't get it to work. It seems I got it wrong somewhere or my whole approach is coming from a wrong direction. Anyone can help?
var ma_marathon_3 = L.mapbox.featureLayer().loadURL('./data/marathon/marker3x.geojson');ma_marathon_3.on('ready', function(layer) { this.eachLayer(function(marker) { if (marker.toGeoJSON().properties.title === 'Verpflegung') { marker.setIcon(L.mapbox.marker.icon({ "marker-size": 'large', "marker-color": "#ff0000", "iconSize": [27, 27], "iconAnchor": [13, 27], "iconUrl": '' })); } if (marker.toGeoJSON().properties.title === 'Toiletten') { marker.setIcon(L.mapbox.marker.icon({ "marker-size": 'large', "marker-color": "#fff", "iconSize": [27, 27], "iconAnchor": [13, 27], "iconUrl": '' })); } else { marker.setIcon(L.mapbox.marker.icon({})); } marker.bindPopup(marker.toGeoJSON().properties.id + ', ' + marker.toGeoJSON().properties.title); });}).addTo(baseMap);
أكثر...
var ma_marathon_3 = L.mapbox.featureLayer().loadURL('./data/marathon/marker3x.geojson');ma_marathon_3.on('ready', function(layer) { this.eachLayer(function(marker) { if (marker.toGeoJSON().properties.title === 'Verpflegung') { marker.setIcon(L.mapbox.marker.icon({ "marker-size": 'large', "marker-color": "#ff0000", "iconSize": [27, 27], "iconAnchor": [13, 27], "iconUrl": '' })); } if (marker.toGeoJSON().properties.title === 'Toiletten') { marker.setIcon(L.mapbox.marker.icon({ "marker-size": 'large', "marker-color": "#fff", "iconSize": [27, 27], "iconAnchor": [13, 27], "iconUrl": '' })); } else { marker.setIcon(L.mapbox.marker.icon({})); } marker.bindPopup(marker.toGeoJSON().properties.id + ', ' + marker.toGeoJSON().properties.title); });}).addTo(baseMap);
أكثر...