mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-30 03:54:10 +01:00
Add icon support.
This commit is contained in:
@@ -3,6 +3,8 @@ L.Contao = L.Class.extend( {
|
||||
|
||||
maps: {},
|
||||
|
||||
icons: {},
|
||||
|
||||
addMap: function (id, map) {
|
||||
this.maps[id] = map;
|
||||
|
||||
@@ -19,9 +21,32 @@ L.Contao = L.Class.extend( {
|
||||
return this.maps[id];
|
||||
},
|
||||
|
||||
addIcon: function(id, icon) {
|
||||
this.icons[id] = icon;
|
||||
this.fire('icon:added', { id: id, icon: icon});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
getIcon: function(id) {
|
||||
if (typeof (this.icons[id]) === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.icons[id];
|
||||
},
|
||||
|
||||
pointToLayer: function(feature, latlng) {
|
||||
var marker = L.marker(latlng, feature.properties.options);
|
||||
|
||||
if (feature.properties && feature.properties.icon) {
|
||||
var icon = this.getIcon(feature.properties.icon);
|
||||
|
||||
if (icon) {
|
||||
marker.setIcon(icon);
|
||||
}
|
||||
}
|
||||
|
||||
this.applyFeatureMethods(marker, feature);
|
||||
this.fire('marker:created', { marker: marker, feature: feature, latlng: latlng });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user