-
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.
Merge pull request #80 from UNopenGIS/add-smp-ucdp
Add smp ucdp
- Loading branch information
Showing
5 changed files
with
102 additions
and
6 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
lib/data/data.source.coop/smartmaps/uppsala-conflict/index.yaml
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,10 @@ | ||
data_id: smartmaps_uppsala_conflict_pmtiles | ||
license: CC-BY-4.0 | ||
attributions: | ||
- Uppsala Conflict Data Program | ||
- UN Smart Maps | ||
description: PMTiles converted Armed conflict data from the Uppsala Conflict Data Program (UCDP) by UN Smart Maps. | ||
data_format: pmtiles | ||
file_format: pmtiles | ||
file_size: 130MB | ||
url: https://data.source.coop/smartmaps/uppsala-conflict/a.pmtiles |
27 changes: 27 additions & 0 deletions
27
src/components/Combined/ArmedConflictWithBaseMap/index.stories.ts
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,27 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { ArmedConflictWithBaseMap } from "."; | ||
import { mapStyleOptions } from "../../mapStyleOptions"; | ||
|
||
const meta = { | ||
component: ArmedConflictWithBaseMap, | ||
argTypes: { | ||
mapStyle: { | ||
options: mapStyleOptions, | ||
control: { type: "select" }, | ||
}, | ||
}, | ||
args: { | ||
mapStyle: "stylejson/tile.openstreetmap.jp/fiord-color-gl-style/style.json", | ||
}, | ||
parameters: { | ||
layout: "fullscreen", | ||
options: { | ||
bottomPanelHeight: 300, | ||
}, | ||
}, | ||
} satisfies Meta<typeof ArmedConflictWithBaseMap>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof ArmedConflictWithBaseMap>; | ||
|
||
export const Preview: Story = {}; |
59 changes: 59 additions & 0 deletions
59
src/components/Combined/ArmedConflictWithBaseMap/index.tsx
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"; | ||
|
||
export const ArmedConflictWithBaseMap:React.FC<{mapStyle: string}> = ({mapStyle}) => { | ||
useEffect(() => { | ||
const protocol = new Protocol(); | ||
maplibregl.addProtocol("pmtiles", protocol.tile); | ||
return () => { | ||
maplibregl.removeProtocol("pmtiles"); | ||
}; | ||
}, []); | ||
|
||
const layer = { | ||
id: "uppsala-conflict", | ||
url: "pmtiles://https://data.source.coop/smartmaps/uppsala-conflict/a.pmtiles", | ||
attribution: '<a href="https://opencellid.org/">OpenCelliD</a>', | ||
maxzoom: 18, | ||
minzoom: 2, | ||
}; | ||
|
||
return ( | ||
<Map | ||
initialViewState={{ | ||
longitude: 0, | ||
latitude: 0, | ||
zoom: 4, | ||
}} | ||
dragPan={true} | ||
scrollZoom={true} | ||
hash={false} | ||
style={{ width: "100%", height: "100%" }} | ||
mapStyle={mapStyle} | ||
> | ||
<Source | ||
key={`${layer.id}-source`} | ||
id={`${layer.id}-source`} | ||
type="vector" | ||
url={layer.url} | ||
attribution={layer.attribution} | ||
maxzoom={layer.maxzoom} | ||
minzoom={layer.minzoom} | ||
> | ||
<Layer | ||
id={`${layer.id}-layer`} | ||
source={`${layer.id}-source`} | ||
source-layer="event" | ||
type="circle" | ||
paint={{ | ||
"circle-radius": 8, | ||
"circle-color": "rgba(141, 211, 199, 0.8)", | ||
}} | ||
/> | ||
</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
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