Mapbox-gl-js: Reuse/store map instance

Created on 24 Aug 2019  路  2Comments  路  Source: mapbox/mapbox-gl-js

mapbox-gl-js version: 1.2.1

Question

Is there a way to reuse mapbox loads?

My use case is an app where the pages are navigated via react router and 1 of the pages is a map. Currently I am creating a map each time the user visits the page but I'd like to be able to reuse loads + token uses if possible when navigating away from and back to the map page.

Sorry if duplicate issue -- I searched old issues and stackoverflow and couldn't find something very closely related

Thanks

Links to related documentation

API Documentation for map

feature

Most helpful comment

Has there been any progress made on this issue? Maybe a workaround to still get the desired behaviour? I am currently in the same predicament where I am wanting to let the user search for a specific location and show it on a MapBox map. That same map+location instance reappears later on in the application. Instead of reloading mapbox I would like to reuse the instance for quicker and more seamless loading times.

All 2 comments

Has there been any progress made on this issue? Maybe a workaround to still get the desired behaviour? I am currently in the same predicament where I am wanting to let the user search for a specific location and show it on a MapBox map. That same map+location instance reappears later on in the application. Instead of reloading mapbox I would like to reuse the instance for quicker and more seamless loading times.

mapbox-gl-js version: 1.12.0

We have a similar use case in an Angular application.
We would like to maintain a single instance in a service and be able to reuse it in many components, cleaning up/toggling layers according to the component's role.

Was this page helpful?
0 / 5 - 0 ratings