Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

Uncaught ReferenceError: map is not defined with mapbox v0.54 and React #71

Open
shaunlandy opened this issue Aug 5, 2019 · 0 comments

Comments

@shaunlandy
Copy link

I've actually came up with a resolution to this myself but it took quite some time to work out the error. I have recently updated my threebox version from a much older version and found I got this error.

Uncaught ReferenceError: map is not defined
    at va.obj._setObject 
    at va.obj.set 
    at va.obj.setCoords

The source of the error can be tracked to AnimationManager as it takes a map parameter but it actually doesn't appear to ever get fed in a value or used. The actual value used is a more global map value. I found two easy methods that resolved the issue. By adding a global map reference once the map has been provided through onAdd.

onAdd(map, mbxContext) {
    window.map = map;
    //...other onAdd stuff
}

Or to ensure that the map container object has an id set to 'map'

<div id={'map'} className={classes.container}>
    <Map
        //...other map stuff
    >
    </Map>
</div>

Comes across as misleading as you'd expect the map object to be passed through to everything rather than using a global or an explicitly named id as well. Animation manager could probably just get access to the map within init at the same time as CameraSync or at least have a mention in the documentation about having to explicitly use an id of 'map'.

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

No branches or pull requests

1 participant