question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ymapMarker created after map init not showing

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
PNKBizzcommented, Nov 20, 2019

@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

1reaction
malyshevarmancommented, Nov 20, 2019

согласен), тогда ждем ответа разработчика

Read more comments on GitHub >

github_iconTop Results From Across the Web

I create a default marker at MAP initialization but Marker not ...
working code snippet: function initialize() { var map; var myCenter = new google.maps.LatLng(18.527362399999998,73.8783206); var mapProp ...
Read more >
Markers | Maps JavaScript API - Google Developers
A marker identifies a location on a map. By default, a marker uses a standard image. Markers can display custom images, in which...
Read more >
Modify Map (add data) after initialization - Google Groups
I have a map on my webpage, which works fine, but I want to add data to it after it has been initialized....
Read more >
WP Go Maps (formerly WP Google Maps) – WordPress plugin
Super easy to use, no coding required! Create as many map markers as you need by simply typing in the address; Responsive maps;...
Read more >
Map - .NET MAUI - Microsoft Learn
NET MAUI app on WinUI, to display a map at a specific location or to ... Once a MapSpan has been created, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found