-
Notifications
You must be signed in to change notification settings - Fork 602
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
Draw plugin breaks when map style changes #512
Comments
@Naimikan your codepen is not working for me. That said, you cannot use |
@Naimikan @mcwhittemore is there a work around for this? Best, |
@guillec - I don't think I'll have the space to do this in the next few weeks, but I am more than willing to work with someone on a PR and get this merged. |
@mcwhittemore I am having this issue as well. Can you describe to me what is causing the problem and how I may address it. Happy to work on a PR. |
@jisaacks - When the style of the map is changed the custom map layers that Draw requires are destroyed but Draw doesn't know this so it keeps trying to reference them which results in the above errors. The solution is to listen to the style change event and make sure that after it is fired, the map still has the required layers. If it does not, they should be added. |
@jisaacks @mcwhittemore thank you guys! |
@jisaacks @mcwhittemore thanks! |
@mcwhittemore There doesn't seem to be any events fired when the style is changed Do you have any advice on how to listen for the style change. Should I make a PR to mapbox-gl-js to add an event? |
👍 note that we're going to be adding a |
@mcwhittemore @lucaswoj I added a PR #540 or are y'all wanting to wait until mapbox/mapbox-gl-js#3578 is released and use that? |
Here's a solution that has worked well for the Mapbox team in the past – use two maps: #494 (comment) |
@samanpwbb that would require everyone who uses multple styles to unnecesarily have to do this duplicate map hack. What if they wanted to use several styles, etc. It just seems like we should fix the issue and not force users to use work-arounds. PR #540 fixes the errors and even keeps the polygons when changing map. |
@jisaacks - sorry for the delay here, I've been out on family leave. I'll get to reviewing this today. |
When I draw something on map and I change the map style, draw plugin breaks and I can't draw anything more. Draw plugin throws me this error:
"The layer 'gl-draw-polygon-fill-inactive.cold' does not exist in the map's style and cannot be queried for features."
Example:
http://codepen.io/Naimikan/pen/JRJOVN?editors=1111
I want to draw a polygon on style, save it, change style and continue drawing other polygons on other styles. I think I have to create style's layer on style change because style change won't do it by itself.
The text was updated successfully, but these errors were encountered: