Created
October 11, 2017 00:04
-
-
Save McCulloughRT/ecf50bbf3d5c1c3f09335bf7d3aa6656 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
componentDidMount(){ | |
// pass in your map properties as props to the component | |
const { token, longitude, latitude, zoom, styleID } = this.props; | |
const mapConfig = { | |
container: 'map', | |
style: `mapbox://styles/${ styleID }`, | |
center: [longitude, latitude], | |
zoom: zoom, | |
}; | |
mapboxgl.accessToken = token; | |
this.map = new mapboxgl.Map(mapConfig); | |
// now we can access the map with this.map, just like in 'normal' js | |
this.map.on('load', () => { | |
const style = this.map.getStyle(); | |
// Do whatever you need to do once the map has loaded | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment