layers
This commit is contained in:
parent
24b6324ed6
commit
b781a564ea
1 changed files with 37 additions and 49 deletions
|
@ -1,14 +1,8 @@
|
||||||
import { createSignal, Show } from 'solid-js';
|
import { createSignal, Show } from 'solid-js';
|
||||||
import * as maplibre from 'maplibre-gl';
|
import * as maplibre from 'maplibre-gl';
|
||||||
import MapGL, {
|
import MapGL, { Viewport, Camera, Layer, Popup, Marker } from 'solid-map-gl';
|
||||||
Viewport,
|
import { MapboxLayer } from '@deck.gl/mapbox/typed';
|
||||||
Light,
|
import { ArcLayer, ScatterplotLayer } from '@deck.gl/layers/typed';
|
||||||
Camera,
|
|
||||||
Source,
|
|
||||||
Layer,
|
|
||||||
} from 'solid-map-gl';
|
|
||||||
import { MapboxLayer } from '@deck.gl/mapbox';
|
|
||||||
import { ArcLayer } from '@deck.gl/layers';
|
|
||||||
|
|
||||||
import MapControls from './MapControls';
|
import MapControls from './MapControls';
|
||||||
|
|
||||||
|
@ -19,29 +13,9 @@ import 'maplibre-gl/dist/maplibre-gl.css';
|
||||||
|
|
||||||
|
|
||||||
function BadassMap(): JSX.Element {
|
function BadassMap(): JSX.Element {
|
||||||
// data stuff
|
|
||||||
const FANEUIL_HALL: number[] = [-71.05625, 42.36]
|
const FANEUIL_HALL: number[] = [-71.05625, 42.36]
|
||||||
const GD_TAVERN: number[] = [-71.056922, 42.360919]
|
const GD_TAVERN: number[] = [-71.056922, 42.360919]
|
||||||
const FAKE_GJSON = {
|
|
||||||
type: 'geojson',
|
|
||||||
data: {
|
|
||||||
"type": "FeatureCollection", "features": [
|
|
||||||
{ "type": "Feature", "geometry": { "type": "Point", "coordinates": FANEUIL_HALL } },
|
|
||||||
{ "type": "Feature", "geometry": { "type": "Point", "coordinates": GD_TAVERN } },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// markers
|
|
||||||
const RED_DOT = {
|
|
||||||
type: 'circle',
|
|
||||||
paint: {
|
|
||||||
'circle-radius': 4,
|
|
||||||
'circle-color': 'red',
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// map stuff
|
|
||||||
const TILES_URL: string = 'https://api.maptiler.com/maps/024da34e-fa66-4cb3-8f5f-0466b51e972e/style.json?key=Ukl2QNcQUCPAwuelQOvM'
|
const TILES_URL: string = 'https://api.maptiler.com/maps/024da34e-fa66-4cb3-8f5f-0466b51e972e/style.json?key=Ukl2QNcQUCPAwuelQOvM'
|
||||||
const options: MapOptions = {
|
const options: MapOptions = {
|
||||||
container: 'solid-map-gl will override me',
|
container: 'solid-map-gl will override me',
|
||||||
|
@ -59,7 +33,7 @@ function BadassMap(): JSX.Element {
|
||||||
const [rotate, setRotate] = createSignal<boolean>(true);
|
const [rotate, setRotate] = createSignal<boolean>(true);
|
||||||
const toggleRotate = () => setRotate<boolean>(!rotate());
|
const toggleRotate = () => setRotate<boolean>(!rotate());
|
||||||
|
|
||||||
const myDeckLayer = new MapboxLayer({
|
const arcLayer = new MapboxLayer({
|
||||||
id: 'deckgl-arc',
|
id: 'deckgl-arc',
|
||||||
type: ArcLayer,
|
type: ArcLayer,
|
||||||
data: [
|
data: [
|
||||||
|
@ -72,6 +46,19 @@ function BadassMap(): JSX.Element {
|
||||||
getWidth: 8,
|
getWidth: 8,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const scatterplotLayer = new MapboxLayer({
|
||||||
|
id: 'deckgl-scatterplot',
|
||||||
|
type: ScatterplotLayer,
|
||||||
|
data: [
|
||||||
|
{ coordinates: FANEUIL_HALL },
|
||||||
|
{ coordinates: GD_TAVERN },
|
||||||
|
],
|
||||||
|
getPosition: (d: any) => d.coordinates,
|
||||||
|
getRadius: 30,
|
||||||
|
getFillColor: [255, 140, 0],
|
||||||
|
getLineColor: [0, 0, 0,]
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MapGL
|
<MapGL
|
||||||
mapLib={maplibre}
|
mapLib={maplibre}
|
||||||
|
@ -79,26 +66,27 @@ function BadassMap(): JSX.Element {
|
||||||
viewport={viewport()}
|
viewport={viewport()}
|
||||||
onViewportChange={(evt: Viewport) => setViewport(evt)}
|
onViewportChange={(evt: Viewport) => setViewport(evt)}
|
||||||
>
|
>
|
||||||
<Source source={FAKE_GJSON} >
|
<Layer customLayer={arcLayer} />
|
||||||
<Layer style={RED_DOT} />
|
<Layer customLayer={scatterplotLayer} />
|
||||||
</Source>
|
|
||||||
<Layer customLayer={myDeckLayer} />
|
<Marker
|
||||||
<MapControls />
|
lngLat={FANEUIL_HALL}
|
||||||
<Camera
|
options={{ color: '#900' }}
|
||||||
rotateViewport={rotate()}
|
|
||||||
reverse={true}
|
|
||||||
/>
|
|
||||||
<Light style={{
|
|
||||||
anchor: 'viewport',
|
|
||||||
color: 'white',
|
|
||||||
intensity: 0.9,
|
|
||||||
}} />
|
|
||||||
<Show
|
|
||||||
when={rotate()}
|
|
||||||
fallback={<button onClick={toggleRotate}> Rotation On </button>}
|
|
||||||
>
|
>
|
||||||
<button onClick={toggleRotate}> Rotation Off </button>
|
hi
|
||||||
</Show>
|
</Marker>
|
||||||
|
|
||||||
|
<MapControls />
|
||||||
|
<Camera
|
||||||
|
rotateViewport={rotate()}
|
||||||
|
reverse={true}
|
||||||
|
/>
|
||||||
|
<Show
|
||||||
|
when={rotate()}
|
||||||
|
fallback={<button onClick={toggleRotate}> Rotation On </button>}
|
||||||
|
>
|
||||||
|
<button onClick={toggleRotate}> Rotation Off </button>
|
||||||
|
</Show>
|
||||||
</MapGL >
|
</MapGL >
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue