I've changed this piece of code from the demo to add a custom marker icon.
// 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: 'ylw-pushpin.png',
iconSize: [32, 37],
iconAnchor: [16, 37],
popupAnchor: [0, -28]
});
L.Control.FileLayerLoad.LABEL = '<i class="fa fa-folder-open"></i>'
L.Control.fileLayerLoad({
fitBounds: true,
layerOptions: {style: style,
pointToLayer: function (data, latlng) {
return L.marker(latlng, {icon: myIcon});
}},
}).addTo(map);This is my solution. Please let me know if this can be done better.
// 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) {
// setup popup, icons...
return L.marker(latlng, {icon: myIcon});
}
}
L.Control.fileLayerLoad({
layerOptions: geoJsonOptions,
}).addTo(map);