Implement style loading and passing to map component

This commit is contained in:
lukasmartinelli
2016-09-09 00:10:54 +02:00
parent 392a7aa832
commit 7f9fb4579e
13 changed files with 84 additions and 143 deletions

View File

@@ -1,21 +1,18 @@
import React from 'react';
import MapboxGl from 'mapbox-gl';
import React from 'react'
import ReactMapboxGl from "react-mapbox-gl"
export class Map extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
MapboxGl.accessToken = "pk.eyJ1IjoibW9yZ2Vua2FmZmVlIiwiYSI6IjIzcmN0NlkifQ.0LRTNgCc-envt9d5MzR75w";
const map = new MapboxGl.Map({
container: this.container,
style: "mapbox://styles/morgenkaffee/cirqasdb8003dh1ntbo6dkvs6"
});
super(props)
}
render() {
return <div ref={x => this.container = x} style={{zIndex: 15}}></div>
if (this.props.mapStyle) {
return <ReactMapboxGl
style={this.props.mapStyle}
accessToken="pk.eyJ1IjoibW9yZ2Vua2FmZmVlIiwiYSI6IjIzcmN0NlkifQ.0LRTNgCc-envt9d5MzR75w"/>
}
return <div />
}
}