Search code examples
fullscreenmapboxmapbox-gl

Mapbox GL - Fullscreen control not working, it is not a constructor


I would like to add the fullscreen control to my map, but for some reason, it doesnt work. I am following tutorial from this link - https://www.mapbox.com/mapbox-gl-js/example/fullscreen/

So to add the FullscreenControl, I use the following code

map.addControl(new mapboxgl.FullscreenControl());

However, it doesnt work, when I compile the project, I see this error in the console - "Uncaught TypeError: mapboxgl.FullscreenControl is not a constructor"

Interestingly, when I use the same code to add the Navigation control, all works as expected.

map.addControl(new mapboxgl.NavigationControl())

Does anyone have an idea where is the problem and why I am able to use that code to add NavigationControl, but not the FullscreenControl?

Thanks a lot


Solution

  • As it was hinted in comments, problem was with the version. I was referencing the older version 0.32.1 . Once I replaced it by version 0.41.0, it started to work