gistda-sphere-react 1.0.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 +827 -0
- package/dist/index.d.mts +1081 -0
- package/dist/index.d.ts +1081 -0
- package/dist/index.js +2057 -0
- package/dist/index.mjs +2013 -0
- package/package.json +70 -0
- package/src/__tests__/Layer.test.tsx +133 -0
- package/src/__tests__/Marker.test.tsx +183 -0
- package/src/__tests__/SphereContext.test.tsx +120 -0
- package/src/__tests__/SphereMap.test.tsx +240 -0
- package/src/__tests__/geometry.test.tsx +454 -0
- package/src/__tests__/hooks.test.tsx +173 -0
- package/src/__tests__/setup.ts +204 -0
- package/src/__tests__/useMapControls.test.tsx +168 -0
- package/src/__tests__/useOverlays.test.tsx +265 -0
- package/src/__tests__/useRoute.test.tsx +219 -0
- package/src/__tests__/useSearch.test.tsx +205 -0
- package/src/__tests__/useTags.test.tsx +179 -0
- package/src/components/Circle.tsx +189 -0
- package/src/components/Dot.tsx +150 -0
- package/src/components/Layer.tsx +177 -0
- package/src/components/Marker.tsx +204 -0
- package/src/components/Polygon.tsx +223 -0
- package/src/components/Polyline.tsx +211 -0
- package/src/components/Popup.tsx +130 -0
- package/src/components/Rectangle.tsx +194 -0
- package/src/components/SphereMap.tsx +315 -0
- package/src/components/index.ts +18 -0
- package/src/context/MapContext.tsx +41 -0
- package/src/context/SphereContext.tsx +348 -0
- package/src/context/index.ts +15 -0
- package/src/hooks/index.ts +42 -0
- package/src/hooks/useMapEvent.ts +66 -0
- package/src/hooks/useOverlays.ts +278 -0
- package/src/hooks/useRoute.ts +232 -0
- package/src/hooks/useSearch.ts +143 -0
- package/src/hooks/useSphere.ts +18 -0
- package/src/hooks/useTags.ts +129 -0
- package/src/index.ts +124 -0
- package/src/types/index.ts +1 -0
- package/src/types/sphere.ts +671 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1081 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
interface Location {
|
|
5
|
+
lon: number;
|
|
6
|
+
lat: number;
|
|
7
|
+
}
|
|
8
|
+
interface Point {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}
|
|
12
|
+
interface Range {
|
|
13
|
+
min: number;
|
|
14
|
+
max: number;
|
|
15
|
+
}
|
|
16
|
+
interface Bound {
|
|
17
|
+
minLon: number;
|
|
18
|
+
minLat: number;
|
|
19
|
+
maxLon: number;
|
|
20
|
+
maxLat: number;
|
|
21
|
+
}
|
|
22
|
+
interface Size {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
}
|
|
26
|
+
interface Tile {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
z: number;
|
|
30
|
+
}
|
|
31
|
+
interface Icon {
|
|
32
|
+
url?: string;
|
|
33
|
+
urlHD?: string;
|
|
34
|
+
html?: string;
|
|
35
|
+
offset?: Point;
|
|
36
|
+
size?: Size;
|
|
37
|
+
}
|
|
38
|
+
type LayerType = "Vector" | "XYZ" | "WMS" | "WMTS" | "WMTS_REST" | "TMS" | "Tiles3D" | "I3S";
|
|
39
|
+
type BuiltInLayer$1 = "SIMPLE" | "STREETS" | "STREETS_NIGHT" | "HYBRID" | "TRAFFIC" | "IMAGES" | "PM25" | "HOTSPOT" | "FLOOD" | "DROUGHT";
|
|
40
|
+
type FilterType = "Dark" | "Light" | "Protanopia" | "Deuteranopia" | "None";
|
|
41
|
+
type LineStyleType = "Solid" | "Dashed" | "Dot";
|
|
42
|
+
type UiComponentMode = "Full" | "Mobile" | "None";
|
|
43
|
+
type RouteMode = "Traffic" | "Cost" | "Distance" | "Fly";
|
|
44
|
+
type RouteType = "Road" | "Ferry" | "Tollway" | "All";
|
|
45
|
+
type RouteLabelType = "Distance" | "Time" | "Hide";
|
|
46
|
+
type TagType = "WFS" | "OGC";
|
|
47
|
+
interface MapOptions {
|
|
48
|
+
layer?: SphereLayer | string;
|
|
49
|
+
zoom?: number;
|
|
50
|
+
zoomRange?: Range;
|
|
51
|
+
location?: Location;
|
|
52
|
+
placeholder?: HTMLElement;
|
|
53
|
+
ui?: UiComponentMode;
|
|
54
|
+
input?: boolean;
|
|
55
|
+
lastView?: boolean;
|
|
56
|
+
language?: string;
|
|
57
|
+
[key: string]: SphereLayer | string | number | boolean | Range | Location | HTMLElement | UiComponentMode | undefined;
|
|
58
|
+
}
|
|
59
|
+
interface LayerOptions {
|
|
60
|
+
type?: LayerType;
|
|
61
|
+
url?: string;
|
|
62
|
+
zoomRange?: Range;
|
|
63
|
+
source?: Range;
|
|
64
|
+
opacity?: number;
|
|
65
|
+
zIndex?: number;
|
|
66
|
+
bound?: Bound;
|
|
67
|
+
attribution?: string;
|
|
68
|
+
extraQuery?: string;
|
|
69
|
+
id?: string;
|
|
70
|
+
format?: string;
|
|
71
|
+
srs?: string;
|
|
72
|
+
tileMatrixPrefix?: string;
|
|
73
|
+
styles?: string;
|
|
74
|
+
version?: string;
|
|
75
|
+
refresh?: number;
|
|
76
|
+
zoomOffset?: number;
|
|
77
|
+
}
|
|
78
|
+
interface MarkerOptions {
|
|
79
|
+
icon?: Icon;
|
|
80
|
+
title?: string;
|
|
81
|
+
detail?: string;
|
|
82
|
+
popup?: PopupOptions;
|
|
83
|
+
visibleRange?: Range;
|
|
84
|
+
clickable?: boolean;
|
|
85
|
+
draggable?: boolean;
|
|
86
|
+
zIndex?: number;
|
|
87
|
+
rotate?: number;
|
|
88
|
+
}
|
|
89
|
+
interface PopupOptions {
|
|
90
|
+
title?: string;
|
|
91
|
+
detail?: string;
|
|
92
|
+
loadDetail?: (element: HTMLElement) => void;
|
|
93
|
+
html?: string;
|
|
94
|
+
loadHtml?: (element: HTMLElement) => void;
|
|
95
|
+
size?: Size;
|
|
96
|
+
closable?: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface GeometryOptions {
|
|
99
|
+
title?: string;
|
|
100
|
+
detail?: string;
|
|
101
|
+
label?: string;
|
|
102
|
+
labelOptions?: MarkerOptions;
|
|
103
|
+
popup?: PopupOptions;
|
|
104
|
+
visibleRange?: Range;
|
|
105
|
+
lineWidth?: number;
|
|
106
|
+
lineColor?: string;
|
|
107
|
+
fillColor?: string;
|
|
108
|
+
lineStyle?: LineStyleType;
|
|
109
|
+
pivot?: Location | (() => Location);
|
|
110
|
+
clickable?: boolean;
|
|
111
|
+
draggable?: boolean;
|
|
112
|
+
pointer?: boolean;
|
|
113
|
+
zIndex?: number;
|
|
114
|
+
editable?: boolean;
|
|
115
|
+
}
|
|
116
|
+
interface TagOptions {
|
|
117
|
+
source?: string;
|
|
118
|
+
type?: TagType;
|
|
119
|
+
icon?: Icon | "big" | "small";
|
|
120
|
+
visibleRange?: Range;
|
|
121
|
+
label?: Range;
|
|
122
|
+
area?: string;
|
|
123
|
+
dataset?: string;
|
|
124
|
+
name?: string;
|
|
125
|
+
extraQuery?: string;
|
|
126
|
+
version?: string;
|
|
127
|
+
}
|
|
128
|
+
interface SearchOptions {
|
|
129
|
+
area?: string;
|
|
130
|
+
tag?: string;
|
|
131
|
+
span?: string;
|
|
132
|
+
offset?: number;
|
|
133
|
+
limit?: number;
|
|
134
|
+
dataset?: string;
|
|
135
|
+
}
|
|
136
|
+
interface SuggestOptions {
|
|
137
|
+
area?: string;
|
|
138
|
+
offset?: number;
|
|
139
|
+
limit?: number;
|
|
140
|
+
dataset?: string;
|
|
141
|
+
}
|
|
142
|
+
interface AddressOptions {
|
|
143
|
+
limit?: number;
|
|
144
|
+
dataset?: string;
|
|
145
|
+
}
|
|
146
|
+
interface NearPoiOptions {
|
|
147
|
+
span?: number;
|
|
148
|
+
zoom?: number;
|
|
149
|
+
limit?: number;
|
|
150
|
+
}
|
|
151
|
+
type EventName = "ready" | "resize" | "repaint" | "zoom" | "zoomRange" | "location" | "fullscreen" | "rotate" | "pitch" | "toolbarChange" | "drawCreate" | "drawDelete" | "tooltipChange" | "beforeContextmenu" | "contextmenu" | "mousemove" | "click" | "doubleClick" | "wheel" | "drag" | "drop" | "idle" | "layerChange" | "tileLoading" | "tileLoaded" | "overlayChange" | "overlayUpdate" | "overlayClick" | "overlayLoad" | "overlayDrag" | "overlayDrop" | "overlayHover" | "overlayLeave" | "popupClose" | "routeError" | "routeComplete" | "error";
|
|
152
|
+
type EventHandler<T = void> = (data: T) => void | undefined | boolean;
|
|
153
|
+
interface SphereEvent {
|
|
154
|
+
bind<T = unknown>(eventName: EventName, handler: EventHandler<T>): this;
|
|
155
|
+
unbind<T = unknown>(eventName: EventName, handler: EventHandler<T>): this;
|
|
156
|
+
}
|
|
157
|
+
interface SphereLayer {
|
|
158
|
+
name(): string;
|
|
159
|
+
options(): LayerOptions;
|
|
160
|
+
}
|
|
161
|
+
interface SphereLayerCollection {
|
|
162
|
+
language(value?: string): string | this;
|
|
163
|
+
setBase(layer: SphereLayer | object | string): this;
|
|
164
|
+
add(layer: SphereLayer | object, beforeId?: string): this;
|
|
165
|
+
remove(layer: SphereLayer | object): this;
|
|
166
|
+
clear(): this;
|
|
167
|
+
list(): object[];
|
|
168
|
+
size(): number;
|
|
169
|
+
}
|
|
170
|
+
interface SphereOverlay {
|
|
171
|
+
location(geojson?: Location | Location[] | object, animate?: boolean): Location | Location[] | this;
|
|
172
|
+
visibleRange(): Range;
|
|
173
|
+
active(): boolean;
|
|
174
|
+
shift(vector: Location): this;
|
|
175
|
+
distance(overlay: Location | SphereOverlay, language?: string): number | string;
|
|
176
|
+
intersects(overlay: Location | SphereOverlay): boolean;
|
|
177
|
+
contains(overlay: Location | SphereOverlay): boolean;
|
|
178
|
+
within(overlay: Location | SphereOverlay): boolean;
|
|
179
|
+
toJSON(key?: string): object;
|
|
180
|
+
}
|
|
181
|
+
interface SphereMarker extends SphereOverlay {
|
|
182
|
+
popup(): SpherePopup;
|
|
183
|
+
element(): HTMLElement;
|
|
184
|
+
pop(mode?: boolean): this;
|
|
185
|
+
update(newOptions: MarkerOptions): this;
|
|
186
|
+
}
|
|
187
|
+
interface SpherePopup extends SphereOverlay {
|
|
188
|
+
element(): HTMLElement;
|
|
189
|
+
title(value?: string): HTMLElement | this;
|
|
190
|
+
detail(value?: string): HTMLElement | this;
|
|
191
|
+
}
|
|
192
|
+
interface SpherePolyline extends SphereOverlay {
|
|
193
|
+
popup(): SpherePopup;
|
|
194
|
+
pop(mode?: boolean, location?: Location): this;
|
|
195
|
+
pivot(): Location;
|
|
196
|
+
centroid(): Location;
|
|
197
|
+
bound(): Bound;
|
|
198
|
+
update(newOptions: GeometryOptions): this;
|
|
199
|
+
rotate(angle: number): this;
|
|
200
|
+
size(language?: string): number | string;
|
|
201
|
+
union(overlay: SpherePolyline, options?: GeometryOptions): SpherePolyline;
|
|
202
|
+
}
|
|
203
|
+
interface SpherePolygon extends SpherePolyline {
|
|
204
|
+
intersection(overlay: SpherePolygon, options?: GeometryOptions): SpherePolygon;
|
|
205
|
+
difference(overlay: SpherePolygon, options?: GeometryOptions): SpherePolygon;
|
|
206
|
+
split(splitter: SpherePolygon, options?: GeometryOptions): SpherePolygon[];
|
|
207
|
+
}
|
|
208
|
+
interface SphereCircle extends SpherePolyline {
|
|
209
|
+
radius(language?: string): number | string;
|
|
210
|
+
}
|
|
211
|
+
interface SphereDot extends SpherePolyline {
|
|
212
|
+
}
|
|
213
|
+
interface SphereRectangle extends SpherePolygon {
|
|
214
|
+
}
|
|
215
|
+
interface SphereOverlayCollection {
|
|
216
|
+
add(overlay: SphereOverlay): this;
|
|
217
|
+
remove(overlay: SphereOverlay): this;
|
|
218
|
+
load(mode: object): this;
|
|
219
|
+
unload(mode: object): this;
|
|
220
|
+
clear(): this;
|
|
221
|
+
list(): SphereOverlay[];
|
|
222
|
+
size(): number;
|
|
223
|
+
lastOpenPopup(): SpherePopup;
|
|
224
|
+
}
|
|
225
|
+
interface SphereUiControl {
|
|
226
|
+
visible(state?: boolean): boolean | SphereUiControl;
|
|
227
|
+
}
|
|
228
|
+
interface SphereContextMenu {
|
|
229
|
+
enableNearPoi(state?: boolean): boolean | SphereContextMenu;
|
|
230
|
+
enableAddress(state?: boolean): boolean | SphereContextMenu;
|
|
231
|
+
}
|
|
232
|
+
interface SphereKeyboard {
|
|
233
|
+
enable(state?: boolean): boolean | SphereKeyboard;
|
|
234
|
+
}
|
|
235
|
+
interface SphereMouse {
|
|
236
|
+
enable(state?: boolean): boolean | SphereMouse;
|
|
237
|
+
enableClick(state?: boolean): boolean | SphereMouse;
|
|
238
|
+
enableDrag(state?: boolean): boolean | SphereMouse;
|
|
239
|
+
enableWheel(state?: boolean): boolean | SphereMouse;
|
|
240
|
+
}
|
|
241
|
+
interface SphereUiCollection {
|
|
242
|
+
DPad: SphereUiControl;
|
|
243
|
+
Geolocation: SphereUiControl;
|
|
244
|
+
Zoombar: SphereUiControl;
|
|
245
|
+
Toolbar: SphereUiControl;
|
|
246
|
+
LayerSelector: SphereUiControl;
|
|
247
|
+
Fullscreen: SphereUiControl;
|
|
248
|
+
Crosshair: SphereUiControl;
|
|
249
|
+
Scale: SphereUiControl;
|
|
250
|
+
ContextMenu: SphereContextMenu;
|
|
251
|
+
Keyboard: SphereKeyboard;
|
|
252
|
+
Mouse: SphereMouse;
|
|
253
|
+
language(value?: string): string | SphereUiCollection;
|
|
254
|
+
add(control: object): SphereUiCollection;
|
|
255
|
+
remove(control: object): SphereUiCollection;
|
|
256
|
+
lockMap(options?: object): SphereUiCollection;
|
|
257
|
+
}
|
|
258
|
+
interface SphereSearch {
|
|
259
|
+
language(value?: string): string | this;
|
|
260
|
+
placeholder(value?: HTMLElement, options?: object): HTMLElement | this;
|
|
261
|
+
suggest(keyword: string, options?: SuggestOptions): Promise<object>;
|
|
262
|
+
search(keyword: string, options?: SearchOptions): Promise<object>;
|
|
263
|
+
address(location: Location, options?: AddressOptions): Promise<object>;
|
|
264
|
+
nearPoi(location: Location, options?: NearPoiOptions): Promise<object>;
|
|
265
|
+
clear(): this;
|
|
266
|
+
enablePopup(state?: boolean): boolean | this;
|
|
267
|
+
}
|
|
268
|
+
interface SphereTagCollection {
|
|
269
|
+
language(value?: string): string | this;
|
|
270
|
+
set(tag: string | ((tile: Tile) => object[]), options?: TagOptions): this;
|
|
271
|
+
add(tag: string | ((tile: Tile) => object[]), options?: TagOptions): this;
|
|
272
|
+
remove(tag: string): this;
|
|
273
|
+
clear(): this;
|
|
274
|
+
list(): string[];
|
|
275
|
+
size(): number;
|
|
276
|
+
enablePopup(state?: boolean): boolean | this;
|
|
277
|
+
}
|
|
278
|
+
interface SphereRoute {
|
|
279
|
+
language(value?: string): string | this;
|
|
280
|
+
placeholder(value?: HTMLElement): HTMLElement | this;
|
|
281
|
+
enableContextMenu(): this;
|
|
282
|
+
line(type: string, value?: GeometryOptions): GeometryOptions | this;
|
|
283
|
+
auto(state?: boolean): boolean | this;
|
|
284
|
+
mode(value?: RouteMode): RouteMode | this;
|
|
285
|
+
modeOf(index: number, value?: RouteMode): RouteMode | this;
|
|
286
|
+
enableRoute(routeType: RouteType, state?: boolean): boolean | this;
|
|
287
|
+
enableRestrict(routeRestrict: string, state?: boolean): boolean | this;
|
|
288
|
+
label(value?: RouteLabelType): RouteLabelType | this;
|
|
289
|
+
add(destination: SphereMarker | Location, mode?: RouteMode): this;
|
|
290
|
+
insert(index: number, destination: SphereMarker | Location, mode?: RouteMode): this;
|
|
291
|
+
remove(destination: SphereMarker): this;
|
|
292
|
+
removeAt(index: number): this;
|
|
293
|
+
clearDestination(): this;
|
|
294
|
+
clearPath(): this;
|
|
295
|
+
clear(): this;
|
|
296
|
+
list(): SphereMarker[];
|
|
297
|
+
size(): number;
|
|
298
|
+
reverse(): this;
|
|
299
|
+
search(): this;
|
|
300
|
+
distance(format?: boolean): number | string;
|
|
301
|
+
interval(format?: boolean): number | string;
|
|
302
|
+
guide(format?: boolean): object[] | HTMLElement;
|
|
303
|
+
exportRouteLine(options?: GeometryOptions): SpherePolyline;
|
|
304
|
+
}
|
|
305
|
+
interface FlyToOptions {
|
|
306
|
+
center?: Location;
|
|
307
|
+
zoom?: number;
|
|
308
|
+
bearing?: number;
|
|
309
|
+
pitch?: number;
|
|
310
|
+
padding?: {
|
|
311
|
+
top?: number;
|
|
312
|
+
bottom?: number;
|
|
313
|
+
left?: number;
|
|
314
|
+
right?: number;
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
interface SphereMap$1 {
|
|
318
|
+
Event: SphereEvent;
|
|
319
|
+
Layers: SphereLayerCollection;
|
|
320
|
+
Overlays: SphereOverlayCollection;
|
|
321
|
+
Ui: SphereUiCollection;
|
|
322
|
+
Search: SphereSearch;
|
|
323
|
+
Tags: SphereTagCollection;
|
|
324
|
+
Route: SphereRoute;
|
|
325
|
+
Renderer: {
|
|
326
|
+
on(event: string, handler: () => void): void;
|
|
327
|
+
};
|
|
328
|
+
id(): number;
|
|
329
|
+
resize(): this;
|
|
330
|
+
repaint(): this;
|
|
331
|
+
placeholder(): HTMLElement;
|
|
332
|
+
zoom(value?: number | boolean, animate?: boolean): number | this;
|
|
333
|
+
zoomRange(value?: Range): Range | this;
|
|
334
|
+
location(value?: Location, animate?: boolean): Location | this;
|
|
335
|
+
bound(value?: Bound, options?: object): Bound | this;
|
|
336
|
+
move(offset: Point, animate?: boolean): this;
|
|
337
|
+
language(value?: string): string | this;
|
|
338
|
+
rotate(angle?: number, animate?: boolean): number | this;
|
|
339
|
+
pitch(angle?: number): number | this;
|
|
340
|
+
enableFilter(filter?: FilterType | false): FilterType | false | this;
|
|
341
|
+
goTo(target: FlyToOptions, animate?: boolean): this;
|
|
342
|
+
}
|
|
343
|
+
interface SphereNamespace {
|
|
344
|
+
Map: new (options?: MapOptions) => SphereMap$1;
|
|
345
|
+
Marker: new (location: Location | object, options?: MarkerOptions) => SphereMarker;
|
|
346
|
+
Popup: new (location: Location | object, options?: PopupOptions) => SpherePopup;
|
|
347
|
+
Polyline: new (locationList: Location[] | object, options?: GeometryOptions) => SpherePolyline;
|
|
348
|
+
Polygon: new (locationList: Location[] | object, options?: GeometryOptions) => SpherePolygon;
|
|
349
|
+
Circle: new (location: Location | object, radius: number, options?: GeometryOptions) => SphereCircle;
|
|
350
|
+
Dot: new (location: Location | object, options?: GeometryOptions) => SphereDot;
|
|
351
|
+
Rectangle: new (location: Location, size: Size | Location, options?: GeometryOptions) => SphereRectangle;
|
|
352
|
+
Layer: new (name: string, options?: LayerOptions) => SphereLayer;
|
|
353
|
+
Layers: {
|
|
354
|
+
SIMPLE: SphereLayer;
|
|
355
|
+
STREETS: SphereLayer;
|
|
356
|
+
STREETS_NIGHT: SphereLayer;
|
|
357
|
+
HYBRID: SphereLayer;
|
|
358
|
+
TRAFFIC: SphereLayer;
|
|
359
|
+
IMAGES: SphereLayer;
|
|
360
|
+
PM25: SphereLayer;
|
|
361
|
+
HOTSPOT: SphereLayer;
|
|
362
|
+
FLOOD: SphereLayer;
|
|
363
|
+
DROUGHT: SphereLayer;
|
|
364
|
+
};
|
|
365
|
+
LayerType: {
|
|
366
|
+
Vector: string;
|
|
367
|
+
XYZ: string;
|
|
368
|
+
WMS: string;
|
|
369
|
+
WMTS: string;
|
|
370
|
+
WMTS_REST: string;
|
|
371
|
+
TMS: string;
|
|
372
|
+
Tiles3D: string;
|
|
373
|
+
I3S: string;
|
|
374
|
+
};
|
|
375
|
+
LineStyle: {
|
|
376
|
+
Solid: string;
|
|
377
|
+
Dashed: string;
|
|
378
|
+
Dot: string;
|
|
379
|
+
};
|
|
380
|
+
Filter: {
|
|
381
|
+
Dark: FilterType;
|
|
382
|
+
Light: FilterType;
|
|
383
|
+
Protanopia: FilterType;
|
|
384
|
+
Deuteranopia: FilterType;
|
|
385
|
+
None: FilterType;
|
|
386
|
+
};
|
|
387
|
+
EventName: Record<EventName, EventName>;
|
|
388
|
+
TagType: {
|
|
389
|
+
WFS: string;
|
|
390
|
+
OGC: string;
|
|
391
|
+
};
|
|
392
|
+
RouteMode: {
|
|
393
|
+
Traffic: string;
|
|
394
|
+
Cost: string;
|
|
395
|
+
Distance: string;
|
|
396
|
+
Fly: string;
|
|
397
|
+
};
|
|
398
|
+
RouteType: {
|
|
399
|
+
Road: string;
|
|
400
|
+
Ferry: string;
|
|
401
|
+
Tollway: string;
|
|
402
|
+
All: string;
|
|
403
|
+
};
|
|
404
|
+
RouteLabel: {
|
|
405
|
+
Distance: string;
|
|
406
|
+
Time: string;
|
|
407
|
+
Hide: string;
|
|
408
|
+
};
|
|
409
|
+
Util: {
|
|
410
|
+
append(element: HTMLElement, childName: string, propertyMap?: object): HTMLElement;
|
|
411
|
+
prepend(element: HTMLElement, childName: string, propertyMap?: object, beforeElement?: HTMLElement): HTMLElement;
|
|
412
|
+
empty(element: HTMLElement): HTMLElement;
|
|
413
|
+
loadStyle(url: string, media?: string): void;
|
|
414
|
+
loadScript(url: string, callback?: (isLoad: boolean) => void): void;
|
|
415
|
+
getJson(url: string): Promise<object>;
|
|
416
|
+
isHD(): number;
|
|
417
|
+
validateLocation(location: Location): boolean;
|
|
418
|
+
sameLocation(a: Location, b: Location): boolean;
|
|
419
|
+
longitudeLength(lat: number): number;
|
|
420
|
+
latitudeLength(lat: number): number;
|
|
421
|
+
isAbsInRange(value: number, range: number): boolean;
|
|
422
|
+
bound(value: number, min: number, max: number): number;
|
|
423
|
+
formatDate(date: string, language: string): string;
|
|
424
|
+
formatTime(time: string): string;
|
|
425
|
+
formatDateTimeRange(startDatetime: string, stopDatetime: string, language: string): string;
|
|
426
|
+
formatInterval(interval: number, language: string): string;
|
|
427
|
+
formatDistance(distance: number, language: string): string;
|
|
428
|
+
formatArea(area: number, language: string): string;
|
|
429
|
+
formatThaiArea(area: number, language: string): string;
|
|
430
|
+
initLibrary(library: string): Promise<void>;
|
|
431
|
+
project(fromProjection: string | undefined, toProjection: string, coordinates: object | unknown[]): object;
|
|
432
|
+
WKTToGeoJSON(text: string): object;
|
|
433
|
+
EsriJSONToGeoJSON(json: object): object;
|
|
434
|
+
TopoJSONToGeoJSON(json: object, obj: object | string): object;
|
|
435
|
+
GMLToGeoJSON(doc: Document | string): object;
|
|
436
|
+
GPXToGeoJSON(doc: Document | string): object;
|
|
437
|
+
KMLToGeoJSON(doc: Document | string): object;
|
|
438
|
+
formatPoi?: (poi: object, lang: string) => HTMLElement;
|
|
439
|
+
poiPopupOptions?: (source: string, id: string, name: string, language: string) => PopupOptions;
|
|
440
|
+
};
|
|
441
|
+
Math: {
|
|
442
|
+
distance(dx: number, dy: number): number;
|
|
443
|
+
closestPointOnLine(x: number, y: number, x1: number, y1: number, x2: number, y2: number): Point;
|
|
444
|
+
lineIntersectPoint(x1: number, y1: number, x2: number, y2: number, u1: number, v1: number, u2: number, v2: number, skipOverlap?: boolean): Point | number[] | null;
|
|
445
|
+
};
|
|
446
|
+
Overlays: {
|
|
447
|
+
cameras: {
|
|
448
|
+
popup?: boolean;
|
|
449
|
+
motion?: boolean;
|
|
450
|
+
};
|
|
451
|
+
events: {
|
|
452
|
+
popup?: boolean;
|
|
453
|
+
};
|
|
454
|
+
aqi: {
|
|
455
|
+
popup?: boolean;
|
|
456
|
+
};
|
|
457
|
+
Object: new (id: string, dataset?: string, options?: object) => SphereOverlay;
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
declare global {
|
|
461
|
+
interface Window {
|
|
462
|
+
sphere?: SphereNamespace;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
interface CircleProps {
|
|
467
|
+
center: Location;
|
|
468
|
+
radius: number;
|
|
469
|
+
title?: string;
|
|
470
|
+
detail?: string;
|
|
471
|
+
popup?: PopupOptions;
|
|
472
|
+
visibleRange?: Range;
|
|
473
|
+
lineWidth?: number;
|
|
474
|
+
lineColor?: string;
|
|
475
|
+
fillColor?: string;
|
|
476
|
+
lineStyle?: LineStyleType;
|
|
477
|
+
clickable?: boolean;
|
|
478
|
+
draggable?: boolean;
|
|
479
|
+
zIndex?: number;
|
|
480
|
+
onClick?: (circle: SphereCircle) => void;
|
|
481
|
+
onDrag?: (circle: SphereCircle) => void;
|
|
482
|
+
onDrop?: (circle: SphereCircle) => void;
|
|
483
|
+
}
|
|
484
|
+
interface CircleRef {
|
|
485
|
+
getCircle(): SphereCircle | null;
|
|
486
|
+
togglePopup(show?: boolean, location?: Location): void;
|
|
487
|
+
getCenter(): Location | null;
|
|
488
|
+
getBound(): Bound | null;
|
|
489
|
+
getArea(language?: string): number | string | null;
|
|
490
|
+
getRadius(language?: string): number | string | null;
|
|
491
|
+
updateStyle(options: Partial<GeometryOptions>): void;
|
|
492
|
+
}
|
|
493
|
+
declare const Circle: react.ForwardRefExoticComponent<CircleProps & react.RefAttributes<CircleRef>>;
|
|
494
|
+
|
|
495
|
+
interface DotProps {
|
|
496
|
+
position: Location;
|
|
497
|
+
title?: string;
|
|
498
|
+
detail?: string;
|
|
499
|
+
visibleRange?: Range;
|
|
500
|
+
lineWidth?: number;
|
|
501
|
+
lineColor?: string;
|
|
502
|
+
clickable?: boolean;
|
|
503
|
+
draggable?: boolean;
|
|
504
|
+
zIndex?: number;
|
|
505
|
+
onClick?: (dot: SphereDot) => void;
|
|
506
|
+
onDrag?: (dot: SphereDot) => void;
|
|
507
|
+
onDrop?: (dot: SphereDot, location: Location) => void;
|
|
508
|
+
}
|
|
509
|
+
interface DotRef {
|
|
510
|
+
getDot(): SphereDot | null;
|
|
511
|
+
setPosition(location: Location): void;
|
|
512
|
+
getPosition(): Location | null;
|
|
513
|
+
}
|
|
514
|
+
declare const Dot: react.ForwardRefExoticComponent<DotProps & react.RefAttributes<DotRef>>;
|
|
515
|
+
|
|
516
|
+
interface LayerProps {
|
|
517
|
+
name?: string;
|
|
518
|
+
preset?: BuiltInLayer$1;
|
|
519
|
+
isBase?: boolean;
|
|
520
|
+
type?: LayerType;
|
|
521
|
+
url?: string;
|
|
522
|
+
zoomRange?: Range;
|
|
523
|
+
source?: Range;
|
|
524
|
+
opacity?: number;
|
|
525
|
+
zIndex?: number;
|
|
526
|
+
bound?: Bound;
|
|
527
|
+
attribution?: string;
|
|
528
|
+
extraQuery?: string;
|
|
529
|
+
id?: string;
|
|
530
|
+
format?: string;
|
|
531
|
+
srs?: string;
|
|
532
|
+
tileMatrixPrefix?: string;
|
|
533
|
+
styles?: string;
|
|
534
|
+
version?: string;
|
|
535
|
+
refresh?: number;
|
|
536
|
+
zoomOffset?: number;
|
|
537
|
+
beforeId?: string;
|
|
538
|
+
}
|
|
539
|
+
declare function Layer({ name, preset, isBase, type, url, zoomRange, source, opacity, zIndex, bound, attribution, extraQuery, id, format, srs, tileMatrixPrefix, styles, version, refresh, zoomOffset, beforeId, }: LayerProps): null;
|
|
540
|
+
|
|
541
|
+
interface MarkerProps {
|
|
542
|
+
position: Location;
|
|
543
|
+
icon?: Icon;
|
|
544
|
+
title?: string;
|
|
545
|
+
detail?: string;
|
|
546
|
+
popup?: PopupOptions;
|
|
547
|
+
visibleRange?: Range;
|
|
548
|
+
clickable?: boolean;
|
|
549
|
+
draggable?: boolean;
|
|
550
|
+
zIndex?: number;
|
|
551
|
+
rotate?: number;
|
|
552
|
+
onClick?: (marker: SphereMarker) => void;
|
|
553
|
+
onDrag?: (marker: SphereMarker) => void;
|
|
554
|
+
onDrop?: (marker: SphereMarker, location: Location) => void;
|
|
555
|
+
onHover?: (marker: SphereMarker) => void;
|
|
556
|
+
onLeave?: (marker: SphereMarker) => void;
|
|
557
|
+
}
|
|
558
|
+
interface MarkerRef {
|
|
559
|
+
getMarker(): SphereMarker | null;
|
|
560
|
+
togglePopup(show?: boolean): void;
|
|
561
|
+
setPosition(location: Location, animate?: boolean): void;
|
|
562
|
+
setRotation(angle: number): void;
|
|
563
|
+
}
|
|
564
|
+
declare const Marker: react.ForwardRefExoticComponent<MarkerProps & react.RefAttributes<MarkerRef>>;
|
|
565
|
+
|
|
566
|
+
interface PolygonProps {
|
|
567
|
+
positions: Location[];
|
|
568
|
+
title?: string;
|
|
569
|
+
detail?: string;
|
|
570
|
+
label?: string;
|
|
571
|
+
labelOptions?: MarkerOptions;
|
|
572
|
+
popup?: PopupOptions;
|
|
573
|
+
visibleRange?: Range;
|
|
574
|
+
lineWidth?: number;
|
|
575
|
+
lineColor?: string;
|
|
576
|
+
fillColor?: string;
|
|
577
|
+
lineStyle?: LineStyleType;
|
|
578
|
+
pivot?: Location;
|
|
579
|
+
clickable?: boolean;
|
|
580
|
+
draggable?: boolean;
|
|
581
|
+
pointer?: boolean;
|
|
582
|
+
zIndex?: number;
|
|
583
|
+
editable?: boolean;
|
|
584
|
+
onClick?: (polygon: SpherePolygon) => void;
|
|
585
|
+
onDrag?: (polygon: SpherePolygon) => void;
|
|
586
|
+
onDrop?: (polygon: SpherePolygon) => void;
|
|
587
|
+
}
|
|
588
|
+
interface PolygonRef {
|
|
589
|
+
getPolygon(): SpherePolygon | null;
|
|
590
|
+
togglePopup(show?: boolean, location?: Location): void;
|
|
591
|
+
getPivot(): Location | null;
|
|
592
|
+
getCentroid(): Location | null;
|
|
593
|
+
getBound(): Bound | null;
|
|
594
|
+
getArea(language?: string): number | string | null;
|
|
595
|
+
rotate(angle: number): void;
|
|
596
|
+
updateStyle(options: Partial<GeometryOptions>): void;
|
|
597
|
+
toGeoJSON(): object | null;
|
|
598
|
+
}
|
|
599
|
+
declare const Polygon: react.ForwardRefExoticComponent<PolygonProps & react.RefAttributes<PolygonRef>>;
|
|
600
|
+
|
|
601
|
+
interface PolylineProps {
|
|
602
|
+
positions: Location[];
|
|
603
|
+
title?: string;
|
|
604
|
+
detail?: string;
|
|
605
|
+
label?: string;
|
|
606
|
+
labelOptions?: MarkerOptions;
|
|
607
|
+
popup?: PopupOptions;
|
|
608
|
+
visibleRange?: Range;
|
|
609
|
+
lineWidth?: number;
|
|
610
|
+
lineColor?: string;
|
|
611
|
+
lineStyle?: LineStyleType;
|
|
612
|
+
pivot?: Location;
|
|
613
|
+
clickable?: boolean;
|
|
614
|
+
draggable?: boolean;
|
|
615
|
+
pointer?: boolean;
|
|
616
|
+
zIndex?: number;
|
|
617
|
+
onClick?: (polyline: SpherePolyline) => void;
|
|
618
|
+
onDrag?: (polyline: SpherePolyline) => void;
|
|
619
|
+
onDrop?: (polyline: SpherePolyline) => void;
|
|
620
|
+
}
|
|
621
|
+
interface PolylineRef {
|
|
622
|
+
getPolyline(): SpherePolyline | null;
|
|
623
|
+
togglePopup(show?: boolean, location?: Location): void;
|
|
624
|
+
getPivot(): Location | null;
|
|
625
|
+
getCentroid(): Location | null;
|
|
626
|
+
getBound(): Bound | null;
|
|
627
|
+
getLength(language?: string): number | string | null;
|
|
628
|
+
rotate(angle: number): void;
|
|
629
|
+
updateStyle(options: Partial<GeometryOptions>): void;
|
|
630
|
+
}
|
|
631
|
+
declare const Polyline: react.ForwardRefExoticComponent<PolylineProps & react.RefAttributes<PolylineRef>>;
|
|
632
|
+
|
|
633
|
+
interface PopupProps {
|
|
634
|
+
position: Location;
|
|
635
|
+
title?: string;
|
|
636
|
+
detail?: string;
|
|
637
|
+
loadDetail?: (element: HTMLElement) => void;
|
|
638
|
+
html?: string;
|
|
639
|
+
loadHtml?: (element: HTMLElement) => void;
|
|
640
|
+
size?: Size;
|
|
641
|
+
closable?: boolean;
|
|
642
|
+
onClose?: (popup: SpherePopup) => void;
|
|
643
|
+
}
|
|
644
|
+
interface PopupRef {
|
|
645
|
+
getPopup(): SpherePopup | null;
|
|
646
|
+
setPosition(location: Location): void;
|
|
647
|
+
setTitle(title: string): void;
|
|
648
|
+
setDetail(detail: string): void;
|
|
649
|
+
getElement(): HTMLElement | null;
|
|
650
|
+
}
|
|
651
|
+
declare const Popup: react.ForwardRefExoticComponent<PopupProps & react.RefAttributes<PopupRef>>;
|
|
652
|
+
|
|
653
|
+
interface RectangleProps {
|
|
654
|
+
position: Location;
|
|
655
|
+
size: Size | Location;
|
|
656
|
+
title?: string;
|
|
657
|
+
detail?: string;
|
|
658
|
+
popup?: PopupOptions;
|
|
659
|
+
visibleRange?: Range;
|
|
660
|
+
lineWidth?: number;
|
|
661
|
+
lineColor?: string;
|
|
662
|
+
fillColor?: string;
|
|
663
|
+
lineStyle?: LineStyleType;
|
|
664
|
+
clickable?: boolean;
|
|
665
|
+
draggable?: boolean;
|
|
666
|
+
editable?: boolean;
|
|
667
|
+
zIndex?: number;
|
|
668
|
+
onClick?: (rectangle: SphereRectangle) => void;
|
|
669
|
+
onDrag?: (rectangle: SphereRectangle) => void;
|
|
670
|
+
onDrop?: (rectangle: SphereRectangle) => void;
|
|
671
|
+
}
|
|
672
|
+
interface RectangleRef {
|
|
673
|
+
getRectangle(): SphereRectangle | null;
|
|
674
|
+
togglePopup(show?: boolean, location?: Location): void;
|
|
675
|
+
getBound(): Bound | null;
|
|
676
|
+
getArea(language?: string): number | string | null;
|
|
677
|
+
updateStyle(options: Partial<GeometryOptions>): void;
|
|
678
|
+
}
|
|
679
|
+
declare const Rectangle: react.ForwardRefExoticComponent<RectangleProps & react.RefAttributes<RectangleRef>>;
|
|
680
|
+
|
|
681
|
+
interface SphereMapProps {
|
|
682
|
+
children?: ReactNode;
|
|
683
|
+
zoom?: number;
|
|
684
|
+
zoomRange?: Range;
|
|
685
|
+
center?: Location;
|
|
686
|
+
language?: string;
|
|
687
|
+
input?: boolean;
|
|
688
|
+
lastView?: boolean;
|
|
689
|
+
ui?: "Full" | "Mobile" | "None";
|
|
690
|
+
filter?: FilterType;
|
|
691
|
+
rotate?: number;
|
|
692
|
+
pitch?: number;
|
|
693
|
+
className?: string;
|
|
694
|
+
style?: CSSProperties;
|
|
695
|
+
id?: string;
|
|
696
|
+
onReady?: (map: SphereMap$1) => void;
|
|
697
|
+
onZoom?: (zoom: number) => void;
|
|
698
|
+
onLocation?: (location: Location) => void;
|
|
699
|
+
onClick?: (location: Location) => void;
|
|
700
|
+
onDoubleClick?: (location: Location) => void;
|
|
701
|
+
onRotate?: (angle: number) => void;
|
|
702
|
+
onPitch?: (angle: number) => void;
|
|
703
|
+
onDrag?: () => void;
|
|
704
|
+
onDrop?: () => void;
|
|
705
|
+
onIdle?: () => void;
|
|
706
|
+
onMouseMove?: (location: Location) => void;
|
|
707
|
+
onError?: (error: Error) => void;
|
|
708
|
+
}
|
|
709
|
+
interface SphereMapRef {
|
|
710
|
+
getMap(): SphereMap$1 | null;
|
|
711
|
+
setZoom(zoom: number, animate?: boolean): void;
|
|
712
|
+
setCenter(location: Location, animate?: boolean): void;
|
|
713
|
+
setBound(bound: Bound, options?: object): void;
|
|
714
|
+
goTo(target: FlyToOptions, animate?: boolean): void;
|
|
715
|
+
setRotate(angle: number, animate?: boolean): void;
|
|
716
|
+
setPitch(angle: number): void;
|
|
717
|
+
setFilter(filter: FilterType): void;
|
|
718
|
+
resize(): void;
|
|
719
|
+
repaint(): void;
|
|
720
|
+
}
|
|
721
|
+
declare const SphereMap: react.ForwardRefExoticComponent<SphereMapProps & react.RefAttributes<SphereMapRef>>;
|
|
722
|
+
|
|
723
|
+
interface MapContextValue {
|
|
724
|
+
map: SphereMap$1 | null;
|
|
725
|
+
isReady: boolean;
|
|
726
|
+
}
|
|
727
|
+
interface MapProviderProps {
|
|
728
|
+
map: SphereMap$1 | null;
|
|
729
|
+
isReady: boolean;
|
|
730
|
+
children: ReactNode;
|
|
731
|
+
}
|
|
732
|
+
declare function MapProvider({ map, isReady, children, }: MapProviderProps): ReactNode;
|
|
733
|
+
declare function useMapContext(): MapContextValue;
|
|
734
|
+
|
|
735
|
+
type BuiltInLayer = "SIMPLE" | "STREETS" | "STREETS_NIGHT" | "HYBRID" | "TRAFFIC" | "IMAGES" | "PM25" | "HOTSPOT" | "FLOOD" | "DROUGHT";
|
|
736
|
+
interface MapControls {
|
|
737
|
+
isReady: boolean;
|
|
738
|
+
goTo: (options: FlyToOptions, animate?: boolean) => void;
|
|
739
|
+
setCenter: (location: Location, animate?: boolean) => void;
|
|
740
|
+
setZoom: (zoom: number, animate?: boolean) => void;
|
|
741
|
+
setBound: (bound: Bound, options?: object) => void;
|
|
742
|
+
setRotate: (angle: number, animate?: boolean) => void;
|
|
743
|
+
setPitch: (angle: number) => void;
|
|
744
|
+
setFilter: (filter: FilterType | false) => void;
|
|
745
|
+
setLanguage: (language: string) => void;
|
|
746
|
+
setBaseLayer: (layer: BuiltInLayer) => void;
|
|
747
|
+
addLayer: (layer: BuiltInLayer) => void;
|
|
748
|
+
removeLayer: (layer: BuiltInLayer) => void;
|
|
749
|
+
resize: () => void;
|
|
750
|
+
repaint: () => void;
|
|
751
|
+
}
|
|
752
|
+
interface SphereContextValue {
|
|
753
|
+
isLoaded: boolean;
|
|
754
|
+
error: Error | null;
|
|
755
|
+
sphere: SphereNamespace | null;
|
|
756
|
+
apiKey: string;
|
|
757
|
+
map: SphereMap$1 | null;
|
|
758
|
+
isMapReady: boolean;
|
|
759
|
+
controls: MapControls;
|
|
760
|
+
registerMap: (map: SphereMap$1) => void;
|
|
761
|
+
unregisterMap: () => void;
|
|
762
|
+
}
|
|
763
|
+
interface SphereProviderProps {
|
|
764
|
+
apiKey: string;
|
|
765
|
+
children: ReactNode;
|
|
766
|
+
scriptUrl?: string;
|
|
767
|
+
onLoad?: () => void;
|
|
768
|
+
onError?: (error: Error) => void;
|
|
769
|
+
}
|
|
770
|
+
declare function SphereProvider({ apiKey, children, scriptUrl, onLoad, onError, }: SphereProviderProps): ReactNode;
|
|
771
|
+
declare function useSphereContext(): SphereContextValue;
|
|
772
|
+
declare function useMap(): {
|
|
773
|
+
map: SphereMap$1 | null;
|
|
774
|
+
sphere: SphereNamespace | null;
|
|
775
|
+
isReady: boolean;
|
|
776
|
+
};
|
|
777
|
+
declare function useMapControls(): MapControls;
|
|
778
|
+
|
|
779
|
+
declare function useMapEvent<T = unknown>(eventName: EventName, handler: EventHandler<T>): void;
|
|
780
|
+
declare function useMapReady(handler: () => void): void;
|
|
781
|
+
declare function useMapClick(handler: EventHandler<{
|
|
782
|
+
lon: number;
|
|
783
|
+
lat: number;
|
|
784
|
+
}>): void;
|
|
785
|
+
declare function useMapZoom(handler: EventHandler<void>): void;
|
|
786
|
+
declare function useMapLocation(handler: EventHandler<void>): void;
|
|
787
|
+
declare function useOverlayClick(handler: EventHandler<{
|
|
788
|
+
overlay: SphereOverlay;
|
|
789
|
+
location: Location;
|
|
790
|
+
}>): void;
|
|
791
|
+
|
|
792
|
+
interface BaseOverlay {
|
|
793
|
+
id: string;
|
|
794
|
+
}
|
|
795
|
+
interface MarkerData extends BaseOverlay {
|
|
796
|
+
position: Location;
|
|
797
|
+
icon?: Icon;
|
|
798
|
+
title?: string;
|
|
799
|
+
detail?: string;
|
|
800
|
+
popup?: PopupOptions;
|
|
801
|
+
visibleRange?: Range;
|
|
802
|
+
clickable?: boolean;
|
|
803
|
+
draggable?: boolean;
|
|
804
|
+
zIndex?: number;
|
|
805
|
+
rotate?: number;
|
|
806
|
+
}
|
|
807
|
+
interface PolygonData extends BaseOverlay {
|
|
808
|
+
positions: Location[];
|
|
809
|
+
title?: string;
|
|
810
|
+
detail?: string;
|
|
811
|
+
lineWidth?: number;
|
|
812
|
+
lineColor?: string;
|
|
813
|
+
fillColor?: string;
|
|
814
|
+
lineStyle?: "Solid" | "Dashed" | "Dot";
|
|
815
|
+
popup?: PopupOptions;
|
|
816
|
+
visibleRange?: Range;
|
|
817
|
+
clickable?: boolean;
|
|
818
|
+
draggable?: boolean;
|
|
819
|
+
editable?: boolean;
|
|
820
|
+
zIndex?: number;
|
|
821
|
+
}
|
|
822
|
+
interface PolylineData extends BaseOverlay {
|
|
823
|
+
positions: Location[];
|
|
824
|
+
title?: string;
|
|
825
|
+
detail?: string;
|
|
826
|
+
lineWidth?: number;
|
|
827
|
+
lineColor?: string;
|
|
828
|
+
lineStyle?: "Solid" | "Dashed" | "Dot";
|
|
829
|
+
popup?: PopupOptions;
|
|
830
|
+
visibleRange?: Range;
|
|
831
|
+
clickable?: boolean;
|
|
832
|
+
draggable?: boolean;
|
|
833
|
+
editable?: boolean;
|
|
834
|
+
zIndex?: number;
|
|
835
|
+
}
|
|
836
|
+
interface CircleData extends BaseOverlay {
|
|
837
|
+
center: Location;
|
|
838
|
+
radius: number;
|
|
839
|
+
title?: string;
|
|
840
|
+
detail?: string;
|
|
841
|
+
lineWidth?: number;
|
|
842
|
+
lineColor?: string;
|
|
843
|
+
fillColor?: string;
|
|
844
|
+
lineStyle?: "Solid" | "Dashed" | "Dot";
|
|
845
|
+
popup?: PopupOptions;
|
|
846
|
+
visibleRange?: Range;
|
|
847
|
+
clickable?: boolean;
|
|
848
|
+
draggable?: boolean;
|
|
849
|
+
zIndex?: number;
|
|
850
|
+
}
|
|
851
|
+
type OverlayInput<T extends BaseOverlay> = Omit<T, "id"> & {
|
|
852
|
+
id?: string;
|
|
853
|
+
};
|
|
854
|
+
interface UseOverlaysResult<T extends BaseOverlay> {
|
|
855
|
+
items: T[];
|
|
856
|
+
add: (data: OverlayInput<T>) => string;
|
|
857
|
+
update: (id: string, data: Partial<Omit<T, "id">>) => void;
|
|
858
|
+
remove: (id: string) => void;
|
|
859
|
+
clear: () => void;
|
|
860
|
+
get: (id: string) => T | undefined;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Hook to manage markers with add/update/remove functionality.
|
|
864
|
+
*
|
|
865
|
+
* @example
|
|
866
|
+
* ```tsx
|
|
867
|
+
* function DrawingPanel() {
|
|
868
|
+
* const { items: markers, add, remove, clear } = useMarkers();
|
|
869
|
+
*
|
|
870
|
+
* const handleMapClick = (location: Location) => {
|
|
871
|
+
* add({ position: location, title: `Marker ${markers.length + 1}` });
|
|
872
|
+
* };
|
|
873
|
+
*
|
|
874
|
+
* return (
|
|
875
|
+
* <>
|
|
876
|
+
* {markers.map((m) => (
|
|
877
|
+
* <Marker
|
|
878
|
+
* key={m.id}
|
|
879
|
+
* position={m.position}
|
|
880
|
+
* title={m.title}
|
|
881
|
+
* onClick={() => remove(m.id)}
|
|
882
|
+
* />
|
|
883
|
+
* ))}
|
|
884
|
+
* </>
|
|
885
|
+
* );
|
|
886
|
+
* }
|
|
887
|
+
* ```
|
|
888
|
+
*/
|
|
889
|
+
declare function useMarkers(): UseOverlaysResult<MarkerData>;
|
|
890
|
+
/**
|
|
891
|
+
* Hook to manage polygons with add/update/remove functionality.
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* ```tsx
|
|
895
|
+
* function DrawingPanel() {
|
|
896
|
+
* const { items: polygons, add, clear } = usePolygons();
|
|
897
|
+
*
|
|
898
|
+
* const handleFinishDrawing = (positions: Location[]) => {
|
|
899
|
+
* add({ positions, fillColor: 'rgba(255, 0, 0, 0.3)' });
|
|
900
|
+
* };
|
|
901
|
+
*
|
|
902
|
+
* return (
|
|
903
|
+
* <>
|
|
904
|
+
* {polygons.map((p) => (
|
|
905
|
+
* <Polygon key={p.id} positions={p.positions} fillColor={p.fillColor} />
|
|
906
|
+
* ))}
|
|
907
|
+
* </>
|
|
908
|
+
* );
|
|
909
|
+
* }
|
|
910
|
+
* ```
|
|
911
|
+
*/
|
|
912
|
+
declare function usePolygons(): UseOverlaysResult<PolygonData>;
|
|
913
|
+
/**
|
|
914
|
+
* Hook to manage polylines with add/update/remove functionality.
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* ```tsx
|
|
918
|
+
* function DrawingPanel() {
|
|
919
|
+
* const { items: polylines, add } = usePolylines();
|
|
920
|
+
*
|
|
921
|
+
* return (
|
|
922
|
+
* <>
|
|
923
|
+
* {polylines.map((p) => (
|
|
924
|
+
* <Polyline key={p.id} positions={p.positions} lineColor={p.lineColor} />
|
|
925
|
+
* ))}
|
|
926
|
+
* </>
|
|
927
|
+
* );
|
|
928
|
+
* }
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
declare function usePolylines(): UseOverlaysResult<PolylineData>;
|
|
932
|
+
/**
|
|
933
|
+
* Hook to manage circles with add/update/remove functionality.
|
|
934
|
+
*
|
|
935
|
+
* @example
|
|
936
|
+
* ```tsx
|
|
937
|
+
* function DrawingPanel() {
|
|
938
|
+
* const { items: circles, add } = useCircles();
|
|
939
|
+
*
|
|
940
|
+
* const handleAddCircle = (center: Location, radius: number) => {
|
|
941
|
+
* add({ center, radius, fillColor: 'rgba(0, 0, 255, 0.3)' });
|
|
942
|
+
* };
|
|
943
|
+
*
|
|
944
|
+
* return (
|
|
945
|
+
* <>
|
|
946
|
+
* {circles.map((c) => (
|
|
947
|
+
* <Circle key={c.id} center={c.center} radius={c.radius} fillColor={c.fillColor} />
|
|
948
|
+
* ))}
|
|
949
|
+
* </>
|
|
950
|
+
* );
|
|
951
|
+
* }
|
|
952
|
+
* ```
|
|
953
|
+
*/
|
|
954
|
+
declare function useCircles(): UseOverlaysResult<CircleData>;
|
|
955
|
+
/**
|
|
956
|
+
* Hook that combines all overlay types into a single manager.
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```tsx
|
|
960
|
+
* function DrawingPanel() {
|
|
961
|
+
* const overlays = useOverlays();
|
|
962
|
+
*
|
|
963
|
+
* const handleClearAll = () => {
|
|
964
|
+
* overlays.markers.clear();
|
|
965
|
+
* overlays.polygons.clear();
|
|
966
|
+
* overlays.polylines.clear();
|
|
967
|
+
* overlays.circles.clear();
|
|
968
|
+
* };
|
|
969
|
+
*
|
|
970
|
+
* return (
|
|
971
|
+
* <>
|
|
972
|
+
* <button onClick={handleClearAll}>Clear All</button>
|
|
973
|
+
* {overlays.markers.items.map((m) => <Marker key={m.id} {...m} />)}
|
|
974
|
+
* {overlays.polygons.items.map((p) => <Polygon key={p.id} {...p} />)}
|
|
975
|
+
* </>
|
|
976
|
+
* );
|
|
977
|
+
* }
|
|
978
|
+
* ```
|
|
979
|
+
*/
|
|
980
|
+
declare function useOverlays(): {
|
|
981
|
+
markers: UseOverlaysResult<MarkerData>;
|
|
982
|
+
polygons: UseOverlaysResult<PolygonData>;
|
|
983
|
+
polylines: UseOverlaysResult<PolylineData>;
|
|
984
|
+
circles: UseOverlaysResult<CircleData>;
|
|
985
|
+
clearAll: () => void;
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
interface RouteGuideStep {
|
|
989
|
+
instruction: string;
|
|
990
|
+
distance: number | string;
|
|
991
|
+
duration: number | string;
|
|
992
|
+
location: Location;
|
|
993
|
+
}
|
|
994
|
+
interface UseRouteReturn {
|
|
995
|
+
isReady: boolean;
|
|
996
|
+
addDestination: (destination: SphereMarker | Location, mode?: RouteMode) => void;
|
|
997
|
+
insertDestination: (index: number, destination: SphereMarker | Location, mode?: RouteMode) => void;
|
|
998
|
+
removeDestination: (destination: SphereMarker) => void;
|
|
999
|
+
removeDestinationAt: (index: number) => void;
|
|
1000
|
+
clearDestinations: () => void;
|
|
1001
|
+
clearPath: () => void;
|
|
1002
|
+
clear: () => void;
|
|
1003
|
+
reverse: () => void;
|
|
1004
|
+
search: () => void;
|
|
1005
|
+
getDistance: (format?: boolean) => number | string;
|
|
1006
|
+
getInterval: (format?: boolean) => number | string;
|
|
1007
|
+
getGuide: (format?: boolean) => RouteGuideStep[] | HTMLElement;
|
|
1008
|
+
exportRouteLine: (options?: GeometryOptions) => SpherePolyline | null;
|
|
1009
|
+
listDestinations: () => SphereMarker[];
|
|
1010
|
+
size: () => number;
|
|
1011
|
+
setMode: (mode: RouteMode) => void;
|
|
1012
|
+
setModeAt: (index: number, mode: RouteMode) => void;
|
|
1013
|
+
enableRouteType: (routeType: RouteType, state: boolean) => void;
|
|
1014
|
+
setLabel: (label: RouteLabelType) => void;
|
|
1015
|
+
setAuto: (state: boolean) => void;
|
|
1016
|
+
setLanguage: (lang: string) => void;
|
|
1017
|
+
}
|
|
1018
|
+
declare function useRoute(): UseRouteReturn;
|
|
1019
|
+
|
|
1020
|
+
interface SearchResult {
|
|
1021
|
+
data: object[];
|
|
1022
|
+
total?: number;
|
|
1023
|
+
}
|
|
1024
|
+
interface AddressResult {
|
|
1025
|
+
address?: string;
|
|
1026
|
+
subdistrict?: string;
|
|
1027
|
+
district?: string;
|
|
1028
|
+
province?: string;
|
|
1029
|
+
postcode?: string;
|
|
1030
|
+
geocode?: string;
|
|
1031
|
+
}
|
|
1032
|
+
interface PoiResult {
|
|
1033
|
+
id: string;
|
|
1034
|
+
name: string;
|
|
1035
|
+
location: Location;
|
|
1036
|
+
category?: string;
|
|
1037
|
+
distance?: number;
|
|
1038
|
+
}
|
|
1039
|
+
interface UseSearchReturn {
|
|
1040
|
+
isReady: boolean;
|
|
1041
|
+
suggest: (keyword: string, options?: SuggestOptions) => Promise<SearchResult>;
|
|
1042
|
+
search: (keyword: string, options?: SearchOptions) => Promise<SearchResult>;
|
|
1043
|
+
address: (location: Location, options?: AddressOptions) => Promise<AddressResult>;
|
|
1044
|
+
nearPoi: (location: Location, options?: NearPoiOptions) => Promise<PoiResult[]>;
|
|
1045
|
+
clear: () => void;
|
|
1046
|
+
enablePopup: (state: boolean) => void;
|
|
1047
|
+
setLanguage: (lang: string) => void;
|
|
1048
|
+
}
|
|
1049
|
+
declare function useSearch(): UseSearchReturn;
|
|
1050
|
+
|
|
1051
|
+
declare function useSphere(): {
|
|
1052
|
+
sphere: SphereNamespace | null;
|
|
1053
|
+
isLoaded: boolean;
|
|
1054
|
+
error: Error | null;
|
|
1055
|
+
apiKey: string;
|
|
1056
|
+
};
|
|
1057
|
+
|
|
1058
|
+
type TagDataFunction = (tile: Tile) => object[];
|
|
1059
|
+
interface UseTagsReturn {
|
|
1060
|
+
isReady: boolean;
|
|
1061
|
+
set: (tag: string | TagDataFunction, options?: TagOptions) => void;
|
|
1062
|
+
add: (tag: string | TagDataFunction, options?: TagOptions) => void;
|
|
1063
|
+
remove: (tag: string) => void;
|
|
1064
|
+
clear: () => void;
|
|
1065
|
+
list: () => string[];
|
|
1066
|
+
size: () => number;
|
|
1067
|
+
enablePopup: (state: boolean) => void;
|
|
1068
|
+
setLanguage: (lang: string) => void;
|
|
1069
|
+
}
|
|
1070
|
+
interface TagDefinition {
|
|
1071
|
+
id: string;
|
|
1072
|
+
label: string;
|
|
1073
|
+
}
|
|
1074
|
+
interface TagCategory {
|
|
1075
|
+
name: string;
|
|
1076
|
+
tags: TagDefinition[];
|
|
1077
|
+
}
|
|
1078
|
+
declare const TAG_CATEGORIES: TagCategory[];
|
|
1079
|
+
declare function useTags(): UseTagsReturn;
|
|
1080
|
+
|
|
1081
|
+
export { type AddressOptions, type AddressResult, type BaseOverlay, type Bound, type BuiltInLayer, Circle, type CircleData, type CircleProps, type CircleRef, Dot, type DotProps, type DotRef, type EventHandler, type EventName, type FilterType, type FlyToOptions, type GeometryOptions, type Icon, Layer, type LayerOptions, type LayerProps, type LayerType, type LineStyleType, type Location, SphereMap as Map, type MapContextValue, type MapControls, type MapOptions, MapProvider, Marker, type MarkerData, type MarkerOptions, type MarkerProps, type MarkerRef, type NearPoiOptions, type OverlayInput, type PoiResult, type Point, Polygon, type PolygonData, type PolygonProps, type PolygonRef, Polyline, type PolylineData, type PolylineProps, type PolylineRef, Popup, type PopupOptions, type PopupProps, type PopupRef, type Range, Rectangle, type RectangleProps, type RectangleRef, type RouteGuideStep, type RouteLabelType, type RouteMode, type RouteType, type SearchOptions, type SearchResult, type Size, type SphereCircle, type SphereContextValue, type SphereDot, type SphereLayer, SphereMap, type SphereMap$1 as SphereMapInstance, type SphereMapProps, type SphereMapRef, type SphereMarker, type SphereNamespace, type SphereOverlay, type SpherePolygon, type SpherePolyline, type SpherePopup, SphereProvider, type SphereProviderProps, type SphereRectangle, type SuggestOptions, TAG_CATEGORIES, type TagCategory, type TagDataFunction, type TagDefinition, type TagOptions, type TagType, type Tile, type UiComponentMode, type UseOverlaysResult, type UseRouteReturn, type UseSearchReturn, type UseTagsReturn, useCircles, useMap, useMapClick, useMapContext, useMapControls, useMapEvent, useMapLocation, useMapReady, useMapZoom, useMarkers, useOverlayClick, useOverlays, usePolygons, usePolylines, useRoute, useSearch, useSphere, useSphereContext, useTags };
|