@lugg/maps 1.0.0-beta.4 → 1.0.0-beta.6

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 (104) hide show
  1. package/android/src/main/java/com/luggmaps/LuggCalloutView.kt +4 -2
  2. package/android/src/main/java/com/luggmaps/LuggCalloutViewManager.kt +4 -3
  3. package/android/src/main/java/com/luggmaps/LuggMapView.kt +40 -0
  4. package/android/src/main/java/com/luggmaps/LuggMapViewManager.kt +31 -0
  5. package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +23 -0
  6. package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +13 -0
  7. package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +166 -21
  8. package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +5 -0
  9. package/android/src/main/java/com/luggmaps/extensions/ViewExtensions.kt +11 -0
  10. package/ios/LuggCalloutView.h +1 -1
  11. package/ios/LuggCalloutView.mm +21 -11
  12. package/ios/LuggMapView.mm +41 -2
  13. package/ios/LuggMarkerView.h +3 -0
  14. package/ios/LuggMarkerView.mm +23 -0
  15. package/ios/core/AppleMapProvider.mm +236 -16
  16. package/ios/core/GoogleMapProvider.mm +91 -18
  17. package/ios/core/MapProviderDelegate.h +8 -1
  18. package/lib/module/MapProvider.web.js +4 -1
  19. package/lib/module/MapProvider.web.js.map +1 -1
  20. package/lib/module/MapView.js +12 -1
  21. package/lib/module/MapView.js.map +1 -1
  22. package/lib/module/MapView.web.js +21 -18
  23. package/lib/module/MapView.web.js.map +1 -1
  24. package/lib/module/components/Circle.web.js +3 -3
  25. package/lib/module/components/Circle.web.js.map +1 -1
  26. package/lib/module/components/GeoJson.js +3 -3
  27. package/lib/module/components/GeoJson.js.map +1 -1
  28. package/lib/module/components/GroundOverlay.web.js +3 -3
  29. package/lib/module/components/GroundOverlay.web.js.map +1 -1
  30. package/lib/module/components/Marker.js +17 -3
  31. package/lib/module/components/Marker.js.map +1 -1
  32. package/lib/module/components/Marker.web.js +23 -10
  33. package/lib/module/components/Marker.web.js.map +1 -1
  34. package/lib/module/components/Polygon.web.js +3 -3
  35. package/lib/module/components/Polygon.web.js.map +1 -1
  36. package/lib/module/components/Polyline.web.js +6 -12
  37. package/lib/module/components/Polyline.web.js.map +1 -1
  38. package/lib/module/components/TileOverlay.web.js +3 -3
  39. package/lib/module/components/TileOverlay.web.js.map +1 -1
  40. package/lib/module/components/index.js.map +1 -1
  41. package/lib/module/fabric/LuggCalloutViewNativeComponent.ts +1 -1
  42. package/lib/module/fabric/LuggMapViewNativeComponent.ts +9 -1
  43. package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +14 -2
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/typescript/src/MapProvider.web.d.ts +3 -2
  46. package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
  47. package/lib/typescript/src/MapView.d.ts +1 -1
  48. package/lib/typescript/src/MapView.d.ts.map +1 -1
  49. package/lib/typescript/src/MapView.types.d.ts +36 -1
  50. package/lib/typescript/src/MapView.types.d.ts.map +1 -1
  51. package/lib/typescript/src/MapView.web.d.ts +1 -1
  52. package/lib/typescript/src/MapView.web.d.ts.map +1 -1
  53. package/lib/typescript/src/components/Circle.web.d.ts +1 -1
  54. package/lib/typescript/src/components/Circle.web.d.ts.map +1 -1
  55. package/lib/typescript/src/components/GeoJson.d.ts +2 -1
  56. package/lib/typescript/src/components/GeoJson.d.ts.map +1 -1
  57. package/lib/typescript/src/components/GroundOverlay.web.d.ts +1 -1
  58. package/lib/typescript/src/components/GroundOverlay.web.d.ts.map +1 -1
  59. package/lib/typescript/src/components/Marker.d.ts +6 -3
  60. package/lib/typescript/src/components/Marker.d.ts.map +1 -1
  61. package/lib/typescript/src/components/Marker.types.d.ts +14 -5
  62. package/lib/typescript/src/components/Marker.types.d.ts.map +1 -1
  63. package/lib/typescript/src/components/Marker.web.d.ts +3 -2
  64. package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
  65. package/lib/typescript/src/components/Polygon.web.d.ts +1 -1
  66. package/lib/typescript/src/components/Polygon.web.d.ts.map +1 -1
  67. package/lib/typescript/src/components/Polyline.web.d.ts +1 -1
  68. package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
  69. package/lib/typescript/src/components/TileOverlay.web.d.ts +1 -1
  70. package/lib/typescript/src/components/TileOverlay.web.d.ts.map +1 -1
  71. package/lib/typescript/src/components/index.d.ts +1 -1
  72. package/lib/typescript/src/components/index.d.ts.map +1 -1
  73. package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts +1 -1
  74. package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts +6 -1
  75. package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -1
  76. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +8 -1
  77. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
  78. package/lib/typescript/src/index.d.ts +3 -3
  79. package/lib/typescript/src/index.d.ts.map +1 -1
  80. package/lib/typescript/src/index.web.d.ts +1 -1
  81. package/lib/typescript/src/index.web.d.ts.map +1 -1
  82. package/lib/typescript/src/types.d.ts +0 -4
  83. package/lib/typescript/src/types.d.ts.map +1 -1
  84. package/package.json +1 -1
  85. package/src/MapProvider.web.tsx +5 -3
  86. package/src/MapView.tsx +12 -1
  87. package/src/MapView.types.ts +118 -1
  88. package/src/MapView.web.tsx +378 -345
  89. package/src/components/Circle.web.tsx +81 -79
  90. package/src/components/GeoJson.tsx +3 -3
  91. package/src/components/GroundOverlay.web.tsx +65 -69
  92. package/src/components/Marker.tsx +28 -5
  93. package/src/components/Marker.types.ts +15 -5
  94. package/src/components/Marker.web.tsx +196 -150
  95. package/src/components/Polygon.web.tsx +93 -89
  96. package/src/components/Polyline.web.tsx +235 -235
  97. package/src/components/TileOverlay.web.tsx +83 -81
  98. package/src/components/index.ts +1 -0
  99. package/src/fabric/LuggCalloutViewNativeComponent.ts +1 -1
  100. package/src/fabric/LuggMapViewNativeComponent.ts +9 -1
  101. package/src/fabric/LuggMarkerViewNativeComponent.ts +14 -2
  102. package/src/index.ts +6 -1
  103. package/src/index.web.ts +3 -0
  104. package/src/types.ts +0 -5
@@ -1,95 +1,97 @@
1
- import { useCallback, useEffect, useRef } from 'react';
1
+ import { memo, useCallback, useEffect, useRef } from 'react';
2
2
  import { useMapContext } from '../MapProvider.web';
3
3
  import type { TileOverlayProps } from './TileOverlay.types';
4
4
 
5
- export const TileOverlay = ({
6
- urlTemplate,
7
- tileSize = 256,
8
- opacity = 1,
9
- bounds,
10
- zIndex = 0,
11
- onPress,
12
- }: TileOverlayProps) => {
13
- const { map } = useMapContext();
14
- const overlayRef = useRef<google.maps.ImageMapType | null>(null);
15
- const indexRef = useRef<number>(-1);
5
+ export const TileOverlay = memo(
6
+ ({
7
+ urlTemplate,
8
+ tileSize = 256,
9
+ opacity = 1,
10
+ bounds,
11
+ zIndex = 0,
12
+ onPress,
13
+ }: TileOverlayProps) => {
14
+ const { map } = useMapContext();
15
+ const overlayRef = useRef<google.maps.ImageMapType | null>(null);
16
+ const indexRef = useRef<number>(-1);
16
17
 
17
- const handleClick = useCallback(() => {
18
- onPress?.();
19
- }, [onPress]);
18
+ const handleClick = useCallback(() => {
19
+ onPress?.();
20
+ }, [onPress]);
20
21
 
21
- // Cleanup on unmount
22
- useEffect(() => {
23
- return () => {
24
- if (overlayRef.current && indexRef.current >= 0) {
25
- map?.overlayMapTypes.removeAt(indexRef.current);
26
- }
27
- overlayRef.current = null;
28
- indexRef.current = -1;
29
- };
30
- // eslint-disable-next-line react-hooks/exhaustive-deps
31
- }, []);
22
+ // Cleanup on unmount
23
+ useEffect(() => {
24
+ return () => {
25
+ if (overlayRef.current && indexRef.current >= 0) {
26
+ map?.overlayMapTypes.removeAt(indexRef.current);
27
+ }
28
+ overlayRef.current = null;
29
+ indexRef.current = -1;
30
+ };
31
+ // eslint-disable-next-line react-hooks/exhaustive-deps
32
+ }, []);
32
33
 
33
- // Sync overlay with props
34
- useEffect(() => {
35
- if (!map) return;
34
+ // Sync overlay with props
35
+ useEffect(() => {
36
+ if (!map) return;
36
37
 
37
- // Remove old overlay
38
- if (overlayRef.current && indexRef.current >= 0) {
39
- map.overlayMapTypes.removeAt(indexRef.current);
40
- overlayRef.current = null;
41
- indexRef.current = -1;
42
- }
38
+ // Remove old overlay
39
+ if (overlayRef.current && indexRef.current >= 0) {
40
+ map.overlayMapTypes.removeAt(indexRef.current);
41
+ overlayRef.current = null;
42
+ indexRef.current = -1;
43
+ }
43
44
 
44
- if (!urlTemplate) return;
45
+ if (!urlTemplate) return;
45
46
 
46
- const imageMapType = new google.maps.ImageMapType({
47
- getTileUrl: (coord, zoom) => {
48
- if (bounds) {
49
- const n = Math.pow(2, zoom);
50
- const tileSWLat =
51
- (Math.atan(Math.sinh(Math.PI * (1 - (2 * (coord.y + 1)) / n))) *
52
- 180) /
53
- Math.PI;
54
- const tileNELat =
55
- (Math.atan(Math.sinh(Math.PI * (1 - (2 * coord.y) / n))) * 180) /
56
- Math.PI;
57
- const tileSWLng = (coord.x / n) * 360 - 180;
58
- const tileNELng = ((coord.x + 1) / n) * 360 - 180;
47
+ const imageMapType = new google.maps.ImageMapType({
48
+ getTileUrl: (coord, zoom) => {
49
+ if (bounds) {
50
+ const n = Math.pow(2, zoom);
51
+ const tileSWLat =
52
+ (Math.atan(Math.sinh(Math.PI * (1 - (2 * (coord.y + 1)) / n))) *
53
+ 180) /
54
+ Math.PI;
55
+ const tileNELat =
56
+ (Math.atan(Math.sinh(Math.PI * (1 - (2 * coord.y) / n))) * 180) /
57
+ Math.PI;
58
+ const tileSWLng = (coord.x / n) * 360 - 180;
59
+ const tileNELng = ((coord.x + 1) / n) * 360 - 180;
59
60
 
60
- if (
61
- tileNELat < bounds.southwest.latitude ||
62
- tileSWLat > bounds.northeast.latitude ||
63
- tileNELng < bounds.southwest.longitude ||
64
- tileSWLng > bounds.northeast.longitude
65
- ) {
66
- return null;
61
+ if (
62
+ tileNELat < bounds.southwest.latitude ||
63
+ tileSWLat > bounds.northeast.latitude ||
64
+ tileNELng < bounds.southwest.longitude ||
65
+ tileSWLng > bounds.northeast.longitude
66
+ ) {
67
+ return null;
68
+ }
67
69
  }
68
- }
69
70
 
70
- return urlTemplate
71
- .replace('{x}', String(coord.x))
72
- .replace('{y}', String(coord.y))
73
- .replace('{z}', String(zoom));
74
- },
75
- tileSize: new google.maps.Size(tileSize, tileSize),
76
- opacity,
77
- });
71
+ return urlTemplate
72
+ .replace('{x}', String(coord.x))
73
+ .replace('{y}', String(coord.y))
74
+ .replace('{z}', String(zoom));
75
+ },
76
+ tileSize: new google.maps.Size(tileSize, tileSize),
77
+ opacity,
78
+ });
78
79
 
79
- const length = map.overlayMapTypes.getLength();
80
- map.overlayMapTypes.insertAt(length, imageMapType);
81
- overlayRef.current = imageMapType;
82
- indexRef.current = length;
83
- }, [
84
- map,
85
- urlTemplate,
86
- tileSize,
87
- opacity,
88
- bounds,
89
- zIndex,
90
- onPress,
91
- handleClick,
92
- ]);
80
+ const length = map.overlayMapTypes.getLength();
81
+ map.overlayMapTypes.insertAt(length, imageMapType);
82
+ overlayRef.current = imageMapType;
83
+ indexRef.current = length;
84
+ }, [
85
+ map,
86
+ urlTemplate,
87
+ tileSize,
88
+ opacity,
89
+ bounds,
90
+ zIndex,
91
+ onPress,
92
+ handleClick,
93
+ ]);
93
94
 
94
- return null;
95
- };
95
+ return null;
96
+ }
97
+ );
@@ -1,6 +1,7 @@
1
1
  export { Marker } from './Marker';
2
2
  export type {
3
3
  CalloutOptions,
4
+ MarkerRef,
4
5
  MarkerProps,
5
6
  MarkerPressEvent,
6
7
  MarkerDragEvent,
@@ -12,7 +12,7 @@ export interface Point {
12
12
 
13
13
  export interface NativeProps extends ViewProps {
14
14
  bubbled?: WithDefault<boolean, true>;
15
- anchor?: Point;
15
+ offset?: Point;
16
16
  }
17
17
 
18
18
  export default codegenNativeComponent<NativeProps>(
@@ -62,6 +62,10 @@ export interface ReadyEvent {}
62
62
 
63
63
  export interface NativeProps extends ViewProps {
64
64
  provider?: WithDefault<'google' | 'apple', 'google'>;
65
+ mapType?: WithDefault<
66
+ 'standard' | 'satellite' | 'terrain' | 'hybrid' | 'muted-standard',
67
+ 'standard'
68
+ >;
65
69
  mapId?: string;
66
70
  initialCoordinate?: Coordinate;
67
71
  initialZoom?: Double;
@@ -74,7 +78,11 @@ export interface NativeProps extends ViewProps {
74
78
  edgeInsets?: EdgeInsets;
75
79
  userLocationEnabled?: boolean;
76
80
  userLocationButtonEnabled?: boolean;
77
- theme?: WithDefault<'light' | 'dark' | 'system', 'system'>;
81
+ poiEnabled?: boolean;
82
+ poiFilterMode?: WithDefault<'including' | 'excluding', 'including'>;
83
+ poiFilterCategories?: ReadonlyArray<string>;
84
+ theme?: WithDefault<'system' | 'light' | 'dark', 'system'>;
85
+ insetAdjustment?: WithDefault<'never' | 'automatic', 'never'>;
78
86
  onMapPress?: DirectEventHandler<PressEvent>;
79
87
  onMapLongPress?: DirectEventHandler<LongPressEvent>;
80
88
  onCameraMove?: DirectEventHandler<CameraMoveEvent>;
@@ -1,4 +1,4 @@
1
- import { codegenNativeComponent } from 'react-native';
1
+ import { codegenNativeComponent, codegenNativeCommands } from 'react-native';
2
2
  import type { ViewProps, HostComponent } from 'react-native';
3
3
  import type {
4
4
  Double,
@@ -25,6 +25,7 @@ export interface NativeProps extends ViewProps {
25
25
  rotate?: WithDefault<Double, 0>;
26
26
  scale?: WithDefault<Double, 1>;
27
27
  rasterize?: WithDefault<boolean, true>;
28
+ centerOnPress?: WithDefault<boolean, true>;
28
29
  draggable?: WithDefault<boolean, false>;
29
30
  onMarkerPress?: DirectEventHandler<{
30
31
  coordinate: {
@@ -68,6 +69,17 @@ export interface NativeProps extends ViewProps {
68
69
  }>;
69
70
  }
70
71
 
72
+ type ComponentType = HostComponent<NativeProps>;
73
+
74
+ interface NativeCommands {
75
+ showCallout: (viewRef: React.ElementRef<ComponentType>) => void;
76
+ hideCallout: (viewRef: React.ElementRef<ComponentType>) => void;
77
+ }
78
+
79
+ export const Commands = codegenNativeCommands<NativeCommands>({
80
+ supportedCommands: ['showCallout', 'hideCallout'],
81
+ });
82
+
71
83
  export default codegenNativeComponent<NativeProps>(
72
84
  'LuggMarkerView'
73
- ) as HostComponent<NativeProps>;
85
+ ) as ComponentType;
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ export type { MapProviderProps } from './MapProvider.types';
4
4
  export { Marker } from './components';
5
5
  export type {
6
6
  CalloutOptions,
7
+ MarkerRef,
7
8
  MarkerProps,
8
9
  MarkerPressEvent,
9
10
  MarkerDragEvent,
@@ -33,10 +34,14 @@ export type {
33
34
  CameraEventPayload,
34
35
  MapCameraEvent,
35
36
  MapPressEvent,
37
+ MapType,
38
+ MapTheme,
39
+ InsetAdjustment,
40
+ PoiCategory,
41
+ PoiFilter,
36
42
  } from './MapView.types';
37
43
  export type {
38
44
  MapProvider as MapProviderType,
39
- MapTheme,
40
45
  Coordinate,
41
46
  Point,
42
47
  EdgeInsets,
package/src/index.web.ts CHANGED
@@ -27,6 +27,9 @@ export type {
27
27
  MoveCameraOptions,
28
28
  FitCoordinatesOptions,
29
29
  CameraEventPayload,
30
+ MapType,
31
+ PoiCategory,
32
+ PoiFilter,
30
33
  } from './MapView.types';
31
34
  export type {
32
35
  MapProvider as MapProviderType,
package/src/types.ts CHANGED
@@ -29,11 +29,6 @@ export interface EdgeInsets {
29
29
  right: number;
30
30
  }
31
31
 
32
- /**
33
- * Map theme
34
- */
35
- export type MapTheme = 'light' | 'dark' | 'system';
36
-
37
32
  /**
38
33
  * Press event payload
39
34
  */