You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some of Popup class methods doesn't work as expected:
addClassName
removeClassName
toggleClassName
getMaxWidth
getElement
That's how I'm initializing popup: let popup = new mapboxgl.Popup().setText("Hello World");
And this is a code that fails: popup.addClassName('my-class');
but it works when in the first place I add a popup to map using 'addTo()' and set coordinates using 'setLngLat()' method. In any other case methods mentioned in the list above throw this error:
TypeError: this._container is undefined popup.js:359:8
addClassName popup.js:359
test.html:30
This was caused by those methods trying to access the popup's container element before it's created. I added checks so that the errors won't throw if the container is undefined, but these methods won't do anything if they're called before addTo or setLngLat.
Would it be possible to have the container created in the constructor so that these methods do something before addTo or setLngLat?
Maybe there's a reason that I'm not aware, but I think it will be confusing for developers using a method that does nothing.
If my suggestion is not possible, perhaps instead of throwing error you could use a warning message.
Some of Popup class methods doesn't work as expected:
That's how I'm initializing popup:
let popup = new mapboxgl.Popup().setText("Hello World");
And this is a code that fails:
popup.addClassName('my-class');
but it works when in the first place I add a popup to map using 'addTo()' and set coordinates using 'setLngLat()' method. In any other case methods mentioned in the list above throw this error:
mapbox GL JS version: https://api.mapbox.com/mapbox-gl-js/v1.8.1/mapbox-gl.js
It happens on every browser.
The text was updated successfully, but these errors were encountered: