Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making use of the attach callback #58

Open
cwmrowe opened this issue Jan 4, 2016 · 0 comments
Open

Making use of the attach callback #58

cwmrowe opened this issue Jan 4, 2016 · 0 comments

Comments

@cwmrowe
Copy link
Contributor

cwmrowe commented Jan 4, 2016

I am using the leaflet-map web component within an Angular 2 app, and the two appear to be a very good match.

However, there appears to be a problem with the way that Angular 2 updates the view and the way that leaflet-map updates the underlying leaflet map. For example, lets say I have an array of 3 locations and plot these on a map with the leaflet-marker element. If I then remove the second location from my array angular will update the DOM to show only two leaflet-marker elements, however, the last two markers are removed from the map.

It appears that Angular 2 removes the last maker (but not the first), and then reattaches it. This is the same leaflet-marker element, so no new marker is created.

I have managed to get the markers working correctly with Angular 2 by adding the following Polymer callback to leaflet-marker.

attached: function(){
    if(this.container && this.feature){
       this.feature.addTo(this.container);
    }
}

I'm happy to create a pull request if you think this is an acceptable approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant