@geolonia/maps-react 0.0.1 → 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.
@@ -0,0 +1,176 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, CSSProperties } from 'react';
3
+ import { Map as Map$1, AttributionControlOptions, FullscreenControlOptions, GeolocateControlOptions, NavigationControlOptions, ScaleControlOptions, IControl, LayerSpecification, PointLike, PositionAnchor, Alignment, SourceSpecification, CanvasSourceSpecification } from 'maplibre-gl';
4
+ import { GeoloniaMapOptions, GeoloniaMap } from '@geolonia/maps-core';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
+
7
+ type ControlPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
8
+ type ControlProps = {
9
+ position?: ControlPosition;
10
+ onAdd?: (map: Map$1) => HTMLElement;
11
+ onRemove?: (map: Map$1) => void;
12
+ children?: ReactNode;
13
+ };
14
+ declare function Control({ position, onAdd, onRemove, children, }: ControlProps): react.ReactPortal | null;
15
+
16
+ declare function useControl<T extends IControl>(factory: () => T, options?: {
17
+ position?: ControlPosition;
18
+ }): void;
19
+ type NavigationControlProps = NavigationControlOptions & {
20
+ position?: ControlPosition;
21
+ };
22
+ declare function NavigationControl({ position, showCompass, showZoom, visualizePitch, }?: NavigationControlProps): null;
23
+ type GeolocateControlProps = GeolocateControlOptions & {
24
+ position?: ControlPosition;
25
+ };
26
+ declare function GeolocateControl({ position, positionOptions, fitBoundsOptions, trackUserLocation, showAccuracyCircle, showUserLocation, }?: GeolocateControlProps): null;
27
+ type FullscreenControlProps = FullscreenControlOptions & {
28
+ position?: ControlPosition;
29
+ };
30
+ declare function FullscreenControl({ position, container, }?: FullscreenControlProps): null;
31
+ type ScaleControlProps = ScaleControlOptions & {
32
+ position?: ControlPosition;
33
+ };
34
+ declare function ScaleControl({ position, maxWidth, unit, }?: ScaleControlProps): null;
35
+ type AttributionControlProps = AttributionControlOptions & {
36
+ position?: ControlPosition;
37
+ };
38
+ declare function AttributionControl({ position, compact, customAttribution, }?: AttributionControlProps): null;
39
+
40
+ type LayerProps = LayerSpecification & {
41
+ beforeId?: string;
42
+ };
43
+ declare function Layer({ beforeId, ...layerSpec }: LayerProps): null;
44
+
45
+ declare const HANDLER_NAMES: {
46
+ readonly onClick: "click";
47
+ readonly onDblClick: "dblclick";
48
+ readonly onMouseDown: "mousedown";
49
+ readonly onMouseUp: "mouseup";
50
+ readonly onMouseMove: "mousemove";
51
+ readonly onMouseEnter: "mouseenter";
52
+ readonly onMouseLeave: "mouseleave";
53
+ readonly onMouseOver: "mouseover";
54
+ readonly onMouseOut: "mouseout";
55
+ readonly onContextMenu: "contextmenu";
56
+ readonly onWheel: "wheel";
57
+ readonly onTouchStart: "touchstart";
58
+ readonly onTouchEnd: "touchend";
59
+ readonly onTouchMove: "touchmove";
60
+ readonly onTouchCancel: "touchcancel";
61
+ readonly onMoveStart: "movestart";
62
+ readonly onMove: "move";
63
+ readonly onMoveEnd: "moveend";
64
+ readonly onZoomStart: "zoomstart";
65
+ readonly onZoom: "zoom";
66
+ readonly onZoomEnd: "zoomend";
67
+ readonly onRotateStart: "rotatestart";
68
+ readonly onRotate: "rotate";
69
+ readonly onRotateEnd: "rotateend";
70
+ readonly onPitchStart: "pitchstart";
71
+ readonly onPitch: "pitch";
72
+ readonly onPitchEnd: "pitchend";
73
+ readonly onDragStart: "dragstart";
74
+ readonly onDrag: "drag";
75
+ readonly onDragEnd: "dragend";
76
+ readonly onError: "error";
77
+ readonly onIdle: "idle";
78
+ readonly onRender: "render";
79
+ readonly onResize: "resize";
80
+ readonly onData: "data";
81
+ readonly onStyleData: "styledata";
82
+ readonly onSourceData: "sourcedata";
83
+ };
84
+ type HandlerKey = keyof typeof HANDLER_NAMES;
85
+ type MapEventHandler = (e: any) => void;
86
+ type MapEventProps = {
87
+ [K in HandlerKey]?: MapEventHandler;
88
+ };
89
+ type MapProps = Omit<GeoloniaMapOptions, "container"> & MapEventProps & {
90
+ id?: string;
91
+ className?: string;
92
+ containerStyle?: CSSProperties;
93
+ interactiveLayerIds?: string[];
94
+ cursor?: string;
95
+ /** Camera transition style for reactive center/zoom/bearing/pitch changes. Default `"fly"`. */
96
+ transitionType?: "fly" | "jump";
97
+ onLoad?: (map: GeoloniaMap) => void;
98
+ children?: ReactNode;
99
+ };
100
+ declare const Map: react.ForwardRefExoticComponent<Omit<GeoloniaMapOptions, "container"> & MapEventProps & {
101
+ id?: string;
102
+ className?: string;
103
+ containerStyle?: CSSProperties;
104
+ interactiveLayerIds?: string[];
105
+ cursor?: string;
106
+ /** Camera transition style for reactive center/zoom/bearing/pitch changes. Default `"fly"`. */
107
+ transitionType?: "fly" | "jump";
108
+ onLoad?: (map: GeoloniaMap) => void;
109
+ children?: ReactNode;
110
+ } & react.RefAttributes<GeoloniaMap | null>>;
111
+
112
+ type MapProviderProps = {
113
+ children?: ReactNode;
114
+ };
115
+ declare function MapProvider({ children }: MapProviderProps): react_jsx_runtime.JSX.Element;
116
+
117
+ type MarkerEventHandler = (e: any) => void;
118
+ type MarkerProps = {
119
+ lat: number;
120
+ lng: number;
121
+ color?: string;
122
+ openPopup?: boolean;
123
+ draggable?: boolean;
124
+ rotation?: number;
125
+ offset?: PointLike;
126
+ anchor?: PositionAnchor;
127
+ rotationAlignment?: Alignment;
128
+ pitchAlignment?: Alignment;
129
+ className?: string;
130
+ onClick?: (e: MouseEvent) => void;
131
+ onDragStart?: MarkerEventHandler;
132
+ onDrag?: MarkerEventHandler;
133
+ onDragEnd?: MarkerEventHandler;
134
+ children?: ReactNode;
135
+ };
136
+ declare function Marker(props: MarkerProps): react.ReactPortal | null;
137
+
138
+ type PopupProps = {
139
+ lat: number;
140
+ lng: number;
141
+ anchor?: PositionAnchor;
142
+ offset?: PointLike;
143
+ closeButton?: boolean;
144
+ closeOnClick?: boolean;
145
+ closeOnMove?: boolean;
146
+ maxWidth?: string;
147
+ className?: string;
148
+ children?: ReactNode;
149
+ onClose?: () => void;
150
+ };
151
+ declare function Popup(props: PopupProps): react.ReactPortal;
152
+
153
+ type SourceProps = (SourceSpecification | CanvasSourceSpecification) & {
154
+ id: string;
155
+ children?: ReactNode;
156
+ };
157
+ declare function Source({ id, children, ...spec }: SourceProps): react_jsx_runtime.JSX.Element;
158
+
159
+ declare const MapContext: react.Context<GeoloniaMap | null>;
160
+ type MapCollection = {
161
+ current?: GeoloniaMap;
162
+ maps: Record<string, GeoloniaMap>;
163
+ };
164
+ type MapRegistry = {
165
+ maps: Record<string, GeoloniaMap>;
166
+ register: (id: string, map: GeoloniaMap) => void;
167
+ unregister: (id: string) => void;
168
+ };
169
+ declare const MapProviderContext: react.Context<MapRegistry | null>;
170
+ declare function useMap(): GeoloniaMap;
171
+ declare function useMaps(): MapCollection;
172
+
173
+ declare const SourceContext: react.Context<string | null>;
174
+ declare function useSourceId(): string | null;
175
+
176
+ export { AttributionControl, type AttributionControlProps, Control, type ControlPosition, type ControlProps, FullscreenControl, type FullscreenControlProps, GeolocateControl, type GeolocateControlProps, Layer, type LayerProps, Map, type MapCollection, MapContext, type MapEventProps, type MapProps, MapProvider, MapProviderContext, type MapProviderProps, type MapRegistry, Marker, type MarkerProps, NavigationControl, type NavigationControlProps, Popup, type PopupProps, ScaleControl, type ScaleControlProps, Source, SourceContext, type SourceProps, useControl, useMap, useMaps, useSourceId };
@@ -0,0 +1,176 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, CSSProperties } from 'react';
3
+ import { Map as Map$1, AttributionControlOptions, FullscreenControlOptions, GeolocateControlOptions, NavigationControlOptions, ScaleControlOptions, IControl, LayerSpecification, PointLike, PositionAnchor, Alignment, SourceSpecification, CanvasSourceSpecification } from 'maplibre-gl';
4
+ import { GeoloniaMapOptions, GeoloniaMap } from '@geolonia/maps-core';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
+
7
+ type ControlPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
8
+ type ControlProps = {
9
+ position?: ControlPosition;
10
+ onAdd?: (map: Map$1) => HTMLElement;
11
+ onRemove?: (map: Map$1) => void;
12
+ children?: ReactNode;
13
+ };
14
+ declare function Control({ position, onAdd, onRemove, children, }: ControlProps): react.ReactPortal | null;
15
+
16
+ declare function useControl<T extends IControl>(factory: () => T, options?: {
17
+ position?: ControlPosition;
18
+ }): void;
19
+ type NavigationControlProps = NavigationControlOptions & {
20
+ position?: ControlPosition;
21
+ };
22
+ declare function NavigationControl({ position, showCompass, showZoom, visualizePitch, }?: NavigationControlProps): null;
23
+ type GeolocateControlProps = GeolocateControlOptions & {
24
+ position?: ControlPosition;
25
+ };
26
+ declare function GeolocateControl({ position, positionOptions, fitBoundsOptions, trackUserLocation, showAccuracyCircle, showUserLocation, }?: GeolocateControlProps): null;
27
+ type FullscreenControlProps = FullscreenControlOptions & {
28
+ position?: ControlPosition;
29
+ };
30
+ declare function FullscreenControl({ position, container, }?: FullscreenControlProps): null;
31
+ type ScaleControlProps = ScaleControlOptions & {
32
+ position?: ControlPosition;
33
+ };
34
+ declare function ScaleControl({ position, maxWidth, unit, }?: ScaleControlProps): null;
35
+ type AttributionControlProps = AttributionControlOptions & {
36
+ position?: ControlPosition;
37
+ };
38
+ declare function AttributionControl({ position, compact, customAttribution, }?: AttributionControlProps): null;
39
+
40
+ type LayerProps = LayerSpecification & {
41
+ beforeId?: string;
42
+ };
43
+ declare function Layer({ beforeId, ...layerSpec }: LayerProps): null;
44
+
45
+ declare const HANDLER_NAMES: {
46
+ readonly onClick: "click";
47
+ readonly onDblClick: "dblclick";
48
+ readonly onMouseDown: "mousedown";
49
+ readonly onMouseUp: "mouseup";
50
+ readonly onMouseMove: "mousemove";
51
+ readonly onMouseEnter: "mouseenter";
52
+ readonly onMouseLeave: "mouseleave";
53
+ readonly onMouseOver: "mouseover";
54
+ readonly onMouseOut: "mouseout";
55
+ readonly onContextMenu: "contextmenu";
56
+ readonly onWheel: "wheel";
57
+ readonly onTouchStart: "touchstart";
58
+ readonly onTouchEnd: "touchend";
59
+ readonly onTouchMove: "touchmove";
60
+ readonly onTouchCancel: "touchcancel";
61
+ readonly onMoveStart: "movestart";
62
+ readonly onMove: "move";
63
+ readonly onMoveEnd: "moveend";
64
+ readonly onZoomStart: "zoomstart";
65
+ readonly onZoom: "zoom";
66
+ readonly onZoomEnd: "zoomend";
67
+ readonly onRotateStart: "rotatestart";
68
+ readonly onRotate: "rotate";
69
+ readonly onRotateEnd: "rotateend";
70
+ readonly onPitchStart: "pitchstart";
71
+ readonly onPitch: "pitch";
72
+ readonly onPitchEnd: "pitchend";
73
+ readonly onDragStart: "dragstart";
74
+ readonly onDrag: "drag";
75
+ readonly onDragEnd: "dragend";
76
+ readonly onError: "error";
77
+ readonly onIdle: "idle";
78
+ readonly onRender: "render";
79
+ readonly onResize: "resize";
80
+ readonly onData: "data";
81
+ readonly onStyleData: "styledata";
82
+ readonly onSourceData: "sourcedata";
83
+ };
84
+ type HandlerKey = keyof typeof HANDLER_NAMES;
85
+ type MapEventHandler = (e: any) => void;
86
+ type MapEventProps = {
87
+ [K in HandlerKey]?: MapEventHandler;
88
+ };
89
+ type MapProps = Omit<GeoloniaMapOptions, "container"> & MapEventProps & {
90
+ id?: string;
91
+ className?: string;
92
+ containerStyle?: CSSProperties;
93
+ interactiveLayerIds?: string[];
94
+ cursor?: string;
95
+ /** Camera transition style for reactive center/zoom/bearing/pitch changes. Default `"fly"`. */
96
+ transitionType?: "fly" | "jump";
97
+ onLoad?: (map: GeoloniaMap) => void;
98
+ children?: ReactNode;
99
+ };
100
+ declare const Map: react.ForwardRefExoticComponent<Omit<GeoloniaMapOptions, "container"> & MapEventProps & {
101
+ id?: string;
102
+ className?: string;
103
+ containerStyle?: CSSProperties;
104
+ interactiveLayerIds?: string[];
105
+ cursor?: string;
106
+ /** Camera transition style for reactive center/zoom/bearing/pitch changes. Default `"fly"`. */
107
+ transitionType?: "fly" | "jump";
108
+ onLoad?: (map: GeoloniaMap) => void;
109
+ children?: ReactNode;
110
+ } & react.RefAttributes<GeoloniaMap | null>>;
111
+
112
+ type MapProviderProps = {
113
+ children?: ReactNode;
114
+ };
115
+ declare function MapProvider({ children }: MapProviderProps): react_jsx_runtime.JSX.Element;
116
+
117
+ type MarkerEventHandler = (e: any) => void;
118
+ type MarkerProps = {
119
+ lat: number;
120
+ lng: number;
121
+ color?: string;
122
+ openPopup?: boolean;
123
+ draggable?: boolean;
124
+ rotation?: number;
125
+ offset?: PointLike;
126
+ anchor?: PositionAnchor;
127
+ rotationAlignment?: Alignment;
128
+ pitchAlignment?: Alignment;
129
+ className?: string;
130
+ onClick?: (e: MouseEvent) => void;
131
+ onDragStart?: MarkerEventHandler;
132
+ onDrag?: MarkerEventHandler;
133
+ onDragEnd?: MarkerEventHandler;
134
+ children?: ReactNode;
135
+ };
136
+ declare function Marker(props: MarkerProps): react.ReactPortal | null;
137
+
138
+ type PopupProps = {
139
+ lat: number;
140
+ lng: number;
141
+ anchor?: PositionAnchor;
142
+ offset?: PointLike;
143
+ closeButton?: boolean;
144
+ closeOnClick?: boolean;
145
+ closeOnMove?: boolean;
146
+ maxWidth?: string;
147
+ className?: string;
148
+ children?: ReactNode;
149
+ onClose?: () => void;
150
+ };
151
+ declare function Popup(props: PopupProps): react.ReactPortal;
152
+
153
+ type SourceProps = (SourceSpecification | CanvasSourceSpecification) & {
154
+ id: string;
155
+ children?: ReactNode;
156
+ };
157
+ declare function Source({ id, children, ...spec }: SourceProps): react_jsx_runtime.JSX.Element;
158
+
159
+ declare const MapContext: react.Context<GeoloniaMap | null>;
160
+ type MapCollection = {
161
+ current?: GeoloniaMap;
162
+ maps: Record<string, GeoloniaMap>;
163
+ };
164
+ type MapRegistry = {
165
+ maps: Record<string, GeoloniaMap>;
166
+ register: (id: string, map: GeoloniaMap) => void;
167
+ unregister: (id: string) => void;
168
+ };
169
+ declare const MapProviderContext: react.Context<MapRegistry | null>;
170
+ declare function useMap(): GeoloniaMap;
171
+ declare function useMaps(): MapCollection;
172
+
173
+ declare const SourceContext: react.Context<string | null>;
174
+ declare function useSourceId(): string | null;
175
+
176
+ export { AttributionControl, type AttributionControlProps, Control, type ControlPosition, type ControlProps, FullscreenControl, type FullscreenControlProps, GeolocateControl, type GeolocateControlProps, Layer, type LayerProps, Map, type MapCollection, MapContext, type MapEventProps, type MapProps, MapProvider, MapProviderContext, type MapProviderProps, type MapRegistry, Marker, type MarkerProps, NavigationControl, type NavigationControlProps, Popup, type PopupProps, ScaleControl, type ScaleControlProps, Source, SourceContext, type SourceProps, useControl, useMap, useMaps, useSourceId };