Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with multiple maps on a page? #64

Open
cchance27 opened this issue Mar 6, 2022 · 2 comments
Open

Issue with multiple maps on a page? #64

cchance27 opened this issue Mar 6, 2022 · 2 comments

Comments

@cchance27
Copy link

When i have 2 components that are Map's on a page I get the following error not sure how to fix this.

map-action.js:31
Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'accessToken')
at init (map-action.js:31:31)
at map-action.js:19:14
at load (asset-loader.js:7:9)
at action (map-action.js:18:3)
at mount (Map.svelte? [sm]:15:6)
at Object.targetCmp.$$.fragment.m (svelte-hooks.js:216:24)
at mount_component (index.mjs:1798:26)
at mount (MapBox.svelte:36:12)
at Object.targetCmp.$$.fragment.m (svelte-hooks.js:216:24)
at mount_component (index.mjs:1798:26)

@raphet
Copy link

raphet commented Apr 24, 2022

I have the same issue. Since there is neither a voting nor particularly fitting reaction emoticon, I'll just leave this comment.

@aubergene
Copy link

I think the problem is the asset loader callback is being called before the asset has loaded. A quick work around is to statically load the assets before initialising the map by putting these in the <head>

<script src="//api.mapbox.com/mapbox-gl-js/v2.7.1/mapbox-gl.js" id="byk-gl-js"></script>
<link rel="stylesheet" type="text/css" href="//api.mapbox.com/mapbox-gl-js/v2.7.1/mapbox-gl.css" id="byk-gl-css" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants