@lugg/maps 1.0.0-beta.0 → 1.0.0-beta.2
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 +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/luggmaps/LuggCalloutView.kt +74 -0
- package/android/src/main/java/com/luggmaps/LuggCalloutViewManager.kt +38 -0
- package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +0 -11
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +73 -51
- package/android/src/main/java/com/luggmaps/LuggPackage.kt +8 -1
- package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +181 -5
- package/ios/LuggCalloutView.h +23 -0
- package/ios/LuggCalloutView.mm +145 -0
- package/ios/LuggMarkerView.h +2 -0
- package/ios/LuggMarkerView.mm +17 -2
- package/ios/core/AppleMapProvider.mm +211 -24
- package/ios/core/GoogleMapProvider.mm +125 -5
- package/ios/core/LuggAnnotationView.h +12 -0
- package/ios/core/LuggAnnotationView.mm +55 -0
- package/lib/module/MapProvider.web.js +3 -1
- package/lib/module/MapProvider.web.js.map +1 -1
- package/lib/module/MapView.web.js +15 -2
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/Marker.js +21 -4
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.web.js +86 -22
- package/lib/module/components/Marker.web.js.map +1 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/fabric/LuggCalloutViewNativeComponent.ts +20 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/MapProvider.web.d.ts +6 -0
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts.map +1 -1
- package/lib/typescript/src/components/GeoJson.types.d.ts +11 -1
- package/lib/typescript/src/components/GeoJson.types.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.d.ts +1 -1
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.types.d.ts +27 -1
- package/lib/typescript/src/components/Marker.types.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.web.d.ts +1 -1
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts +1 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/index.web.d.ts +1 -1
- package/lib/typescript/src/components/index.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts +13 -0
- package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +2 -2
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/MapProvider.web.tsx +11 -1
- package/src/MapView.web.tsx +26 -2
- package/src/components/GeoJson.types.ts +12 -1
- package/src/components/Marker.tsx +29 -1
- package/src/components/Marker.types.ts +28 -1
- package/src/components/Marker.web.tsx +113 -23
- package/src/components/index.ts +1 -0
- package/src/components/index.web.ts +1 -1
- package/src/fabric/LuggCalloutViewNativeComponent.ts +20 -0
- package/src/index.ts +2 -0
- package/src/index.web.ts +2 -1
|
@@ -1,8 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
isValidElement,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import {
|
|
9
|
+
AdvancedMarker,
|
|
10
|
+
InfoWindow,
|
|
11
|
+
useAdvancedMarkerRef,
|
|
12
|
+
} from '@vis.gl/react-google-maps';
|
|
3
13
|
import { useMapContext } from '../MapProvider.web';
|
|
4
14
|
import type { MarkerProps } from './Marker.types';
|
|
5
15
|
|
|
16
|
+
const CALLOUT_ARROW_HEIGHT = 12;
|
|
17
|
+
const UNBUBBLED_CLASS = 'rnm-callout-unbubbled';
|
|
18
|
+
const UNBUBBLED_STYLE_ID = 'rnm-callout-unbubbled-style';
|
|
19
|
+
|
|
20
|
+
function injectUnbubbledStyle() {
|
|
21
|
+
if (document.getElementById(UNBUBBLED_STYLE_ID)) return;
|
|
22
|
+
const style = document.createElement('style');
|
|
23
|
+
style.id = UNBUBBLED_STYLE_ID;
|
|
24
|
+
style.textContent = `
|
|
25
|
+
.gm-style-iw-c:has(.${UNBUBBLED_CLASS}) {
|
|
26
|
+
background: transparent !important;
|
|
27
|
+
box-shadow: none !important;
|
|
28
|
+
padding: 0 !important;
|
|
29
|
+
border-radius: 0 !important;
|
|
30
|
+
}
|
|
31
|
+
.gm-style-iw-d:has(.${UNBUBBLED_CLASS}) {
|
|
32
|
+
overflow: visible !important;
|
|
33
|
+
}
|
|
34
|
+
.gm-style-iw-t:has(.${UNBUBBLED_CLASS})::after,
|
|
35
|
+
.gm-style-iw-t:has(.${UNBUBBLED_CLASS}) .gm-style-iw-tc {
|
|
36
|
+
display: none !important;
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
document.head.appendChild(style);
|
|
40
|
+
}
|
|
41
|
+
|
|
6
42
|
const toWebAnchor = (value: number) => `-${value * 100}%`;
|
|
7
43
|
|
|
8
44
|
const createEvent = (
|
|
@@ -25,6 +61,7 @@ const createEvent = (
|
|
|
25
61
|
export const Marker = ({
|
|
26
62
|
coordinate,
|
|
27
63
|
title,
|
|
64
|
+
description,
|
|
28
65
|
anchor,
|
|
29
66
|
zIndex,
|
|
30
67
|
rotate,
|
|
@@ -34,10 +71,38 @@ export const Marker = ({
|
|
|
34
71
|
onDragStart,
|
|
35
72
|
onDragChange,
|
|
36
73
|
onDragEnd,
|
|
74
|
+
callout,
|
|
75
|
+
calloutOptions,
|
|
37
76
|
children,
|
|
38
77
|
}: MarkerProps) => {
|
|
39
|
-
const { moveCamera } = useMapContext();
|
|
78
|
+
const { moveCamera, onCalloutClose, closeCallouts } = useMapContext();
|
|
40
79
|
const dragPositionRef = useRef<google.maps.LatLngLiteral | null>(null);
|
|
80
|
+
const [markerRef, markerElement] = useAdvancedMarkerRef();
|
|
81
|
+
const [infoWindowOpen, setInfoWindowOpen] = useState(false);
|
|
82
|
+
const calloutBubbled = calloutOptions?.bubbled ?? true;
|
|
83
|
+
|
|
84
|
+
const closeCallout = useCallback(() => setInfoWindowOpen(false), []);
|
|
85
|
+
|
|
86
|
+
useEffect(() => onCalloutClose(closeCallout), [onCalloutClose, closeCallout]);
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (!calloutBubbled) injectUnbubbledStyle();
|
|
90
|
+
}, [calloutBubbled]);
|
|
91
|
+
|
|
92
|
+
const hasCallout = !!(callout || title);
|
|
93
|
+
|
|
94
|
+
const calloutContent = callout
|
|
95
|
+
? isValidElement(callout)
|
|
96
|
+
? callout
|
|
97
|
+
: React.createElement(callout)
|
|
98
|
+
: title
|
|
99
|
+
? React.createElement(
|
|
100
|
+
'div',
|
|
101
|
+
{ style: { fontSize: 14 } },
|
|
102
|
+
React.createElement('div', { style: { fontWeight: 500 } }, title),
|
|
103
|
+
description ? React.createElement('div', null, description) : null
|
|
104
|
+
)
|
|
105
|
+
: null;
|
|
41
106
|
|
|
42
107
|
const transforms: string[] = [];
|
|
43
108
|
if (rotate) transforms.push(`rotate(${rotate}deg)`);
|
|
@@ -51,8 +116,12 @@ export const Marker = ({
|
|
|
51
116
|
: coordinate;
|
|
52
117
|
moveCamera(coord);
|
|
53
118
|
onPress?.(createEvent(e, coordinate));
|
|
119
|
+
if (hasCallout) {
|
|
120
|
+
closeCallouts(closeCallout);
|
|
121
|
+
setInfoWindowOpen((prev) => !prev);
|
|
122
|
+
}
|
|
54
123
|
},
|
|
55
|
-
[moveCamera, onPress, coordinate]
|
|
124
|
+
[moveCamera, onPress, coordinate, hasCallout, closeCallouts, closeCallout]
|
|
56
125
|
);
|
|
57
126
|
|
|
58
127
|
const handleDragStart = useCallback(
|
|
@@ -92,29 +161,50 @@ export const Marker = ({
|
|
|
92
161
|
dragPositionRef.current = null;
|
|
93
162
|
}, [coordinate.latitude, coordinate.longitude]);
|
|
94
163
|
|
|
95
|
-
const
|
|
164
|
+
const latLngPosition = {
|
|
96
165
|
lat: coordinate.latitude,
|
|
97
166
|
lng: coordinate.longitude,
|
|
98
167
|
};
|
|
99
168
|
|
|
169
|
+
const position = dragPositionRef.current ?? latLngPosition;
|
|
170
|
+
|
|
100
171
|
return (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
172
|
+
<>
|
|
173
|
+
<AdvancedMarker
|
|
174
|
+
ref={markerRef}
|
|
175
|
+
position={position}
|
|
176
|
+
title={title}
|
|
177
|
+
zIndex={zIndex}
|
|
178
|
+
anchorLeft={anchor ? toWebAnchor(anchor.x) : undefined}
|
|
179
|
+
anchorTop={anchor ? toWebAnchor(anchor.y) : undefined}
|
|
180
|
+
clickable
|
|
181
|
+
draggable={draggable}
|
|
182
|
+
onClick={handleClick}
|
|
183
|
+
onDragStart={handleDragStart}
|
|
184
|
+
onDrag={handleDrag}
|
|
185
|
+
onDragEnd={handleDragEnd}
|
|
186
|
+
style={
|
|
187
|
+
transforms.length > 0
|
|
188
|
+
? { transform: transforms.join(' ') }
|
|
189
|
+
: undefined
|
|
190
|
+
}
|
|
191
|
+
>
|
|
192
|
+
{children}
|
|
193
|
+
</AdvancedMarker>
|
|
194
|
+
{calloutContent && infoWindowOpen && markerElement && (
|
|
195
|
+
<InfoWindow
|
|
196
|
+
anchor={markerElement}
|
|
197
|
+
pixelOffset={!calloutBubbled ? [0, CALLOUT_ARROW_HEIGHT] : undefined}
|
|
198
|
+
headerDisabled
|
|
199
|
+
onClose={() => setInfoWindowOpen(false)}
|
|
200
|
+
>
|
|
201
|
+
{!calloutBubbled ? (
|
|
202
|
+
<div className={UNBUBBLED_CLASS}>{calloutContent}</div>
|
|
203
|
+
) : (
|
|
204
|
+
calloutContent
|
|
205
|
+
)}
|
|
206
|
+
</InfoWindow>
|
|
207
|
+
)}
|
|
208
|
+
</>
|
|
119
209
|
);
|
|
120
210
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Marker } from './Marker.web';
|
|
2
2
|
export { Polygon } from './Polygon.web';
|
|
3
3
|
export { Polyline } from './Polyline.web';
|
|
4
|
-
export type { MarkerProps } from './Marker.types';
|
|
4
|
+
export type { CalloutOptions, MarkerProps } from './Marker.types';
|
|
5
5
|
export type { PolygonProps } from './Polygon.types';
|
|
6
6
|
export type { PolylineProps } from './Polyline.types';
|
|
7
7
|
export { GeoJson } from './GeoJson';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { codegenNativeComponent } from 'react-native';
|
|
2
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
Double,
|
|
5
|
+
WithDefault,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
|
|
8
|
+
export interface Point {
|
|
9
|
+
x: Double;
|
|
10
|
+
y: Double;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface NativeProps extends ViewProps {
|
|
14
|
+
bubbled?: WithDefault<boolean, true>;
|
|
15
|
+
anchor?: Point;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default codegenNativeComponent<NativeProps>(
|
|
19
|
+
'LuggCalloutView'
|
|
20
|
+
) as HostComponent<NativeProps>;
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { MapProvider } from './MapProvider';
|
|
|
3
3
|
export type { MapProviderProps } from './MapProvider.types';
|
|
4
4
|
export { Marker } from './components';
|
|
5
5
|
export type {
|
|
6
|
+
CalloutOptions,
|
|
6
7
|
MarkerProps,
|
|
7
8
|
MarkerPressEvent,
|
|
8
9
|
MarkerDragEvent,
|
|
@@ -39,6 +40,7 @@ export type {
|
|
|
39
40
|
GeoJSON,
|
|
40
41
|
Feature,
|
|
41
42
|
FeatureCollection,
|
|
43
|
+
FeatureProperties,
|
|
42
44
|
Geometry,
|
|
43
45
|
Position,
|
|
44
46
|
} from './components/GeoJson.types';
|
package/src/index.web.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { MapView } from './MapView.web';
|
|
|
2
2
|
export { MapProvider } from './MapProvider.web';
|
|
3
3
|
export type { MapProviderProps } from './MapProvider.types';
|
|
4
4
|
export { Marker } from './components/index.web';
|
|
5
|
-
export type { MarkerProps } from './components/index.web';
|
|
5
|
+
export type { CalloutOptions, MarkerProps } from './components/index.web';
|
|
6
6
|
export { Polygon } from './components/index.web';
|
|
7
7
|
export type { PolygonProps } from './components/index.web';
|
|
8
8
|
export { Polyline } from './components/index.web';
|
|
@@ -26,6 +26,7 @@ export type {
|
|
|
26
26
|
GeoJSON,
|
|
27
27
|
Feature,
|
|
28
28
|
FeatureCollection,
|
|
29
|
+
FeatureProperties,
|
|
29
30
|
Geometry,
|
|
30
31
|
Position,
|
|
31
32
|
} from './components/GeoJson.types';
|