We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When attempting to update GL JS version from 0.40.1 to 0.44.1, we found that the style-layer switching no longer works.
How it was (successfully) handled in the latest mapbox-gl-circle version:
styledataloading
styledata
Was working really well.
Here's the code that does it:
class MapboxCircle { /* snip */ /** * When map style is changed, remove circle assets from map and add it back on next MapboxGL 'styledata' event. * @param {MapDataEvent} event * @private */ _onMapStyleDataLoading(event) { if (this.map) { this.map.once('styledata', () => { // noinspection JSUnresolvedVariable this.addTo(event.target); }); this.remove(); } } /* snip */ addTo(map, before) { const addCircleAssetsOnMap = () => { /* snip */ map.on('styledataloading', this._onMapStyleDataLoading); /* snip */ } /* snip */ /** * Remove source data, layers and listeners from map. * @return {MapboxCircle} * @public */ remove() { this.map.off('styledataloading', this._onMapStyleDataLoading); this.observer.disconnect(); if (this.options.editable) { this._unbindBroadcastListeners(); MapboxCircle._removeActiveEditableCircle(this); this.off('radiuschanged', this._onRadiusChanged).off('centerchanged', this._onCenterChanged); this._unbindRadiusHandlesListeners(); this.map.removeLayer(this._circleRadiusHandlesId); this._unbindCenterHandleListeners(); this.map.removeLayer(this._circleCenterHandleId); this.map.removeSource(this._circleRadiusHandlesSourceId); this.map.removeSource(this._circleCenterHandleSourceId); } this.map.off('zoomend', this._onZoomEnd); this._unbindCircleFillListeners(); this.map.removeLayer(this._circleFillId); this.map.removeLayer(this._circleStrokeId); this.map.removeSource(this._circleSourceId); this.map = null; return this; } /* snip */ }
What happens with the latest version is that remove() call fails because, apparently, the circle assets already does not exist.
Question: @ryanbaumann is there some earlier event we should listen to in order to detect-and-handle a style layer change?
The text was updated successfully, but these errors were encountered:
@mblomdahl I would recommend:
if (map.getLayer('my-layer')) { map.removeLayer('my-layer') } if ((map.getSource('my-source')) { map.removeSource('my-layer') }
cc @JulieMunro
Sorry, something went wrong.
smithmicro#73 Bump library version to 1.6.5, mapbox-gl version to 0.4…
db33129
…4.1 and update misc dependencies
smithmicro#73 Use conditional map.removeLayer() and map.removeSource(…
7afb03c
…) calls when removing a circle (thanks @ryanbaumann!)
smithmicro#73 Add changelog entry for 1.6.5 + update Mapbox version u…
66571f8
…sed in gh-pages sample
add me to the review team :)
mblomdahl
ryanbaumann
No branches or pull requests
When attempting to update GL JS version from 0.40.1 to 0.44.1, we found that the style-layer switching no longer works.
How it was (successfully) handled in the latest mapbox-gl-circle version:
styledataloading
upon being added to a mapstyledata
firingstyledata
firing, the circle would add itself back to the mapWas working really well.
Here's the code that does it:
What happens with the latest version is that remove() call fails because, apparently, the circle assets already does not exist.
Question: @ryanbaumann is there some earlier event we should listen to in order to detect-and-handle a style layer change?
The text was updated successfully, but these errors were encountered: