ymapMarker created after map init not showing
See original GitHub issueHi,
I’m trying to use the <ymap-marker> component to generate markers for an array of places which are loaded asynchronously. However it seems like creating <ymap-marker> after the map initialization doesn’t trigger anything.
I created a codepen:
https://codepen.io/Owumaro/pen/LYYqrRK
I used a setTimeout to fake an async loading. After the timeout, there are 3 ymap-markers but they are not showing.
The problem is that the drawing of the markers is handled by the Map component, however the map is not watching its default slot to get new ymap-marker.
The map component reads its ymap-markers at creation (using this.$slots.default), but if a ymap-marker is created after, it will not be known by the map.
Maybe the ymap-marker should register itself at creation to the parent Map. I’m not sure of how the map keeps track of its children ymap-marker currently.
Another solution would be to delegate the creation of markers to the ymap-marker component itself. I also use vue-googlemaps which works that way:
https://github.com/Akryum/vue-googlemaps/blob/master/src/components/Marker.js#L96
As you can see the marker component gets the map reference and creates the map marker by calling the google maps method. This also allows each marker to be independent and would simplify a lot of code here. But that would be a big change.
What do you think ?
Thanks,
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (2 by maintainers)

Top Related StackOverflow Question
@antoinematyja Yeah. It is a bug. I deleted an observer, but forgot to implement marker creation in created hook. I’ll fix it tomorrow and will think about your another issue #183
согласен), тогда ждем ответа разработчика