Add icon support.

This commit is contained in:
David Molineus
2015-01-06 21:30:57 +01:00
parent 3608f7cd48
commit adc8de55ae
11 changed files with 367 additions and 136 deletions

View File

@@ -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 });