@geolonia/maps-react 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +161 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Geolonia Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# @geolonia/maps-react
|
|
2
|
+
|
|
3
|
+
React component wrapper for [Geolonia Maps](https://geolonia.com/). Provides declarative React components built on `@geolonia/maps-core`.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @geolonia/maps-react maplibre-gl
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Peer dependencies:** `react >= 18`, `react-dom >= 18`, `maplibre-gl >= 5`
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
17
|
+
import '@geolonia/maps-core/css';
|
|
18
|
+
import { Map, Marker, Source, Layer } from '@geolonia/maps-react';
|
|
19
|
+
|
|
20
|
+
function App() {
|
|
21
|
+
return (
|
|
22
|
+
<Map
|
|
23
|
+
style="https://tile.openstreetmap.jp/styles/osm-bright/style.json"
|
|
24
|
+
center={[139.7671, 35.6812]}
|
|
25
|
+
zoom={14}
|
|
26
|
+
containerStyle={{ width: '100%', height: '400px' }}
|
|
27
|
+
>
|
|
28
|
+
<Marker lat={35.6812} lng={139.7671} color="#E4402F">
|
|
29
|
+
<p>Tokyo Station</p>
|
|
30
|
+
</Marker>
|
|
31
|
+
|
|
32
|
+
<Source id="stations" type="geojson" data={geojson}>
|
|
33
|
+
<Layer
|
|
34
|
+
id="stations-circle"
|
|
35
|
+
type="circle"
|
|
36
|
+
paint={{ 'circle-radius': 6, 'circle-color': '#007cbf' }}
|
|
37
|
+
/>
|
|
38
|
+
</Source>
|
|
39
|
+
</Map>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Components
|
|
45
|
+
|
|
46
|
+
### `<Map>`
|
|
47
|
+
|
|
48
|
+
Root component. Creates a Geolonia map instance and provides it to children via `MapContext`.
|
|
49
|
+
|
|
50
|
+
| Prop | Type | Description |
|
|
51
|
+
|------|------|-------------|
|
|
52
|
+
| `apiKey` | `string` | Geolonia API key |
|
|
53
|
+
| `style` | `string` | Map style name or URL (e.g. `"geolonia/basic-v2"`) |
|
|
54
|
+
| `center` | `[number, number]` | Initial center `[lng, lat]` |
|
|
55
|
+
| `zoom` | `number` | Initial zoom level |
|
|
56
|
+
| `bearing` | `number` | Initial bearing (rotation) |
|
|
57
|
+
| `pitch` | `number` | Initial pitch (tilt) |
|
|
58
|
+
| `hash` | `boolean` | Sync map position with URL hash |
|
|
59
|
+
| `lang` | `'ja' \| 'en' \| 'auto'` | Language for style labels |
|
|
60
|
+
| `marker` | `boolean` | Show default marker at center |
|
|
61
|
+
| `markerColor` | `string` | Default marker color |
|
|
62
|
+
| `navigationControl` | `boolean \| ControlPosition` | Navigation control |
|
|
63
|
+
| `geolocateControl` | `boolean \| ControlPosition` | Geolocate button |
|
|
64
|
+
| `fullscreenControl` | `boolean \| ControlPosition` | Fullscreen button |
|
|
65
|
+
| `scaleControl` | `boolean \| ControlPosition` | Scale bar |
|
|
66
|
+
| `geoloniaControl` | `boolean \| ControlPosition` | Geolonia logo |
|
|
67
|
+
| `minZoom` / `maxZoom` | `number` | Zoom range |
|
|
68
|
+
| `gestureHandling` | `boolean` | Gesture handling on scrollable pages |
|
|
69
|
+
| `loader` | `boolean` | Loading animation |
|
|
70
|
+
| `3d` | `boolean` | Enable 3D mode |
|
|
71
|
+
| `className` | `string` | CSS class for the container |
|
|
72
|
+
| `containerStyle` | `CSSProperties` | Inline styles for the container |
|
|
73
|
+
| `onLoad` | `(map: GeoloniaMap) => void` | Callback when map is loaded |
|
|
74
|
+
| `children` | `ReactNode` | Child components |
|
|
75
|
+
| `ref` | `Ref<GeoloniaMap>` | Ref to the map instance |
|
|
76
|
+
|
|
77
|
+
`ControlPosition` = `'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'`
|
|
78
|
+
|
|
79
|
+
### `<Marker>`
|
|
80
|
+
|
|
81
|
+
Displays a marker at the given coordinates. Children are rendered as a popup.
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
<Marker lat={35.6812} lng={139.7671} color="red">
|
|
85
|
+
<p>Popup content</p>
|
|
86
|
+
</Marker>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
| Prop | Type | Description |
|
|
90
|
+
|------|------|-------------|
|
|
91
|
+
| `lat` | `number` | Latitude (required) |
|
|
92
|
+
| `lng` | `number` | Longitude (required) |
|
|
93
|
+
| `color` | `string` | Marker color (changing recreates the marker) |
|
|
94
|
+
| `openPopup` | `boolean` | Show the popup on mount / toggle open state when changed |
|
|
95
|
+
| `children` | `ReactNode` | Popup content |
|
|
96
|
+
|
|
97
|
+
### `<Popup>`
|
|
98
|
+
|
|
99
|
+
Displays a standalone popup at the given coordinates.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
<Popup lat={35.6812} lng={139.7671} onClose={() => console.log('closed')}>
|
|
103
|
+
<p>Content</p>
|
|
104
|
+
</Popup>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
| Prop | Type | Description |
|
|
108
|
+
|------|------|-------------|
|
|
109
|
+
| `lat` | `number` | Latitude (required) |
|
|
110
|
+
| `lng` | `number` | Longitude (required) |
|
|
111
|
+
| `onClose` | `() => void` | Callback when popup is closed |
|
|
112
|
+
| `children` | `ReactNode` | Popup content |
|
|
113
|
+
|
|
114
|
+
### `<Source>` / `<Layer>`
|
|
115
|
+
|
|
116
|
+
Declaratively add MapLibre sources and layers. Nesting `<Layer>` inside `<Source>` automatically inherits the source ID.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
<Source id="my-source" type="geojson" data={geojson}>
|
|
120
|
+
<Layer
|
|
121
|
+
id="my-layer"
|
|
122
|
+
type="circle"
|
|
123
|
+
paint={{ 'circle-radius': 6, 'circle-color': '#007cbf' }}
|
|
124
|
+
/>
|
|
125
|
+
</Source>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
`<Layer>` props match `LayerSpecification` from MapLibre GL, plus `beforeId` for insertion order.
|
|
129
|
+
|
|
130
|
+
### `useMap()`
|
|
131
|
+
|
|
132
|
+
Hook to access the map instance from `MapContext`. Must be used inside `<Map>`.
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
import { useMap } from '@geolonia/maps-react';
|
|
136
|
+
|
|
137
|
+
function ZoomDisplay() {
|
|
138
|
+
const map = useMap();
|
|
139
|
+
return <div>Zoom: {map.getZoom().toFixed(1)}</div>;
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### `useSourceId()`
|
|
144
|
+
|
|
145
|
+
Hook to access the parent `<Source>` ID from `SourceContext`. Useful for custom layer components.
|
|
146
|
+
|
|
147
|
+
## Development
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npm install
|
|
151
|
+
npm run build # ESM + CJS + DTS
|
|
152
|
+
npm run test # Vitest unit tests
|
|
153
|
+
npm run test:coverage # Vitest with coverage report
|
|
154
|
+
npm run e2e # Playwright E2E tests
|
|
155
|
+
npm run lint # Biome
|
|
156
|
+
npm run dev # Vite dev server (example/)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geolonia/maps-react",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@geolonia/maps-core": "^0.3.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": ">=18",
|
|
23
|
+
"react-dom": ">=18"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@biomejs/biome": "^2.4.8",
|
|
27
|
+
"@playwright/test": "^1.58.2",
|
|
28
|
+
"@testing-library/react": "^16.3.2",
|
|
29
|
+
"@types/react": "^18",
|
|
30
|
+
"@types/react-dom": "^18",
|
|
31
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
32
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
33
|
+
"jsdom": "^29.0.1",
|
|
34
|
+
"maplibre-gl": "5.7.0",
|
|
35
|
+
"react": "^18",
|
|
36
|
+
"react-dom": "^18",
|
|
37
|
+
"tsup": "^8",
|
|
38
|
+
"typescript": "^5.8",
|
|
39
|
+
"vite": "^7.3.2",
|
|
40
|
+
"vitest": "^4.1.1"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --external react --external react-dom --external maplibre-gl",
|
|
44
|
+
"dev": "vite --config vite.config.ts",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"test:watch": "vitest",
|
|
47
|
+
"test:coverage": "vitest run --coverage",
|
|
48
|
+
"e2e": "playwright test",
|
|
49
|
+
"lint": "biome check src/ test/ e2e/ example/",
|
|
50
|
+
"lint:fix": "biome check --write src/ test/ e2e/ example/"
|
|
51
|
+
},
|
|
52
|
+
"license": "MIT"
|
|
53
|
+
}
|