Skip to content

Commit

Permalink
Merge pull request #76 from UNopenGIS/preview-opencellid
Browse files Browse the repository at this point in the history
Add OpenCellId for example of preview of BaseData
  • Loading branch information
yuiseki committed Jun 29, 2024
2 parents f42f847 + 7e49b3c commit bd2d44b
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 12 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"arcgis",
"arcgisonline",
"BODC",
"cellid",
"clearmap",
"cyberjapandata",
"DAAC",
Expand Down
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"maplibre-gl": "^4.4.0",
"pmtiles": "^3.0.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-map-gl": "^7.1.7"
Expand Down
20 changes: 20 additions & 0 deletions public/stylejson/opencellid.org/style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 8,
"sources": {
"opencellid": {
"type": "vector",
"url": "pmtiles://https://data.source.coop/smartmaps/opencellid/cellid.pmtiles",
"attribution": "<a href=\"https://opencellid.org/\">OpenCelliD</a>"
}
},
"layers": [
{
"id": "opencellid",
"source": "opencellid",
"source-layer": "a",
"type": "circle",
"maxzoom": 18,
"minzoom": 2
}
]
}
14 changes: 14 additions & 0 deletions src/components/BaseData/OpenCellId/index.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Meta, StoryObj } from "@storybook/react";
import { OpenCellId } from ".";

const meta = {
component: OpenCellId,
parameters: {
layout: "fullscreen",
},
} satisfies Meta<typeof OpenCellId>;

export default meta;
type Story = StoryObj<typeof OpenCellId>;

export const Preview: Story = {};
30 changes: 30 additions & 0 deletions src/components/BaseData/OpenCellId/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Protocol } from "pmtiles";
import maplibregl from "maplibre-gl";
import "maplibre-gl/dist/maplibre-gl.css";
import { Map } from "react-map-gl/maplibre";
import { useEffect } from "react";

export const OpenCellId = () => {
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/opencellid.org/style.json"
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const OpenStreetMapFrHotRaster = () => {
latitude: 0,
zoom: 4,
}}
dragPan={false}
scrollZoom={false}
dragPan={true}
scrollZoom={true}
hash={false}
style={{ width: "100%", height: "100%" }}
mapStyle="stylejson/tile.openstreetmap.fr/hot/style.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const OpenStreetMapJpOSMBrightVector = () => {
latitude: 0,
zoom: 4,
}}
dragPan={false}
scrollZoom={false}
dragPan={true}
scrollZoom={true}
hash={false}
style={{ width: "100%", height: "100%" }}
mapStyle="https://tile.openstreetmap.jp/styles/osm-bright/style.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const OpenStreetMapOrgRaster = () => {
latitude: 0,
zoom: 4,
}}
dragPan={false}
scrollZoom={false}
dragPan={true}
scrollZoom={true}
hash={false}
style={{ width: "100%", height: "100%" }}
mapStyle="stylejson/tile.openstreetmap.org/style.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const ArcGISWorldImagery = () => {
latitude: 0,
zoom: 4,
}}
dragPan={false}
scrollZoom={false}
dragPan={true}
scrollZoom={true}
hash={false}
style={{ width: "100%", height: "100%" }}
mapStyle="stylejson/server.arcgisonline.com/world_imagery/style.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const GSISeamlessPhoto = () => {
latitude: 0,
zoom: 4,
}}
dragPan={false}
scrollZoom={false}
dragPan={true}
scrollZoom={true}
hash={false}
style={{ width: "100%", height: "100%" }}
mapStyle="stylejson/cyberjapandata.gsi.go.jp/xyz/seamlessphoto/style.json"
Expand Down
4 changes: 2 additions & 2 deletions src/components/BaseMaps/UNClearMapRaster/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const UNClearMapRaster = () => {
latitude: 0,
zoom: 4,
}}
dragPan={false}
scrollZoom={false}
dragPan={true}
scrollZoom={true}
hash={false}
style={{ width: "100%", height: "100%" }}
mapStyle="stylejson/geoservices.un.org/clearmap/style.json"
Expand Down

0 comments on commit bd2d44b

Please sign in to comment.