-
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 #97 from UNopenGIS/yuiseki/impl-smp-gelmap
Implement Smart Maps GEL Map component
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { GELMap } from '.'; | ||
|
||
const meta: Meta<typeof GELMap> = { | ||
component: GELMap, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
} satisfies Meta<typeof GELMap>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof GELMap>; | ||
|
||
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,35 @@ | ||
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 { GELPMTilesSource as source } from "./source"; | ||
|
||
export const GELMap = () => { | ||
useEffect(() => { | ||
const protocol = new Protocol(); | ||
maplibregl.addProtocol("pmtiles", protocol.tile); | ||
return () => { | ||
maplibregl.removeProtocol("pmtiles"); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<Map | ||
initialViewState={{ | ||
longitude: 0, | ||
latitude: 0, | ||
zoom: 6, | ||
}} | ||
dragPan={true} | ||
scrollZoom={true} | ||
hash={true} | ||
style={{ width: "100%", height: "100%" }} | ||
mapStyle="stylejson/tile.openstreetmap.jp/fiord-color-gl-style/style.json" | ||
> | ||
<Source key={source.id} {...source}> | ||
{source.layers?.map((layer) => <Layer key={layer.id} source-layer={layer.sourceLayer} {...layer} />)} | ||
</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,23 @@ | ||
import { PMTilesSource } from "../../../types/PMTilesSource"; | ||
|
||
export const GELPMTilesSource: PMTilesSource = { | ||
id: "gel-source", | ||
url: "https://beta.source.coop/smartmaps/gel/gel.pmtiles", | ||
type: "raster", | ||
attribution: '<a href="https://lpdaac.usgs.gov/products/nasadem_hgtv001/">NASADEM</a>, <a href="https://globalmaps.github.io/">Global Map (ISCGM)</a>', | ||
maxzoom: 12, | ||
minzoom: 6, | ||
terrain: { | ||
source: "gel-source", | ||
}, | ||
layers: [ | ||
{ | ||
id: "gel-hills", | ||
type: "hillshade", | ||
source: "gel-source", | ||
paint: { | ||
"hillshade-shadow-color": "#473B24", | ||
}, | ||
}, | ||
], | ||
}; |