2016-09-09 00:10:54 +02:00
|
|
|
import React from 'react'
|
2016-09-09 14:09:02 +02:00
|
|
|
import ReactMapboxGl, { ZoomControl } from "react-mapbox-gl"
|
|
|
|
|
2016-09-09 11:29:18 +02:00
|
|
|
import theme from './theme.js'
|
2016-09-08 19:47:29 +02:00
|
|
|
|
|
|
|
export class Map extends React.Component {
|
2016-09-09 15:49:23 +02:00
|
|
|
static propTypes = {
|
|
|
|
styleManager: React.PropTypes.object.isRequired
|
|
|
|
}
|
|
|
|
|
2016-09-08 20:35:21 +02:00
|
|
|
constructor(props) {
|
2016-09-09 15:49:23 +02:00
|
|
|
super(props)
|
|
|
|
this.map = null
|
|
|
|
}
|
|
|
|
|
|
|
|
onStyleChange(change) {
|
|
|
|
this.map[change.command].apply(this.map, change.args);
|
|
|
|
}
|
|
|
|
|
|
|
|
onMapLoaded(map) {
|
|
|
|
this.map = map;
|
|
|
|
this.props.styleManager.onStyleChange(this.onStyleChange.bind(this))
|
2016-09-08 20:35:21 +02:00
|
|
|
}
|
|
|
|
|
2016-09-08 19:47:29 +02:00
|
|
|
render() {
|
2016-09-09 15:49:23 +02:00
|
|
|
if (this.props.styleManager.mapStyle) {
|
2016-09-09 00:10:54 +02:00
|
|
|
return <ReactMapboxGl
|
2016-09-09 15:49:23 +02:00
|
|
|
onStyleLoad={this.onMapLoaded.bind(this)}
|
|
|
|
style={this.props.styleManager.mapStyle}
|
2016-09-09 14:09:02 +02:00
|
|
|
accessToken="pk.eyJ1IjoibW9yZ2Vua2FmZmVlIiwiYSI6IjIzcmN0NlkifQ.0LRTNgCc-envt9d5MzR75w">
|
|
|
|
<ZoomControl/>
|
|
|
|
</ReactMapboxGl>
|
2016-09-09 11:29:18 +02:00
|
|
|
}
|
|
|
|
return <div style={{backgroundColor: theme.colors.black}}/>
|
2016-09-08 19:47:29 +02:00
|
|
|
}
|
|
|
|
}
|