Relative Content

Tag Archive for mapbox-gl-jsmaplibre-gl

How to resize() Mapbox canvas without preserving original center?

I have a mapbox map set up with resize() during transition working fine. I know the resize() function will try to keep the original center as it’s resizing (For example, A city that was in the center of the map will still be at the center when the mapContainer size is doubled) However, I don’t want this effect and would rather have the same location be at the same screen position instead. How would I be able to do this without setting setCenter() right after every resize? I have tried setCenter but it makes it look incredibly clunky. I’ve attached a picture description of effect I would like to have. (circle represents a location)
I’ve tried searching through resize documentation but nothing really seemed to help where I could disable the center option. I would appreciate any help I can get! Thank you!