Skip to content

Instantly share code, notes, and snippets.

@Remigr
Created January 26, 2015 21:42
Show Gist options
  • Save Remigr/7e4d57620bce1467cd41 to your computer and use it in GitHub Desktop.
Save Remigr/7e4d57620bce1467cd41 to your computer and use it in GitHub Desktop.
Hook to leaflet to add ID to icon markers
(function () {
var original_initIcon = L.Marker.prototype._initIcon,
originalsetIcon = L.Marker.prototype.setIcon;
L.Marker.include({
setIcon: function (icon, id) {
this.options.id = id;
originalsetIcon.call(this, icon);
},
_initIcon: function () {
original_initIcon.call(this);
this._icon.id = "marker-" + this.options.id;
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment