@lugg/maps 1.0.0-beta.0 → 1.0.0-beta.1

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.
Files changed (60) hide show
  1. package/README.md +1 -1
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/luggmaps/LuggCalloutView.kt +74 -0
  4. package/android/src/main/java/com/luggmaps/LuggCalloutViewManager.kt +38 -0
  5. package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +0 -11
  6. package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +73 -51
  7. package/android/src/main/java/com/luggmaps/LuggPackage.kt +8 -1
  8. package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +181 -5
  9. package/ios/LuggCalloutView.h +23 -0
  10. package/ios/LuggCalloutView.mm +145 -0
  11. package/ios/LuggMarkerView.h +2 -0
  12. package/ios/LuggMarkerView.mm +17 -2
  13. package/ios/core/AppleMapProvider.mm +152 -8
  14. package/ios/core/GoogleMapProvider.mm +114 -5
  15. package/ios/core/LuggAnnotationView.h +12 -0
  16. package/ios/core/LuggAnnotationView.mm +55 -0
  17. package/lib/module/MapProvider.web.js +3 -1
  18. package/lib/module/MapProvider.web.js.map +1 -1
  19. package/lib/module/MapView.web.js +15 -2
  20. package/lib/module/MapView.web.js.map +1 -1
  21. package/lib/module/components/Marker.js +21 -4
  22. package/lib/module/components/Marker.js.map +1 -1
  23. package/lib/module/components/Marker.web.js +86 -22
  24. package/lib/module/components/Marker.web.js.map +1 -1
  25. package/lib/module/components/index.js.map +1 -1
  26. package/lib/module/fabric/LuggCalloutViewNativeComponent.ts +20 -0
  27. package/lib/module/index.js.map +1 -1
  28. package/lib/typescript/src/MapProvider.web.d.ts +6 -0
  29. package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
  30. package/lib/typescript/src/MapView.web.d.ts.map +1 -1
  31. package/lib/typescript/src/components/GeoJson.types.d.ts +11 -1
  32. package/lib/typescript/src/components/GeoJson.types.d.ts.map +1 -1
  33. package/lib/typescript/src/components/Marker.d.ts +1 -1
  34. package/lib/typescript/src/components/Marker.d.ts.map +1 -1
  35. package/lib/typescript/src/components/Marker.types.d.ts +27 -1
  36. package/lib/typescript/src/components/Marker.types.d.ts.map +1 -1
  37. package/lib/typescript/src/components/Marker.web.d.ts +1 -1
  38. package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
  39. package/lib/typescript/src/components/index.d.ts +1 -1
  40. package/lib/typescript/src/components/index.d.ts.map +1 -1
  41. package/lib/typescript/src/components/index.web.d.ts +1 -1
  42. package/lib/typescript/src/components/index.web.d.ts.map +1 -1
  43. package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts +13 -0
  44. package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts.map +1 -0
  45. package/lib/typescript/src/index.d.ts +2 -2
  46. package/lib/typescript/src/index.d.ts.map +1 -1
  47. package/lib/typescript/src/index.web.d.ts +2 -2
  48. package/lib/typescript/src/index.web.d.ts.map +1 -1
  49. package/package.json +2 -1
  50. package/src/MapProvider.web.tsx +11 -1
  51. package/src/MapView.web.tsx +26 -2
  52. package/src/components/GeoJson.types.ts +12 -1
  53. package/src/components/Marker.tsx +29 -1
  54. package/src/components/Marker.types.ts +28 -1
  55. package/src/components/Marker.web.tsx +113 -23
  56. package/src/components/index.ts +1 -0
  57. package/src/components/index.web.ts +1 -1
  58. package/src/fabric/LuggCalloutViewNativeComponent.ts +20 -0
  59. package/src/index.ts +2 -0
  60. package/src/index.web.ts +2 -1
@@ -1,3 +1,3 @@
1
1
  import type { MarkerProps } from './Marker.types';
2
- export declare const Marker: ({ coordinate, title, anchor, zIndex, rotate, scale, draggable, onPress, onDragStart, onDragChange, onDragEnd, children, }: MarkerProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Marker: ({ coordinate, title, description, anchor, zIndex, rotate, scale, draggable, onPress, onDragStart, onDragChange, onDragEnd, callout, calloutOptions, children, }: MarkerProps) => import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=Marker.web.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Marker.web.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAqBlD,eAAO,MAAM,MAAM,GAAI,2HAapB,WAAW,4CAkFb,CAAC"}
1
+ {"version":3,"file":"Marker.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Marker.web.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA+ClD,eAAO,MAAM,MAAM,GAAI,iKAgBpB,WAAW,4CAqIb,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export { Marker } from './Marker';
2
- export type { MarkerProps, MarkerPressEvent, MarkerDragEvent, } from './Marker.types';
2
+ export type { CalloutOptions, MarkerProps, MarkerPressEvent, MarkerDragEvent, } from './Marker.types';
3
3
  export { Polygon } from './Polygon';
4
4
  export type { PolygonProps } from './Polygon.types';
5
5
  export { Polyline } from './Polyline';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EACV,aAAa,EACb,cAAc,EACd,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EACV,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EACV,aAAa,EACb,cAAc,EACd,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
@@ -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';
@@ -1 +1 @@
1
- {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/components/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/components/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { ViewProps, HostComponent } from 'react-native';
2
+ import type { Double, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
3
+ export interface Point {
4
+ x: Double;
5
+ y: Double;
6
+ }
7
+ export interface NativeProps extends ViewProps {
8
+ bubbled?: WithDefault<boolean, true>;
9
+ anchor?: Point;
10
+ }
11
+ declare const _default: HostComponent<NativeProps>;
12
+ export default _default;
13
+ //# sourceMappingURL=LuggCalloutViewNativeComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LuggCalloutViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/fabric/LuggCalloutViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EACV,MAAM,EACN,WAAW,EACZ,MAAM,2CAA2C,CAAC;AAEnD,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB;wBAII,aAAa,CAAC,WAAW,CAAC;AAF/B,wBAEgC"}
@@ -2,7 +2,7 @@ export { MapView } from './MapView';
2
2
  export { MapProvider } from './MapProvider';
3
3
  export type { MapProviderProps } from './MapProvider.types';
4
4
  export { Marker } from './components';
5
- export type { MarkerProps, MarkerPressEvent, MarkerDragEvent, } from './components';
5
+ export type { CalloutOptions, MarkerProps, MarkerPressEvent, MarkerDragEvent, } from './components';
6
6
  export { Polygon } from './components';
7
7
  export type { PolygonProps } from './components';
8
8
  export { Polyline } from './components';
@@ -11,5 +11,5 @@ export { GeoJson } from './components';
11
11
  export type { GeoJsonProps } from './components';
12
12
  export type { MapViewProps, MapViewRef, MoveCameraOptions, FitCoordinatesOptions, SetEdgeInsetsOptions, CameraEventPayload, MapCameraEvent, MapPressEvent, } from './MapView.types';
13
13
  export type { MapProvider as MapProviderType, MapTheme, Coordinate, Point, EdgeInsets, PressEventPayload, } from './types';
14
- export type { GeoJSON, Feature, FeatureCollection, Geometry, Position, } from './components/GeoJson.types';
14
+ export type { GeoJSON, Feature, FeatureCollection, FeatureProperties, Geometry, Position, } from './components/GeoJson.types';
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY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,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,WAAW,IAAI,eAAe,EAC9B,QAAQ,EACR,UAAU,EACV,KAAK,EACL,UAAU,EACV,iBAAiB,GAClB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,EACR,QAAQ,GACT,MAAM,4BAA4B,CAAC"}
@@ -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';
@@ -11,5 +11,5 @@ export { GeoJson } from './components/index.web';
11
11
  export type { GeoJsonProps } from './components/index.web';
12
12
  export type { MapViewProps, MapViewRef, MoveCameraOptions, FitCoordinatesOptions, CameraEventPayload, } from './MapView.types';
13
13
  export type { MapProvider as MapProviderType, Coordinate, Point, EdgeInsets, } from './types';
14
- export type { GeoJSON, Feature, FeatureCollection, Geometry, Position, } from './components/GeoJson.types';
14
+ export type { GeoJSON, Feature, FeatureCollection, FeatureProperties, Geometry, Position, } from './components/GeoJson.types';
15
15
  //# sourceMappingURL=index.web.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../src/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAA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AAwB,CAAC;AAClD,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,WAAW,IAAI,eAAe,EAC9B,UAAU,EACV,KAAK,EACL,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,EACR,QAAQ,GACT,MAAM,4BAA4B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lugg/maps",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "Universal maps for React Native.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -147,6 +147,7 @@
147
147
  "componentProvider": {
148
148
  "LuggMapView": "LuggMapView",
149
149
  "LuggMarkerView": "LuggMarkerView",
150
+ "LuggCalloutView": "LuggCalloutView",
150
151
  "LuggMapWrapperView": "LuggMapWrapperView",
151
152
  "LuggPolylineView": "LuggPolylineView",
152
153
  "LuggPolygonView": "LuggPolygonView"
@@ -2,11 +2,21 @@ import { createContext, useContext } from 'react';
2
2
  import { APIProvider } from '@vis.gl/react-google-maps';
3
3
  import type { MapProviderProps } from './MapProvider.types';
4
4
 
5
+ type CalloutCloseListener = () => void;
6
+
5
7
  export const MapContext = createContext<{
6
8
  map: google.maps.Map | null;
7
9
  isDragging: boolean;
8
10
  moveCamera: (coordinate: { latitude: number; longitude: number }) => void;
9
- }>({ map: null, isDragging: false, moveCamera: () => {} });
11
+ onCalloutClose: (listener: CalloutCloseListener) => () => void;
12
+ closeCallouts: (except?: CalloutCloseListener) => void;
13
+ }>({
14
+ map: null,
15
+ isDragging: false,
16
+ moveCamera: () => {},
17
+ onCalloutClose: () => () => {},
18
+ closeCallouts: () => {},
19
+ });
10
20
 
11
21
  export const useMapContext = () => useContext(MapContext);
12
22
 
@@ -285,6 +285,23 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
285
285
  const longPressTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
286
286
  const longPressFired = useRef(false);
287
287
 
288
+ const calloutListeners = useRef(new Set<() => void>()).current;
289
+ const onCalloutClose = useCallback(
290
+ (listener: () => void) => {
291
+ calloutListeners.add(listener);
292
+ return () => calloutListeners.delete(listener);
293
+ },
294
+ [calloutListeners]
295
+ );
296
+ const closeCallouts = useCallback(
297
+ (except?: () => void) => {
298
+ calloutListeners.forEach((l) => {
299
+ if (l !== except) l();
300
+ });
301
+ },
302
+ [calloutListeners]
303
+ );
304
+
288
305
  const getPoint = useCallback((domEvent?: Event) => {
289
306
  const el = containerRef.current as unknown as HTMLElement | null;
290
307
  if (!domEvent || !el) return { x: 0, y: 0 };
@@ -299,6 +316,7 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
299
316
  longPressFired.current = false;
300
317
  return;
301
318
  }
319
+ closeCallouts();
302
320
  const latLng = event.detail.latLng;
303
321
  if (!onPress || !latLng) return;
304
322
  onPress(
@@ -308,7 +326,7 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
308
326
  })
309
327
  );
310
328
  },
311
- [onPress, getPoint]
329
+ [onPress, getPoint, closeCallouts]
312
330
  );
313
331
 
314
332
  const handleMouseDown = useCallback(
@@ -419,7 +437,13 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
419
437
 
420
438
  return (
421
439
  <MapContext.Provider
422
- value={{ map, isDragging, moveCamera: panToCoordinate }}
440
+ value={{
441
+ map,
442
+ isDragging,
443
+ moveCamera: panToCoordinate,
444
+ onCalloutClose,
445
+ closeCallouts,
446
+ }}
423
447
  >
424
448
  <View ref={containerRef} style={style}>
425
449
  <Map
@@ -56,11 +56,22 @@ export type Geometry =
56
56
  | MultiPolygon
57
57
  | GeometryCollection;
58
58
 
59
+ export interface FeatureProperties {
60
+ 'title'?: string;
61
+ 'description'?: string;
62
+ 'fill'?: string;
63
+ 'fill-opacity'?: number;
64
+ 'stroke'?: string;
65
+ 'stroke-width'?: number;
66
+ 'stroke-opacity'?: number;
67
+ [key: string]: unknown;
68
+ }
69
+
59
70
  export interface Feature<G extends Geometry = Geometry> {
60
71
  type: 'Feature';
61
72
  id?: string | number;
62
73
  geometry: G;
63
- properties: Record<string, any> | null;
74
+ properties: FeatureProperties | null;
64
75
  }
65
76
 
66
77
  export interface FeatureCollection<G extends Geometry = Geometry> {
@@ -1,9 +1,11 @@
1
- import React from 'react';
1
+ import React, { isValidElement } from 'react';
2
2
  import { StyleSheet } from 'react-native';
3
3
  import LuggMarkerViewNativeComponent from '../fabric/LuggMarkerViewNativeComponent';
4
+ import LuggCalloutViewNativeComponent from '../fabric/LuggCalloutViewNativeComponent';
4
5
  import type { MarkerProps } from './Marker.types';
5
6
 
6
7
  export type {
8
+ CalloutOptions,
7
9
  MarkerProps,
8
10
  MarkerPressEvent,
9
11
  MarkerDragEvent,
@@ -38,9 +40,19 @@ export class Marker extends React.PureComponent<MarkerProps> {
38
40
  onDragStart,
39
41
  onDragChange,
40
42
  onDragEnd,
43
+ callout,
44
+ calloutOptions,
41
45
  children,
42
46
  } = this.props;
43
47
 
48
+ const calloutContent = callout
49
+ ? isValidElement(callout)
50
+ ? callout
51
+ : React.createElement(callout)
52
+ : null;
53
+ const calloutBubbled = calloutOptions?.bubbled ?? true;
54
+ const calloutAnchor = calloutOptions?.anchor;
55
+
44
56
  return (
45
57
  <LuggMarkerViewNativeComponent
46
58
  style={this.getStyle(zIndex)}
@@ -59,6 +71,15 @@ export class Marker extends React.PureComponent<MarkerProps> {
59
71
  onMarkerDragEnd={onDragEnd}
60
72
  >
61
73
  {children}
74
+ {calloutContent && (
75
+ <LuggCalloutViewNativeComponent
76
+ style={calloutStyles.callout}
77
+ bubbled={calloutBubbled}
78
+ anchor={calloutAnchor}
79
+ >
80
+ {calloutContent}
81
+ </LuggCalloutViewNativeComponent>
82
+ )}
62
83
  </LuggMarkerViewNativeComponent>
63
84
  );
64
85
  }
@@ -70,3 +91,10 @@ const styles = StyleSheet.create({
70
91
  pointerEvents: 'box-none',
71
92
  },
72
93
  });
94
+
95
+ const calloutStyles = StyleSheet.create({
96
+ callout: {
97
+ position: 'absolute',
98
+ pointerEvents: 'box-none',
99
+ },
100
+ });
@@ -1,10 +1,28 @@
1
- import type { ReactNode } from 'react';
1
+ import type { ComponentType, ReactElement, ReactNode } from 'react';
2
2
  import type { NativeSyntheticEvent } from 'react-native';
3
3
  import type { Coordinate, Point, PressEventPayload } from '../types';
4
4
 
5
5
  export type MarkerPressEvent = NativeSyntheticEvent<PressEventPayload>;
6
6
  export type MarkerDragEvent = NativeSyntheticEvent<PressEventPayload>;
7
7
 
8
+ export interface CalloutOptions {
9
+ /**
10
+ * Whether to wrap the callout in the native platform bubble.
11
+ * Set to `false` to render custom content directly without the native callout chrome.
12
+ *
13
+ * @default true
14
+ */
15
+ bubbled?: boolean;
16
+ /**
17
+ * Anchor point for the callout relative to the marker position.
18
+ * `{x: 0.5, y: 1}` places the bottom-center of the callout at the marker.
19
+ *
20
+ * @note Not supported on web.
21
+ * @default {x: 0.5, y: 1}
22
+ */
23
+ anchor?: Point;
24
+ }
25
+
8
26
  export interface MarkerProps {
9
27
  /**
10
28
  * Name used for debugging purposes
@@ -68,6 +86,15 @@ export interface MarkerProps {
68
86
  * Called when marker drag ends
69
87
  */
70
88
  onDragEnd?: (event: MarkerDragEvent) => void;
89
+ /**
90
+ * Callout content displayed when marker is tapped.
91
+ * Pass a `ReactElement` for inline content or a `ComponentType` to be instantiated.
92
+ */
93
+ callout?: ComponentType<unknown> | ReactElement;
94
+ /**
95
+ * Callout configuration options.
96
+ */
97
+ calloutOptions?: CalloutOptions;
71
98
  /**
72
99
  * Custom marker view
73
100
  */
@@ -1,8 +1,44 @@
1
- import { useCallback, useEffect, useRef } from 'react';
2
- import { AdvancedMarker } from '@vis.gl/react-google-maps';
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 position = dragPositionRef.current ?? {
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
- <AdvancedMarker
102
- position={position}
103
- title={title}
104
- zIndex={zIndex}
105
- anchorLeft={anchor ? toWebAnchor(anchor.x) : undefined}
106
- anchorTop={anchor ? toWebAnchor(anchor.y) : undefined}
107
- clickable
108
- draggable={draggable}
109
- onClick={handleClick}
110
- onDragStart={handleDragStart}
111
- onDrag={handleDrag}
112
- onDragEnd={handleDragEnd}
113
- style={
114
- transforms.length > 0 ? { transform: transforms.join(' ') } : undefined
115
- }
116
- >
117
- {children}
118
- </AdvancedMarker>
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
  };
@@ -1,5 +1,6 @@
1
1
  export { Marker } from './Marker';
2
2
  export type {
3
+ CalloutOptions,
3
4
  MarkerProps,
4
5
  MarkerPressEvent,
5
6
  MarkerDragEvent,
@@ -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';