hubertokf/vue2-leaflet-draw

heirarchy assumptions

Closed this issue · 4 comments

Hi Huberto - thanks for your nice work on the leaflet-draw

I was trying to use it and am running into a problem with the map ref not being findable.
https://github.com/hubertokf/vue2-leaflet-draw/blob/master/src/App.vue#L24

It seems like you assume that the parent of the parent of the l-draw-toolbar is the root of the vue component
If there is an extra level in there (e.g. for resizing) then it breaks with an undefined error since it is trying to ask a different object for $refs

Am I seeing this right? Can you think of a workaround without forking your code?
I haven't seen any leaflet best practice or rule that says things should not be arranged this way in the ui...

Please let me know what you think - maybe there is a safer way to find the component root from a child element? Or maybe there could be an option to assume that the parent is the vue2leaflet l-map...?

Having the same issue when trying to put the map inside a modal.

kevyt commented

Did you register your map with ref="map"?
i.e.:
<LMap
ref="map"
:zoom="zoom"
:center="center"
:options="mapOptions"
style="height: 100%"
@update:center="centerUpdate"
@update:zoom="zoomUpdate"
>.....

This issue should be closed in favor of this answer.
#16 (comment)

@professorhaseeb I can't test this at the moment - but I'll defer to you on this and reopen if I find the problem later. Thanks!