Created
January 26, 2015 21:42
-
-
Save Remigr/7e4d57620bce1467cd41 to your computer and use it in GitHub Desktop.
Hook to leaflet to add ID to icon markers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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