@more-than-software/mapkit 0.1.0
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/README.md +306 -0
- package/dist/README.md +306 -0
- package/dist/components/MapEffectComposer.d.ts +5 -0
- package/dist/components/MapEffectComposer.d.ts.map +1 -0
- package/dist/components/MapEntity.d.ts +10 -0
- package/dist/components/MapEntity.d.ts.map +1 -0
- package/dist/components/MapScene.d.ts +15 -0
- package/dist/components/MapScene.d.ts.map +1 -0
- package/dist/components/MapViewport.d.ts +10 -0
- package/dist/components/MapViewport.d.ts.map +1 -0
- package/dist/hooks/useMapEvents.d.ts +44 -0
- package/dist/hooks/useMapEvents.d.ts.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43381 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +48 -0
- package/dist/plugins/TileCreasedNormalsPlugin.d.ts +11 -0
- package/dist/plugins/TileCreasedNormalsPlugin.d.ts.map +1 -0
- package/dist/src/components/MapEffectComposer.tsx +39 -0
- package/dist/src/components/MapEntity.tsx +98 -0
- package/dist/src/components/MapScene.tsx +138 -0
- package/dist/src/components/MapViewport.tsx +82 -0
- package/dist/src/hooks/useMapEvents.ts +211 -0
- package/dist/src/index.ts +55 -0
- package/dist/src/plugins/TileCreasedNormalsPlugin.ts +64 -0
- package/dist/src/utils/camera.ts +60 -0
- package/dist/src/utils/flyTo.ts +118 -0
- package/dist/src/utils/presets.ts +63 -0
- package/dist/utils/camera.d.ts +12 -0
- package/dist/utils/camera.d.ts.map +1 -0
- package/dist/utils/flyTo.d.ts +13 -0
- package/dist/utils/flyTo.d.ts.map +1 -0
- package/dist/utils/presets.d.ts +14 -0
- package/dist/utils/presets.d.ts.map +1 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
# @more-than-software/mapkit
|
|
2
|
+
|
|
3
|
+
A React component library for rendering interactive 3D maps using Google 3D Tiles, React Three Fiber, and Three.js.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🌍 Interactive 3D globe rendering with Google Maps 3D Tiles
|
|
8
|
+
- 🎨 Atmospheric effects and cloud rendering
|
|
9
|
+
- 🎯 Camera controls and fly-to animations
|
|
10
|
+
- 📍 Entity placement (models and billboards) at geodetic coordinates
|
|
11
|
+
- 🎣 Event hooks for clicks, hover, camera changes, and tile loading
|
|
12
|
+
- ⚡ Built on React Three Fiber for optimal performance
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- React 19.0.0 or higher
|
|
17
|
+
- React DOM 19.0.0 or higher
|
|
18
|
+
- Three.js 0.182.0 or higher
|
|
19
|
+
- A Google Maps API key with 3D Tiles enabled
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @more-than-software/mapkit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Peer Dependencies
|
|
28
|
+
|
|
29
|
+
This package requires the following peer dependencies. Install them in your project:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install react react-dom three postprocessing @react-three/fiber @react-three/drei @react-three/postprocessing 3d-tiles-renderer motion react-merge-refs tiny-invariant
|
|
33
|
+
|
|
34
|
+
npm install @takram/three-geospatial @takram/three-atmosphere @takram/three-clouds @takram/three-geospatial-effects
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { Canvas } from '@react-three/fiber'
|
|
41
|
+
import { MapScene, MapEntity } from '@more-than-software/mapkit'
|
|
42
|
+
|
|
43
|
+
function App() {
|
|
44
|
+
return (
|
|
45
|
+
<Canvas>
|
|
46
|
+
<MapScene apiKey="YOUR_GOOGLE_MAPS_API_KEY">
|
|
47
|
+
<MapEntity
|
|
48
|
+
id="marker-1"
|
|
49
|
+
type="billboard"
|
|
50
|
+
latitude={37.7749}
|
|
51
|
+
longitude={-122.4194}
|
|
52
|
+
url="/marker.png"
|
|
53
|
+
/>
|
|
54
|
+
</MapScene>
|
|
55
|
+
</Canvas>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Components
|
|
61
|
+
|
|
62
|
+
### MapScene
|
|
63
|
+
|
|
64
|
+
The main scene component that sets up the 3D map environment with atmosphere, lighting, and post-processing effects.
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { MapScene } from '@more-than-software/mapkit'
|
|
68
|
+
|
|
69
|
+
<MapScene
|
|
70
|
+
apiKey="YOUR_API_KEY"
|
|
71
|
+
enableClouds={true}
|
|
72
|
+
enableAerialPerspective={true}
|
|
73
|
+
enableToneMapping={true}
|
|
74
|
+
cloudsCoverage={0.3}
|
|
75
|
+
exposure={10}
|
|
76
|
+
correctAltitude={true}
|
|
77
|
+
correctGeometricError={true}
|
|
78
|
+
onLoadError={() => console.error('Failed to load tiles')}
|
|
79
|
+
>
|
|
80
|
+
{/* Your map entities and other components */}
|
|
81
|
+
</MapScene>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### Props
|
|
85
|
+
|
|
86
|
+
- `apiKey` (string, required): Your Google Maps API key
|
|
87
|
+
- `children` (ReactNode, optional): Child components to render
|
|
88
|
+
- `enableClouds` (boolean, default: `false`): Enable cloud rendering
|
|
89
|
+
- `enableAerialPerspective` (boolean, default: `true`): Enable atmospheric perspective
|
|
90
|
+
- `enableToneMapping` (boolean, default: `true`): Enable tone mapping
|
|
91
|
+
- `cloudsCoverage` (number, default: `0.3`): Cloud coverage amount (0-1)
|
|
92
|
+
- `exposure` (number, default: `10`): Scene exposure level
|
|
93
|
+
- `correctAltitude` (boolean, default: `true`): Correct altitude calculations
|
|
94
|
+
- `correctGeometricError` (boolean, default: `true`): Correct geometric error
|
|
95
|
+
- `onLoadError` (function, optional): Callback when tile loading fails
|
|
96
|
+
|
|
97
|
+
### MapViewport
|
|
98
|
+
|
|
99
|
+
Lower-level component that handles the 3D Tiles rendering. Typically used internally by `MapScene`, but can be used directly for custom setups.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { MapViewport } from '@more-than-software/mapkit'
|
|
103
|
+
|
|
104
|
+
<MapViewport
|
|
105
|
+
apiKey="YOUR_API_KEY"
|
|
106
|
+
onLoadError={() => console.error('Failed to load tiles')}
|
|
107
|
+
>
|
|
108
|
+
{/* Custom controls and content */}
|
|
109
|
+
</MapViewport>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### MapEntity
|
|
113
|
+
|
|
114
|
+
Renders entities (models or billboards) at specific geodetic coordinates.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { MapEntity } from '@more-than-software/mapkit'
|
|
118
|
+
|
|
119
|
+
// Render a 3D model
|
|
120
|
+
<MapEntity
|
|
121
|
+
id="building-1"
|
|
122
|
+
type="model"
|
|
123
|
+
latitude={37.7749}
|
|
124
|
+
longitude={-122.4194}
|
|
125
|
+
altitude={0}
|
|
126
|
+
url="/models/building.glb"
|
|
127
|
+
rotation={[0, Math.PI / 4, 0]}
|
|
128
|
+
scale={1.0}
|
|
129
|
+
/>
|
|
130
|
+
|
|
131
|
+
// Render a billboard sprite
|
|
132
|
+
<MapEntity
|
|
133
|
+
id="marker-1"
|
|
134
|
+
type="billboard"
|
|
135
|
+
latitude={37.7749}
|
|
136
|
+
longitude={-122.4194}
|
|
137
|
+
altitude={100}
|
|
138
|
+
url="/markers/pin.png"
|
|
139
|
+
scale={2.0}
|
|
140
|
+
/>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### Props
|
|
144
|
+
|
|
145
|
+
- `id` (string, required): Unique identifier for the entity
|
|
146
|
+
- `type` (`'model' | 'billboard'`, required): Type of entity to render
|
|
147
|
+
- `latitude` (number, required): Latitude in degrees
|
|
148
|
+
- `longitude` (number, required): Longitude in degrees
|
|
149
|
+
- `altitude` (number, default: `0`): Altitude in meters
|
|
150
|
+
- `url` (string, optional): URL to model (GLB) or image (for billboards)
|
|
151
|
+
- `rotation` (`[number, number, number]`, optional): Rotation in radians [x, y, z]
|
|
152
|
+
- `scale` (number, default: `1`): Scale factor
|
|
153
|
+
- `metadata` (object, optional): Custom metadata
|
|
154
|
+
- `children` (ReactNode, optional): Additional content to render with the entity
|
|
155
|
+
|
|
156
|
+
## Hooks
|
|
157
|
+
|
|
158
|
+
### useMapClick
|
|
159
|
+
|
|
160
|
+
Handle click events on the map surface.
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
import { useMapClick } from '@more-than-software/mapkit'
|
|
164
|
+
import { useRef } from 'react'
|
|
165
|
+
|
|
166
|
+
const tilesRef = useRef(null)
|
|
167
|
+
|
|
168
|
+
const { handleClick } = useMapClick(tilesRef, (event) => {
|
|
169
|
+
console.log('Clicked at:', event.latlng)
|
|
170
|
+
console.log('Screen point:', event.point)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
// Attach to canvas element
|
|
174
|
+
<canvas onClick={handleClick} />
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### useMapHover
|
|
178
|
+
|
|
179
|
+
Handle hover events on the map surface.
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { useMapHover } from '@more-than-software/mapkit'
|
|
183
|
+
|
|
184
|
+
const { handleMouseMove, handleMouseLeave, hoveredLatLng } = useMapHover(
|
|
185
|
+
tilesRef,
|
|
186
|
+
(event) => {
|
|
187
|
+
if (event.latlng) {
|
|
188
|
+
console.log('Hovering at:', event.latlng)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
<canvas
|
|
194
|
+
onMouseMove={handleMouseMove}
|
|
195
|
+
onMouseLeave={handleMouseLeave}
|
|
196
|
+
/>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### useMapCameraChange
|
|
200
|
+
|
|
201
|
+
Listen to camera position and orientation changes.
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
import { useMapCameraChange } from '@more-than-software/mapkit'
|
|
205
|
+
|
|
206
|
+
const { currentView } = useMapCameraChange((view) => {
|
|
207
|
+
console.log('Camera view:', view)
|
|
208
|
+
// view contains: latitude, longitude, heading, pitch, distance, fov
|
|
209
|
+
})
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### useMapTileLoad
|
|
213
|
+
|
|
214
|
+
Monitor when tiles have finished loading.
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
import { useMapTileLoad } from '@more-than-software/mapkit'
|
|
218
|
+
|
|
219
|
+
const { tilesLoaded } = useMapTileLoad(tilesRef, () => {
|
|
220
|
+
console.log('Tiles loaded!')
|
|
221
|
+
})
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Utilities
|
|
225
|
+
|
|
226
|
+
### Camera Control
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
import { setCameraView, getCameraView } from '@more-than-software/mapkit'
|
|
230
|
+
import { useThree } from '@react-three/fiber'
|
|
231
|
+
|
|
232
|
+
const { camera } = useThree()
|
|
233
|
+
|
|
234
|
+
// Set camera to a specific view
|
|
235
|
+
setCameraView(camera, {
|
|
236
|
+
latitude: 37.7749,
|
|
237
|
+
longitude: -122.4194,
|
|
238
|
+
heading: 0,
|
|
239
|
+
pitch: Math.PI / 4,
|
|
240
|
+
distance: 10000,
|
|
241
|
+
fov: 50
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
// Get current camera view
|
|
245
|
+
const view = getCameraView(camera)
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Fly To Animation
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
import { flyTo } from '@more-than-software/mapkit'
|
|
252
|
+
import { useThree } from '@react-three/fiber'
|
|
253
|
+
|
|
254
|
+
const { camera } = useThree()
|
|
255
|
+
|
|
256
|
+
flyTo(camera, {
|
|
257
|
+
latitude: 40.7128,
|
|
258
|
+
longitude: -74.0060,
|
|
259
|
+
heading: 0,
|
|
260
|
+
pitch: Math.PI / 6,
|
|
261
|
+
distance: 5000
|
|
262
|
+
}, {
|
|
263
|
+
duration: 2000 // milliseconds
|
|
264
|
+
})
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Camera Presets
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
import { createPreset, getPreset, commonPresets } from '@more-than-software/mapkit'
|
|
271
|
+
|
|
272
|
+
// Use a common preset
|
|
273
|
+
const view = getPreset(commonPresets.overview)
|
|
274
|
+
|
|
275
|
+
// Create a custom preset
|
|
276
|
+
const customPreset = createPreset({
|
|
277
|
+
latitude: 37.7749,
|
|
278
|
+
longitude: -122.4194,
|
|
279
|
+
heading: 0,
|
|
280
|
+
pitch: Math.PI / 4,
|
|
281
|
+
distance: 10000
|
|
282
|
+
})
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Types
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
import type {
|
|
289
|
+
LatLng,
|
|
290
|
+
CameraView,
|
|
291
|
+
MapEntity,
|
|
292
|
+
MapViewportProps,
|
|
293
|
+
MapSceneProps,
|
|
294
|
+
MapEntityProps,
|
|
295
|
+
MapClickEvent,
|
|
296
|
+
MapHoverEvent
|
|
297
|
+
} from '@more-than-software/mapkit'
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## License
|
|
301
|
+
|
|
302
|
+
MIT
|
|
303
|
+
|
|
304
|
+
## Repository
|
|
305
|
+
|
|
306
|
+
https://github.com/more-than-software/citykit
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
# @more-than-software/mapkit
|
|
2
|
+
|
|
3
|
+
A React component library for rendering interactive 3D maps using Google 3D Tiles, React Three Fiber, and Three.js.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🌍 Interactive 3D globe rendering with Google Maps 3D Tiles
|
|
8
|
+
- 🎨 Atmospheric effects and cloud rendering
|
|
9
|
+
- 🎯 Camera controls and fly-to animations
|
|
10
|
+
- 📍 Entity placement (models and billboards) at geodetic coordinates
|
|
11
|
+
- 🎣 Event hooks for clicks, hover, camera changes, and tile loading
|
|
12
|
+
- ⚡ Built on React Three Fiber for optimal performance
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- React 19.0.0 or higher
|
|
17
|
+
- React DOM 19.0.0 or higher
|
|
18
|
+
- Three.js 0.182.0 or higher
|
|
19
|
+
- A Google Maps API key with 3D Tiles enabled
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @more-than-software/mapkit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Peer Dependencies
|
|
28
|
+
|
|
29
|
+
This package requires the following peer dependencies. Install them in your project:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install react react-dom three postprocessing @react-three/fiber @react-three/drei @react-three/postprocessing 3d-tiles-renderer motion react-merge-refs tiny-invariant
|
|
33
|
+
|
|
34
|
+
npm install @takram/three-geospatial @takram/three-atmosphere @takram/three-clouds @takram/three-geospatial-effects
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { Canvas } from '@react-three/fiber'
|
|
41
|
+
import { MapScene, MapEntity } from '@more-than-software/mapkit'
|
|
42
|
+
|
|
43
|
+
function App() {
|
|
44
|
+
return (
|
|
45
|
+
<Canvas>
|
|
46
|
+
<MapScene apiKey="YOUR_GOOGLE_MAPS_API_KEY">
|
|
47
|
+
<MapEntity
|
|
48
|
+
id="marker-1"
|
|
49
|
+
type="billboard"
|
|
50
|
+
latitude={37.7749}
|
|
51
|
+
longitude={-122.4194}
|
|
52
|
+
url="/marker.png"
|
|
53
|
+
/>
|
|
54
|
+
</MapScene>
|
|
55
|
+
</Canvas>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Components
|
|
61
|
+
|
|
62
|
+
### MapScene
|
|
63
|
+
|
|
64
|
+
The main scene component that sets up the 3D map environment with atmosphere, lighting, and post-processing effects.
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { MapScene } from '@more-than-software/mapkit'
|
|
68
|
+
|
|
69
|
+
<MapScene
|
|
70
|
+
apiKey="YOUR_API_KEY"
|
|
71
|
+
enableClouds={true}
|
|
72
|
+
enableAerialPerspective={true}
|
|
73
|
+
enableToneMapping={true}
|
|
74
|
+
cloudsCoverage={0.3}
|
|
75
|
+
exposure={10}
|
|
76
|
+
correctAltitude={true}
|
|
77
|
+
correctGeometricError={true}
|
|
78
|
+
onLoadError={() => console.error('Failed to load tiles')}
|
|
79
|
+
>
|
|
80
|
+
{/* Your map entities and other components */}
|
|
81
|
+
</MapScene>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### Props
|
|
85
|
+
|
|
86
|
+
- `apiKey` (string, required): Your Google Maps API key
|
|
87
|
+
- `children` (ReactNode, optional): Child components to render
|
|
88
|
+
- `enableClouds` (boolean, default: `false`): Enable cloud rendering
|
|
89
|
+
- `enableAerialPerspective` (boolean, default: `true`): Enable atmospheric perspective
|
|
90
|
+
- `enableToneMapping` (boolean, default: `true`): Enable tone mapping
|
|
91
|
+
- `cloudsCoverage` (number, default: `0.3`): Cloud coverage amount (0-1)
|
|
92
|
+
- `exposure` (number, default: `10`): Scene exposure level
|
|
93
|
+
- `correctAltitude` (boolean, default: `true`): Correct altitude calculations
|
|
94
|
+
- `correctGeometricError` (boolean, default: `true`): Correct geometric error
|
|
95
|
+
- `onLoadError` (function, optional): Callback when tile loading fails
|
|
96
|
+
|
|
97
|
+
### MapViewport
|
|
98
|
+
|
|
99
|
+
Lower-level component that handles the 3D Tiles rendering. Typically used internally by `MapScene`, but can be used directly for custom setups.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { MapViewport } from '@more-than-software/mapkit'
|
|
103
|
+
|
|
104
|
+
<MapViewport
|
|
105
|
+
apiKey="YOUR_API_KEY"
|
|
106
|
+
onLoadError={() => console.error('Failed to load tiles')}
|
|
107
|
+
>
|
|
108
|
+
{/* Custom controls and content */}
|
|
109
|
+
</MapViewport>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### MapEntity
|
|
113
|
+
|
|
114
|
+
Renders entities (models or billboards) at specific geodetic coordinates.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { MapEntity } from '@more-than-software/mapkit'
|
|
118
|
+
|
|
119
|
+
// Render a 3D model
|
|
120
|
+
<MapEntity
|
|
121
|
+
id="building-1"
|
|
122
|
+
type="model"
|
|
123
|
+
latitude={37.7749}
|
|
124
|
+
longitude={-122.4194}
|
|
125
|
+
altitude={0}
|
|
126
|
+
url="/models/building.glb"
|
|
127
|
+
rotation={[0, Math.PI / 4, 0]}
|
|
128
|
+
scale={1.0}
|
|
129
|
+
/>
|
|
130
|
+
|
|
131
|
+
// Render a billboard sprite
|
|
132
|
+
<MapEntity
|
|
133
|
+
id="marker-1"
|
|
134
|
+
type="billboard"
|
|
135
|
+
latitude={37.7749}
|
|
136
|
+
longitude={-122.4194}
|
|
137
|
+
altitude={100}
|
|
138
|
+
url="/markers/pin.png"
|
|
139
|
+
scale={2.0}
|
|
140
|
+
/>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### Props
|
|
144
|
+
|
|
145
|
+
- `id` (string, required): Unique identifier for the entity
|
|
146
|
+
- `type` (`'model' | 'billboard'`, required): Type of entity to render
|
|
147
|
+
- `latitude` (number, required): Latitude in degrees
|
|
148
|
+
- `longitude` (number, required): Longitude in degrees
|
|
149
|
+
- `altitude` (number, default: `0`): Altitude in meters
|
|
150
|
+
- `url` (string, optional): URL to model (GLB) or image (for billboards)
|
|
151
|
+
- `rotation` (`[number, number, number]`, optional): Rotation in radians [x, y, z]
|
|
152
|
+
- `scale` (number, default: `1`): Scale factor
|
|
153
|
+
- `metadata` (object, optional): Custom metadata
|
|
154
|
+
- `children` (ReactNode, optional): Additional content to render with the entity
|
|
155
|
+
|
|
156
|
+
## Hooks
|
|
157
|
+
|
|
158
|
+
### useMapClick
|
|
159
|
+
|
|
160
|
+
Handle click events on the map surface.
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
import { useMapClick } from '@more-than-software/mapkit'
|
|
164
|
+
import { useRef } from 'react'
|
|
165
|
+
|
|
166
|
+
const tilesRef = useRef(null)
|
|
167
|
+
|
|
168
|
+
const { handleClick } = useMapClick(tilesRef, (event) => {
|
|
169
|
+
console.log('Clicked at:', event.latlng)
|
|
170
|
+
console.log('Screen point:', event.point)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
// Attach to canvas element
|
|
174
|
+
<canvas onClick={handleClick} />
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### useMapHover
|
|
178
|
+
|
|
179
|
+
Handle hover events on the map surface.
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { useMapHover } from '@more-than-software/mapkit'
|
|
183
|
+
|
|
184
|
+
const { handleMouseMove, handleMouseLeave, hoveredLatLng } = useMapHover(
|
|
185
|
+
tilesRef,
|
|
186
|
+
(event) => {
|
|
187
|
+
if (event.latlng) {
|
|
188
|
+
console.log('Hovering at:', event.latlng)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
<canvas
|
|
194
|
+
onMouseMove={handleMouseMove}
|
|
195
|
+
onMouseLeave={handleMouseLeave}
|
|
196
|
+
/>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### useMapCameraChange
|
|
200
|
+
|
|
201
|
+
Listen to camera position and orientation changes.
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
import { useMapCameraChange } from '@more-than-software/mapkit'
|
|
205
|
+
|
|
206
|
+
const { currentView } = useMapCameraChange((view) => {
|
|
207
|
+
console.log('Camera view:', view)
|
|
208
|
+
// view contains: latitude, longitude, heading, pitch, distance, fov
|
|
209
|
+
})
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### useMapTileLoad
|
|
213
|
+
|
|
214
|
+
Monitor when tiles have finished loading.
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
import { useMapTileLoad } from '@more-than-software/mapkit'
|
|
218
|
+
|
|
219
|
+
const { tilesLoaded } = useMapTileLoad(tilesRef, () => {
|
|
220
|
+
console.log('Tiles loaded!')
|
|
221
|
+
})
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Utilities
|
|
225
|
+
|
|
226
|
+
### Camera Control
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
import { setCameraView, getCameraView } from '@more-than-software/mapkit'
|
|
230
|
+
import { useThree } from '@react-three/fiber'
|
|
231
|
+
|
|
232
|
+
const { camera } = useThree()
|
|
233
|
+
|
|
234
|
+
// Set camera to a specific view
|
|
235
|
+
setCameraView(camera, {
|
|
236
|
+
latitude: 37.7749,
|
|
237
|
+
longitude: -122.4194,
|
|
238
|
+
heading: 0,
|
|
239
|
+
pitch: Math.PI / 4,
|
|
240
|
+
distance: 10000,
|
|
241
|
+
fov: 50
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
// Get current camera view
|
|
245
|
+
const view = getCameraView(camera)
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Fly To Animation
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
import { flyTo } from '@more-than-software/mapkit'
|
|
252
|
+
import { useThree } from '@react-three/fiber'
|
|
253
|
+
|
|
254
|
+
const { camera } = useThree()
|
|
255
|
+
|
|
256
|
+
flyTo(camera, {
|
|
257
|
+
latitude: 40.7128,
|
|
258
|
+
longitude: -74.0060,
|
|
259
|
+
heading: 0,
|
|
260
|
+
pitch: Math.PI / 6,
|
|
261
|
+
distance: 5000
|
|
262
|
+
}, {
|
|
263
|
+
duration: 2000 // milliseconds
|
|
264
|
+
})
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Camera Presets
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
import { createPreset, getPreset, commonPresets } from '@more-than-software/mapkit'
|
|
271
|
+
|
|
272
|
+
// Use a common preset
|
|
273
|
+
const view = getPreset(commonPresets.overview)
|
|
274
|
+
|
|
275
|
+
// Create a custom preset
|
|
276
|
+
const customPreset = createPreset({
|
|
277
|
+
latitude: 37.7749,
|
|
278
|
+
longitude: -122.4194,
|
|
279
|
+
heading: 0,
|
|
280
|
+
pitch: Math.PI / 4,
|
|
281
|
+
distance: 10000
|
|
282
|
+
})
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Types
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
import type {
|
|
289
|
+
LatLng,
|
|
290
|
+
CameraView,
|
|
291
|
+
MapEntity,
|
|
292
|
+
MapViewportProps,
|
|
293
|
+
MapSceneProps,
|
|
294
|
+
MapEntityProps,
|
|
295
|
+
MapClickEvent,
|
|
296
|
+
MapHoverEvent
|
|
297
|
+
} from '@more-than-software/mapkit'
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## License
|
|
301
|
+
|
|
302
|
+
MIT
|
|
303
|
+
|
|
304
|
+
## Repository
|
|
305
|
+
|
|
306
|
+
https://github.com/more-than-software/citykit
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EffectComposerProps } from '@react-three/postprocessing';
|
|
2
|
+
import { EffectComposer as EffectComposerImpl } from 'postprocessing';
|
|
3
|
+
import { FC, RefAttributes } from 'react';
|
|
4
|
+
export declare const MapEffectComposer: FC<EffectComposerProps & RefAttributes<EffectComposerImpl>>;
|
|
5
|
+
//# sourceMappingURL=MapEffectComposer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapEffectComposer.d.ts","sourceRoot":"","sources":["../../src/components/MapEffectComposer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAEL,KAAK,cAAc,IAAI,kBAAkB,EAC1C,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAA2B,KAAK,EAAE,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAA;AAQ5E,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAChC,mBAAmB,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAqBxD,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { MapEntity as MapEntityType } from '../index';
|
|
3
|
+
export interface MapEntityProps extends MapEntityType {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* MapEntity component - renders entities at geodetic coordinates
|
|
8
|
+
*/
|
|
9
|
+
export declare const MapEntity: FC<MapEntityProps>;
|
|
10
|
+
//# sourceMappingURL=MapEntity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapEntity.d.ts","sourceRoot":"","sources":["../../src/components/MapEntity.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIxD,OAAO,KAAK,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AAE1D,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAgDD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAoCxC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
export interface MapSceneProps {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
enableClouds?: boolean;
|
|
6
|
+
enableAerialPerspective?: boolean;
|
|
7
|
+
enableToneMapping?: boolean;
|
|
8
|
+
cloudsCoverage?: number;
|
|
9
|
+
exposure?: number;
|
|
10
|
+
correctAltitude?: boolean;
|
|
11
|
+
correctGeometricError?: boolean;
|
|
12
|
+
onLoadError?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const MapScene: FC<MapSceneProps>;
|
|
15
|
+
//# sourceMappingURL=MapScene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapScene.d.ts","sourceRoot":"","sources":["../../src/components/MapScene.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAyC,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAatF,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;CACzB;AAED,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAuGtC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TilesRenderer as TilesRendererImpl } from '3d-tiles-renderer';
|
|
2
|
+
import { FC, ReactNode, Ref } from 'react';
|
|
3
|
+
export interface MapViewportProps {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
ref?: Ref<TilesRendererImpl>;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
onLoadError?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const MapViewport: FC<MapViewportProps>;
|
|
10
|
+
//# sourceMappingURL=MapViewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapViewport.d.ts","sourceRoot":"","sources":["../../src/components/MapViewport.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAa3E,OAAO,EAAuB,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAA;AAW9E,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAA;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;CACzB;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAkD5C,CAAA"}
|