@object-ui/plugin-map 0.3.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/LICENSE +21 -0
- package/README.md +276 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +461 -0
- package/dist/index.umd.cjs +6 -0
- package/dist/src/ObjectMap.d.ts +12 -0
- package/dist/src/ObjectMap.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/package.json +52 -0
- package/src/ObjectMap.tsx +400 -0
- package/src/index.tsx +29 -0
- package/tsconfig.json +18 -0
- package/vite.config.ts +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ObjectQL
|
|
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,276 @@
|
|
|
1
|
+
# @object-ui/plugin-map
|
|
2
|
+
|
|
3
|
+
Map visualization plugin for Object UI - Display geographic data with interactive maps.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Interactive Maps** - Zoomable, pannable map visualization
|
|
8
|
+
- **Markers** - Add markers with custom icons and popups
|
|
9
|
+
- **Layers** - Multiple map layers support
|
|
10
|
+
- **Geolocation** - User location detection
|
|
11
|
+
- **Customizable** - Tailwind CSS styling support
|
|
12
|
+
- **Responsive** - Mobile-friendly map controls
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @object-ui/plugin-map
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Automatic Registration (Side-Effect Import)
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// In your app entry point (e.g., App.tsx or main.tsx)
|
|
26
|
+
import '@object-ui/plugin-map';
|
|
27
|
+
|
|
28
|
+
// Now you can use map types in your schemas
|
|
29
|
+
const schema = {
|
|
30
|
+
type: 'map',
|
|
31
|
+
center: { lat: 37.7749, lng: -122.4194 },
|
|
32
|
+
zoom: 12,
|
|
33
|
+
markers: [
|
|
34
|
+
{ lat: 37.7749, lng: -122.4194, label: 'San Francisco' }
|
|
35
|
+
]
|
|
36
|
+
};
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Manual Registration
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { mapComponents } from '@object-ui/plugin-map';
|
|
43
|
+
import { ComponentRegistry } from '@object-ui/core';
|
|
44
|
+
|
|
45
|
+
// Register map components
|
|
46
|
+
Object.entries(mapComponents).forEach(([type, component]) => {
|
|
47
|
+
ComponentRegistry.register(type, component);
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Schema API
|
|
52
|
+
|
|
53
|
+
### Map
|
|
54
|
+
|
|
55
|
+
Display an interactive map:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
{
|
|
59
|
+
type: 'map',
|
|
60
|
+
center: { lat: number, lng: number },
|
|
61
|
+
zoom?: number, // Default: 10
|
|
62
|
+
markers?: MapMarker[],
|
|
63
|
+
layers?: MapLayer[],
|
|
64
|
+
height?: number | string,
|
|
65
|
+
onMarkerClick?: (marker) => void,
|
|
66
|
+
className?: string
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Map Marker
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
interface MapMarker {
|
|
74
|
+
lat: number;
|
|
75
|
+
lng: number;
|
|
76
|
+
label?: string;
|
|
77
|
+
icon?: string; // Icon URL or name
|
|
78
|
+
popup?: string | ReactNode;
|
|
79
|
+
color?: string; // Marker color
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Examples
|
|
84
|
+
|
|
85
|
+
### Basic Map
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const schema = {
|
|
89
|
+
type: 'map',
|
|
90
|
+
center: { lat: 40.7128, lng: -74.0060 },
|
|
91
|
+
zoom: 13,
|
|
92
|
+
height: 500,
|
|
93
|
+
markers: [
|
|
94
|
+
{
|
|
95
|
+
lat: 40.7128,
|
|
96
|
+
lng: -74.0060,
|
|
97
|
+
label: 'New York City',
|
|
98
|
+
popup: 'The Big Apple'
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Multiple Markers
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
const schema = {
|
|
108
|
+
type: 'map',
|
|
109
|
+
center: { lat: 37.7749, lng: -122.4194 },
|
|
110
|
+
zoom: 10,
|
|
111
|
+
markers: [
|
|
112
|
+
{
|
|
113
|
+
lat: 37.7749,
|
|
114
|
+
lng: -122.4194,
|
|
115
|
+
label: 'San Francisco',
|
|
116
|
+
color: 'red',
|
|
117
|
+
popup: 'Golden Gate Bridge'
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
lat: 37.8044,
|
|
121
|
+
lng: -122.2712,
|
|
122
|
+
label: 'Oakland',
|
|
123
|
+
color: 'blue',
|
|
124
|
+
popup: 'Port of Oakland'
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
lat: 37.3382,
|
|
128
|
+
lng: -121.8863,
|
|
129
|
+
label: 'San Jose',
|
|
130
|
+
color: 'green',
|
|
131
|
+
popup: 'Silicon Valley'
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
};
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Interactive Map
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
const schema = {
|
|
141
|
+
type: 'map',
|
|
142
|
+
center: { lat: 51.5074, lng: -0.1278 },
|
|
143
|
+
zoom: 12,
|
|
144
|
+
markers: [/* markers */],
|
|
145
|
+
onMarkerClick: (marker) => {
|
|
146
|
+
console.log('Marker clicked:', marker);
|
|
147
|
+
// Show marker details
|
|
148
|
+
},
|
|
149
|
+
onMapClick: (coordinates) => {
|
|
150
|
+
console.log('Map clicked at:', coordinates);
|
|
151
|
+
// Add new marker
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Map with Data Binding
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
const schema = {
|
|
160
|
+
type: 'map',
|
|
161
|
+
center: { lat: 37.7749, lng: -122.4194 },
|
|
162
|
+
zoom: 10,
|
|
163
|
+
markers: '${data.locations.map(loc => ({ lat: loc.latitude, lng: loc.longitude, label: loc.name }))}',
|
|
164
|
+
onMarkerClick: (marker) => {
|
|
165
|
+
// Handle marker click
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Integration with ObjectQL
|
|
171
|
+
|
|
172
|
+
Connect map to ObjectStack data sources:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import { createObjectStackAdapter } from '@object-ui/data-objectstack';
|
|
176
|
+
|
|
177
|
+
const dataSource = createObjectStackAdapter({
|
|
178
|
+
baseUrl: 'https://api.example.com',
|
|
179
|
+
token: 'your-auth-token'
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const schema = {
|
|
183
|
+
type: 'object-map',
|
|
184
|
+
dataSource,
|
|
185
|
+
object: 'locations',
|
|
186
|
+
latField: 'latitude',
|
|
187
|
+
lngField: 'longitude',
|
|
188
|
+
labelField: 'name',
|
|
189
|
+
popupField: 'description',
|
|
190
|
+
center: { lat: 37.7749, lng: -122.4194 },
|
|
191
|
+
zoom: 10
|
|
192
|
+
};
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Map Features
|
|
196
|
+
|
|
197
|
+
### Custom Markers
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
const schema = {
|
|
201
|
+
type: 'map',
|
|
202
|
+
markers: [
|
|
203
|
+
{
|
|
204
|
+
lat: 40.7128,
|
|
205
|
+
lng: -74.0060,
|
|
206
|
+
icon: '/custom-marker.png',
|
|
207
|
+
popup: {
|
|
208
|
+
type: 'card',
|
|
209
|
+
title: 'Location Details',
|
|
210
|
+
body: 'Custom popup content'
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
};
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Geolocation
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
const schema = {
|
|
221
|
+
type: 'map',
|
|
222
|
+
useGeolocation: true, // Center map on user's location
|
|
223
|
+
zoom: 15,
|
|
224
|
+
markers: []
|
|
225
|
+
};
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Map Layers
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
const schema = {
|
|
232
|
+
type: 'map',
|
|
233
|
+
center: { lat: 37.7749, lng: -122.4194 },
|
|
234
|
+
layers: [
|
|
235
|
+
{ type: 'heatmap', data: [/* heatmap data */] },
|
|
236
|
+
{ type: 'polygon', coordinates: [/* polygon coordinates */], color: 'rgba(255, 0, 0, 0.3)' }
|
|
237
|
+
]
|
|
238
|
+
};
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## TypeScript Support
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import type { MapSchema, MapMarker } from '@object-ui/plugin-map';
|
|
245
|
+
|
|
246
|
+
const marker: MapMarker = {
|
|
247
|
+
lat: 37.7749,
|
|
248
|
+
lng: -122.4194,
|
|
249
|
+
label: 'San Francisco',
|
|
250
|
+
color: 'red'
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const map: MapSchema = {
|
|
254
|
+
type: 'map',
|
|
255
|
+
center: { lat: 37.7749, lng: -122.4194 },
|
|
256
|
+
zoom: 12,
|
|
257
|
+
markers: [marker]
|
|
258
|
+
};
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Customization
|
|
262
|
+
|
|
263
|
+
Style the map with Tailwind classes:
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
const schema = {
|
|
267
|
+
type: 'map',
|
|
268
|
+
className: 'rounded-lg shadow-xl border-2 border-gray-200',
|
|
269
|
+
height: '600px',
|
|
270
|
+
center: { lat: 37.7749, lng: -122.4194 }
|
|
271
|
+
};
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## License
|
|
275
|
+
|
|
276
|
+
MIT
|
package/dist/index.d.ts
ADDED