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

How to reload layers after style change? #146

Open
edanweis opened this issue Oct 22, 2019 · 1 comment
Open

How to reload layers after style change? #146

edanweis opened this issue Oct 22, 2019 · 1 comment

Comments

@edanweis
Copy link

edanweis commented Oct 22, 2019

When map style is changed, layers are removed (even with clearSource: false option) and the new style loads without the previous layer. Geojson features do not display, despite their sources remaining.

mapbox-gl.js?e192:29 Error: The layer 'my-layer' does not exist in the map's style and cannot be queried for features.

Should there be a layer method for reload? Only remove, and move exist currently.

@edanweis
Copy link
Author

edanweis commented Oct 22, 2019

In case anyone comes across this problem, my workaround:

if(!this.map.getLayer('my-layer-name')){
	this.map.addLayer({
		...this.myLayer,
		id: 'my-layer-name', 
		source: this.geojsonSource
	})
}

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