2023-04-15 07:03:37 -04:00
|
|
|
import { Component, createSignal, Show } from 'solid-js';
|
2023-04-15 01:21:33 -04:00
|
|
|
import MapGL, { Viewport, Control, Light, Camera } from 'solid-map-gl';
|
|
|
|
import * as maplibre from 'maplibre-gl';
|
|
|
|
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
|
|
|
2023-04-15 07:03:37 -04:00
|
|
|
export default function BadassMap(): Component {
|
2023-04-15 01:21:33 -04:00
|
|
|
const [viewport, setViewport] = createSignal({
|
|
|
|
center: [-71.05625, 42.36],
|
|
|
|
zoom: 15.5,
|
|
|
|
bearing: 160,
|
|
|
|
pitch: 60,
|
|
|
|
maxPitch: 85,
|
|
|
|
antialias: true,
|
|
|
|
} as Viewport);
|
|
|
|
|
2023-04-15 06:35:25 -04:00
|
|
|
const [rotate, setRotate] = createSignal(true)
|
2023-04-15 07:03:37 -04:00
|
|
|
const toggleRotate = () => setRotate(!rotate())
|
2023-04-15 05:34:42 -04:00
|
|
|
|
2023-04-15 01:21:33 -04:00
|
|
|
return (
|
|
|
|
<MapGL
|
|
|
|
mapLib={maplibre}
|
|
|
|
options={{
|
|
|
|
style: 'https://api.maptiler.com/maps/024da34e-fa66-4cb3-8f5f-0466b51e972e/style.json?key=Ukl2QNcQUCPAwuelQOvM'
|
|
|
|
}}
|
|
|
|
viewport={viewport()}
|
|
|
|
onViewportChange={(evt: Viewport) => setViewport(evt)}
|
|
|
|
>
|
|
|
|
|
2023-04-15 07:03:37 -04:00
|
|
|
<Show
|
|
|
|
when={rotate()}
|
|
|
|
fallback={<button onClick={toggleRotate}> Rotation On </button>}
|
|
|
|
>
|
|
|
|
<button onClick={toggleRotate}> Rotation Off </button>
|
|
|
|
</Show>
|
2023-04-15 06:35:25 -04:00
|
|
|
|
2023-04-15 01:21:33 -04:00
|
|
|
<Control type="fullscreen" position="top-right" />
|
|
|
|
<Control type="navigation" position="top-right" />
|
|
|
|
<Control type="geolocate" position="top-right" />
|
|
|
|
<Control type="scale" position="bottom-left" />
|
|
|
|
|
|
|
|
<Light style={{
|
|
|
|
anchor: 'viewport',
|
|
|
|
color: 'white',
|
|
|
|
intensity: 0.9,
|
|
|
|
}} />
|
|
|
|
|
|
|
|
<Camera
|
2023-04-15 05:34:42 -04:00
|
|
|
rotateViewport={rotate()}
|
2023-04-15 07:03:37 -04:00
|
|
|
reverse={true}
|
2023-04-15 01:21:33 -04:00
|
|
|
/>
|
|
|
|
|
|
|
|
</MapGL>
|
|
|
|
);
|
|
|
|
};
|