mirror of
https://github.com/visgl/react-map-gl.git
synced 2026-01-18 15:54:22 +00:00
44 lines
918 B
JavaScript
44 lines
918 B
JavaScript
/* global window, document */
|
|
import React, {Component} from 'react';
|
|
import {render} from 'react-dom';
|
|
import MapGL from 'react-map-gl';
|
|
|
|
const MAPBOX_TOKEN = ''; // Set your mapbox token here
|
|
|
|
class Root extends Component {
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
viewport: {
|
|
latitude: 37.785164,
|
|
longitude: -122.41669,
|
|
zoom: 14,
|
|
bearing: 0,
|
|
pitch: 0,
|
|
width: window.innerWidth,
|
|
height: window.innerHeight
|
|
}
|
|
};
|
|
}
|
|
|
|
render() {
|
|
|
|
const {viewport} = this.state;
|
|
|
|
return (
|
|
<MapGL
|
|
{...viewport}
|
|
mapStyle="mapbox://styles/mapbox/dark-v9"
|
|
onViewportChange={v => this.setState({viewport: v})}
|
|
preventStyleDiffing={false}
|
|
mapboxApiAccessToken={MAPBOX_TOKEN} />
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
const root = document.createElement('div');
|
|
document.body.appendChild(root);
|
|
render(<Root />, root);
|