-
Notifications
You must be signed in to change notification settings - Fork 142
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
Production Build Errors #53
Comments
Yup, I have the same problem when adding and removing the map from the page. Here's the stack trace when there's an error adding a map:
I see this periodically on Chrome Version 68.0.3440.106 (Official Build) (64-bit). |
@dgrald doesn't seems to be the same issue. "Failed to initialize WebGL". |
Gotcha, thanks, @Wykks ! Sorry for the confusion. |
This starting happening on development build as well. A colleague of mine found a temporary fix that works but is not sure if it is a permanent solution to the problem. Line 544 of fesm5/ngx-mapbox-gl.js is currently this. /**
* @param {?} control
* @return {?}
*/
MapService.prototype.removeControl = /**
* @param {?} control
* @return {?}
*/
function (control) {
var _this = this;
return this.zone.runOutsideAngular(function () {
_this.mapInstance.removeControl(/** @type {?} */ (control));
});
}; If you replace it with this it seems to resolve it when using ng serve to run your angular app. /**
* @param {?} control
* @return {?}
*/
MapService.prototype.removeControl = /**
* @param {?} control
* @return {?}
*/
function (control) {
var _this = this;
return this.zone.runOutsideAngular(function () {
if(control)
{
_this.mapInstance.removeControl(/** @type {?} */ (control));
}
});
}; |
The above 'fix' doesn't resolve the issue but I think I've narrowed down the problem. It seems that including the mglGeolocate control is causing the initial error stated above. <mgl-control mglGeolocate position="top-left"></mgl-control> If we take the following portion of the initial stack trace: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'remove' of undefined
TypeError: Cannot read property 'remove' of undefined
at n.onRemove (mapbox-gl.js:33)
at o.removeControl (mapbox-gl.js:33)
at ngx-mapbox-gl.js:555 And we go to the source definition for the onRemove function for mapbox-gl.js it contains a bunch of code related to a users geo location. I noticed that there is no control on the page for user's geolocation so I suspect this is why the control it's trying to remove is undefined. Removing the mglGeolocate control fixes my issue for development and production builds. I'm not sure how to fix the actual library for this but I hope this helps someone experiencing the same issue. |
Have you added I added a check to not call (This may also happen if the control is destroyed before the map is created). |
Yes I've added the mapbox-gl-geocoder package. |
Closing, safety check released. |
When I load a page with a map on it, everything loads fine and the map shows up and you can do what you will with it. As soon as I leave the page and navigate to another page I get the below error.
package.json
app.module.ts
map.component.html
map.component.ts
Any chance anyone else is experiencing this problem?
The text was updated successfully, but these errors were encountered: