-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
233 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { ArmedConflictMap } from "."; | ||
|
||
const meta = { | ||
component: ArmedConflictMap, | ||
parameters: { | ||
layout: "fullscreen", | ||
}, | ||
} satisfies Meta<typeof ArmedConflictMap>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof ArmedConflictMap>; | ||
|
||
export const Preview: Story = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Protocol } from "pmtiles"; | ||
import maplibregl from "maplibre-gl"; | ||
import "maplibre-gl/dist/maplibre-gl.css"; | ||
import { Layer, Map, Source } from "react-map-gl/maplibre"; | ||
import { useEffect } from "react"; | ||
import { ArmedConflictPMTilesSource as source } from "./source"; | ||
|
||
export const ArmedConflictMap = () => { | ||
useEffect(() => { | ||
const protocol = new Protocol(); | ||
maplibregl.addProtocol("pmtiles", protocol.tile); | ||
return () => { | ||
maplibregl.removeProtocol("pmtiles"); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<Map | ||
initialViewState={{ | ||
longitude: 0, | ||
latitude: 0, | ||
zoom: 4, | ||
}} | ||
dragPan={true} | ||
scrollZoom={true} | ||
hash={false} | ||
style={{ width: "100%", height: "100%" }} | ||
mapStyle="stylejson/tile.openstreetmap.jp/fiord-color-gl-style/style.json" | ||
> | ||
<Source | ||
key={`${source.id}-source`} | ||
id={`${source.id}-source`} | ||
type={source.type} | ||
url={source.url} | ||
attribution={source.attribution} | ||
maxzoom={source.maxzoom} | ||
minzoom={source.minzoom} | ||
> | ||
{source.layers?.map((layer) => { | ||
switch (layer.type) { | ||
case "circle": | ||
return ( | ||
<Layer | ||
key={`${layer.id}-layer`} | ||
id={`${layer.id}-layer`} | ||
source={`${layer.id}-source`} | ||
source-layer={layer.sourceLayer} | ||
type={layer.type} | ||
paint={layer.paint} | ||
/> | ||
); | ||
default: | ||
return null; | ||
} | ||
})} | ||
</Source> | ||
</Map> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { PMTilesSource } from "../../../types/PMTilesSource"; | ||
|
||
export const ArmedConflictPMTilesSource: PMTilesSource = { | ||
id: "uppsala-armed-conflict", | ||
url: "pmtiles://https://data.source.coop/smartmaps/uppsala-conflict/a.pmtiles", | ||
type: "vector", | ||
attribution: | ||
'<a href="https://ucdp.uu.se/">Uppsala Conflict Data Program</a>', | ||
maxzoom: 18, | ||
minzoom: 2, | ||
layers: [ | ||
{ | ||
id: "event-layer", | ||
sourceLayer: "event", | ||
type: "circle", | ||
paint: { | ||
"circle-radius": 8, | ||
"circle-color": "rgba(141, 211, 199, 0.8)", | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { PMTilesSource } from "../../../types/PMTilesSource"; | ||
|
||
export const OpenCellIdPMTilesSource: PMTilesSource = { | ||
id: "opencellid-source", | ||
url: "pmtiles://https://data.source.coop/smartmaps/opencellid/cellid.pmtiles", | ||
type: "vector", | ||
attribution: '<a href="https://opencellid.org/">OpenCelliD</a>', | ||
maxzoom: 18, | ||
minzoom: 2, | ||
layers: [ | ||
{ | ||
id: "cell-layer", | ||
sourceLayer: "a", | ||
type: "circle", | ||
paint: { | ||
"circle-radius": 8, | ||
"circle-color": "rgba(141, 211, 199, 0.8)", | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.