shareabouts icon indicating copy to clipboard operation
shareabouts copied to clipboard

accesToken in config not passed through to app

Open eveostay opened this issue 8 years ago • 2 comments

In our local flavor's config.yml I have

layers:
    - type: mapbox
      style: mapbox://styles/[actual string removed]
      accessToken: [actual string removed]

But, the accessToken wasn't being passed through, resulting in the error L.mapboxGL is not a function.

The workaround was to add the token string to the settings.py:

+MAPBOX_TOKEN = env.get('MAPBOX_TOKEN', '[string]')

eveostay avatar Feb 25 '16 18:02 eveostay

You can see where the Django template checks the token and loads the library here: https://github.com/openplans/shareabouts/blob/master/src/sa_web/templates/base.html#L140-L144 I think this is by design to avoid loading the mapbox-gl-js library unnecessarily.

I believe the accessToken: attribute in the config is used only when you want to override the access token in your environment variable for a particular layer.

Perhaps this design could be more explicit. Ideally, I imagine a solution that loads modules dynamically, by using RequireJS. It seems like it would be a significant refactor, but worth it!

modulitos avatar Feb 25 '16 19:02 modulitos

Agreed, this is a little akward the way that MAPBOX_TOKEN is required for the Mapbox JS to be loaded. The docs in CONFIG.md don't really explain this properly.

BenSturmfels avatar Mar 27 '23 03:03 BenSturmfels