var osm = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © 2013 OpenStreetMap contributors',
});
var map = L.map('map')
.fitWorld()
.addLayer(osm);
// line style
var style = {color:'red', fillColor: "#ff7800", opacity: 1.0, fillOpacity: 0.8, weight: 2, clickable: false};
// icon style
var myIcon = L.icon({
iconUrl: 'map_pin_yellow.png',
iconSize: [22, 31],
iconAnchor: [9, 30],
popupAnchor: [0, -28]
});
L.Control.FileLayerLoad.LABEL = '<i class="fa fa-folder-open"></i>';
var geoJsonOptions = {
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.description);},
style: style,
pointToLayer: function (data, latlng) {
return L.marker(latlng, {icon: myIcon, title: 'Click icon'});
}
}
L.Control.fileLayerLoad({
layerOptions: geoJsonOptions,
}).addTo(map);
var Icon_SiteB = L.icon({
iconUrl: 'https://dl.dropboxusercontent.com/u/209723935/Bibliotheken/images/SiteB.png',
iconSize: [30,35],
iconAnchor: [15,34]
})
L.easyButton('fa-map-marker', function(){marker.setIcon(Icon_SiteB);},'Change Icon')I don't see any reference to your markers, so try pushing them in an array when creating them.
And then iterate the array when pushing your button and "setIcon" on each marker.How many markers do you have to change? I think when there are to much it could be slow.
var markers = [];
var geoJsonOptions = {
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.description);},
style: style,
pointToLayer: function (data, latlng) {
var marker = L.marker(latlng, {icon: myIcon, title: 'Click icon'};
markers.push(marker);
return marker;
}
}
L.Control.fileLayerLoad({
layerOptions: geoJsonOptions,
}).addTo(map);
var Icon_SiteB = L.icon({
iconUrl: 'https://dl.dropboxusercontent.com/u/209723935/Bibliotheken/images/SiteB.png',
iconSize: [30,35],
iconAnchor: [15,34]
})
L.easyButton('fa-map-marker', function(){
for(var i = 0;i<markers.length;i++){
markers[i]setIcon(Icon_SiteB);
}
},'Change Icon')
L.easyButton('fa-map-marker', function(){
for(var i = 0;i<markers.length;i++){
markers[i].setIcon(Icon_SiteB);
}
},'Change Icon')