mirror of
https://github.com/visgl/react-map-gl.git
synced 2026-01-18 15:54:22 +00:00
32 lines
700 B
JavaScript
32 lines
700 B
JavaScript
/* global document */
|
|
import * as React from 'react';
|
|
import {useState} from 'react';
|
|
import {render} from 'react-dom';
|
|
import MapGL from 'react-map-gl';
|
|
|
|
const MAPBOX_TOKEN = ''; // Set your mapbox token here
|
|
|
|
function Root() {
|
|
const [viewport, setViewport] = useState({
|
|
latitude: 37.8,
|
|
longitude: -122.4,
|
|
zoom: 14,
|
|
bearing: 0,
|
|
pitch: 0
|
|
});
|
|
|
|
return (
|
|
<MapGL
|
|
{...viewport}
|
|
width="100vw"
|
|
height="100vh"
|
|
mapStyle="mapbox://styles/mapbox/dark-v9"
|
|
onViewportChange={setViewport}
|
|
mapboxApiAccessToken={MAPBOX_TOKEN}
|
|
/>
|
|
);
|
|
}
|
|
|
|
document.body.style.margin = 0;
|
|
render(<Root />, document.body.appendChild(document.createElement('div')));
|