leaflet-search
leaflet-search copied to clipboard
Conflict with https://github.com/bbecquet/Leaflet.RotatedMarker in Leaflet 1.0.0
leaflet.rotatedMarker.js:9
Uncaught TypeError: Cannot read property 'iconAnchor' of undefined
(anonymous function) @ leaflet.rotatedMarker.js:9
proto.callInitHooks @ leaflet.js:365
proto.callInitHooks @ leaflet.js:359
NewClass @ leaflet.js:314
onAdd @ leaflet-search.js:137
addTo @ leaflet.js:11610
addTo @ leaflet-search.js:160
addControl @ leaflet.js:11674
(anonymous function) @ index.html:121
See https://github.com/bbecquet/Leaflet.RotatedMarker/issues/6
Hi!
It seems the problem occurs because in the default options passed to the subclass L.Control.Search.Marker
, icon
may be false
instead of a valid Icon
object.
https://github.com/stefanocudini/leaflet-search/blob/689c3deb30f1138d5e2a8a27610b6daf00df87d6/src/leaflet-search.js#L83
My code in rotatedMarker
assumes it's always an Icon
object with options, so it crashes.
I will add a check to make this line more robust: https://github.com/bbecquet/Leaflet.RotatedMarker/blob/master/leaflet.rotatedMarker.js#L9
But I think the best way to fix the bug is on your side, by avoiding false
as a valid icon
value in your subclass. As it contradicts the original Leaflet.Marker
API, you may run into problems with other plugins as well.
What do you think?
Confirmed that @bbecquet's fix to Leaflet.Rotated marker solves the problem. I've closed the issue on his repo, but will leave this one open so you can implement his suggestions in leaflet-search if you want. Thanks!