hubertokf / vue2-leaflet-draw

MIT License
32 stars 25 forks source link

heirarchy assumptions #16

Closed chrisamow closed 3 years ago

chrisamow commented 4 years ago

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...?

glaroc commented 4 years ago

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

kevyt commented 4 years ago

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"

.....

professorhaseeb commented 3 years ago

This issue should be closed in favor of this answer. https://github.com/hubertokf/vue2-leaflet-draw/issues/16#issuecomment-72359309

chrisamow commented 3 years ago

@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!