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

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 (112) hide show
  1. package/README.md +3 -0
  2. package/android/src/main/java/com/luggmaps/LuggCircleView.kt +85 -0
  3. package/android/src/main/java/com/luggmaps/LuggCircleViewManager.kt +79 -0
  4. package/android/src/main/java/com/luggmaps/LuggGroundOverlayView.kt +81 -0
  5. package/android/src/main/java/com/luggmaps/LuggGroundOverlayViewManager.kt +82 -0
  6. package/android/src/main/java/com/luggmaps/LuggMapView.kt +9 -0
  7. package/android/src/main/java/com/luggmaps/LuggPackage.kt +4 -1
  8. package/android/src/main/java/com/luggmaps/LuggTileOverlayView.kt +92 -0
  9. package/android/src/main/java/com/luggmaps/LuggTileOverlayViewManager.kt +80 -0
  10. package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +289 -0
  11. package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +9 -0
  12. package/android/src/main/java/com/luggmaps/events/CirclePressEvent.kt +12 -0
  13. package/android/src/main/java/com/luggmaps/events/GroundOverlayPressEvent.kt +12 -0
  14. package/android/src/main/java/com/luggmaps/events/TileOverlayPressEvent.kt +12 -0
  15. package/ios/LuggCircleView.h +31 -0
  16. package/ios/LuggCircleView.mm +133 -0
  17. package/ios/LuggGroundOverlayView.h +30 -0
  18. package/ios/LuggGroundOverlayView.mm +125 -0
  19. package/ios/LuggMapView.mm +43 -0
  20. package/ios/LuggTileOverlayView.h +31 -0
  21. package/ios/LuggTileOverlayView.mm +130 -0
  22. package/ios/core/AppleMapProvider.mm +398 -1
  23. package/ios/core/GoogleMapProvider.mm +299 -10
  24. package/ios/core/MapProviderDelegate.h +12 -0
  25. package/ios/events/CirclePressEvent.h +20 -0
  26. package/ios/events/GroundOverlayPressEvent.h +20 -0
  27. package/ios/events/TileOverlayPressEvent.h +20 -0
  28. package/lib/module/components/Circle.js +46 -0
  29. package/lib/module/components/Circle.js.map +1 -0
  30. package/lib/module/components/Circle.types.js +4 -0
  31. package/lib/module/components/Circle.types.js.map +1 -0
  32. package/lib/module/components/Circle.web.js +79 -0
  33. package/lib/module/components/Circle.web.js.map +1 -0
  34. package/lib/module/components/GroundOverlay.js +45 -0
  35. package/lib/module/components/GroundOverlay.js.map +1 -0
  36. package/lib/module/components/GroundOverlay.types.js +4 -0
  37. package/lib/module/components/GroundOverlay.types.js.map +1 -0
  38. package/lib/module/components/GroundOverlay.web.js +77 -0
  39. package/lib/module/components/GroundOverlay.web.js.map +1 -0
  40. package/lib/module/components/Marker.js +5 -1
  41. package/lib/module/components/Marker.js.map +1 -1
  42. package/lib/module/components/TileOverlay.js +44 -0
  43. package/lib/module/components/TileOverlay.js.map +1 -0
  44. package/lib/module/components/TileOverlay.types.js +4 -0
  45. package/lib/module/components/TileOverlay.types.js.map +1 -0
  46. package/lib/module/components/TileOverlay.web.js +69 -0
  47. package/lib/module/components/TileOverlay.web.js.map +1 -0
  48. package/lib/module/components/index.js +3 -0
  49. package/lib/module/components/index.js.map +1 -1
  50. package/lib/module/components/index.web.js +3 -0
  51. package/lib/module/components/index.web.js.map +1 -1
  52. package/lib/module/fabric/LuggCircleViewNativeComponent.ts +25 -0
  53. package/lib/module/fabric/LuggGroundOverlayViewNativeComponent.ts +29 -0
  54. package/lib/module/fabric/LuggTileOverlayViewNativeComponent.ts +30 -0
  55. package/lib/module/index.js +3 -0
  56. package/lib/module/index.js.map +1 -1
  57. package/lib/module/index.web.js +3 -0
  58. package/lib/module/index.web.js.map +1 -1
  59. package/lib/typescript/src/components/Circle.d.ts +10 -0
  60. package/lib/typescript/src/components/Circle.d.ts.map +1 -0
  61. package/lib/typescript/src/components/Circle.types.d.ts +33 -0
  62. package/lib/typescript/src/components/Circle.types.d.ts.map +1 -0
  63. package/lib/typescript/src/components/Circle.web.d.ts +3 -0
  64. package/lib/typescript/src/components/Circle.web.d.ts.map +1 -0
  65. package/lib/typescript/src/components/GroundOverlay.d.ts +10 -0
  66. package/lib/typescript/src/components/GroundOverlay.d.ts.map +1 -0
  67. package/lib/typescript/src/components/GroundOverlay.types.d.ts +35 -0
  68. package/lib/typescript/src/components/GroundOverlay.types.d.ts.map +1 -0
  69. package/lib/typescript/src/components/GroundOverlay.web.d.ts +3 -0
  70. package/lib/typescript/src/components/GroundOverlay.web.d.ts.map +1 -0
  71. package/lib/typescript/src/components/Marker.d.ts.map +1 -1
  72. package/lib/typescript/src/components/Marker.types.d.ts +4 -1
  73. package/lib/typescript/src/components/Marker.types.d.ts.map +1 -1
  74. package/lib/typescript/src/components/TileOverlay.d.ts +10 -0
  75. package/lib/typescript/src/components/TileOverlay.d.ts.map +1 -0
  76. package/lib/typescript/src/components/TileOverlay.types.d.ts +36 -0
  77. package/lib/typescript/src/components/TileOverlay.types.d.ts.map +1 -0
  78. package/lib/typescript/src/components/TileOverlay.web.d.ts +3 -0
  79. package/lib/typescript/src/components/TileOverlay.web.d.ts.map +1 -0
  80. package/lib/typescript/src/components/index.d.ts +6 -0
  81. package/lib/typescript/src/components/index.d.ts.map +1 -1
  82. package/lib/typescript/src/components/index.web.d.ts +6 -0
  83. package/lib/typescript/src/components/index.web.d.ts.map +1 -1
  84. package/lib/typescript/src/fabric/LuggCircleViewNativeComponent.d.ts +18 -0
  85. package/lib/typescript/src/fabric/LuggCircleViewNativeComponent.d.ts.map +1 -0
  86. package/lib/typescript/src/fabric/LuggGroundOverlayViewNativeComponent.d.ts +21 -0
  87. package/lib/typescript/src/fabric/LuggGroundOverlayViewNativeComponent.d.ts.map +1 -0
  88. package/lib/typescript/src/fabric/LuggTileOverlayViewNativeComponent.d.ts +21 -0
  89. package/lib/typescript/src/fabric/LuggTileOverlayViewNativeComponent.d.ts.map +1 -0
  90. package/lib/typescript/src/index.d.ts +6 -0
  91. package/lib/typescript/src/index.d.ts.map +1 -1
  92. package/lib/typescript/src/index.web.d.ts +6 -0
  93. package/lib/typescript/src/index.web.d.ts.map +1 -1
  94. package/package.json +5 -2
  95. package/src/components/Circle.tsx +52 -0
  96. package/src/components/Circle.types.ts +33 -0
  97. package/src/components/Circle.web.tsx +93 -0
  98. package/src/components/GroundOverlay.tsx +47 -0
  99. package/src/components/GroundOverlay.types.ts +36 -0
  100. package/src/components/GroundOverlay.web.tsx +85 -0
  101. package/src/components/Marker.tsx +4 -1
  102. package/src/components/Marker.types.ts +4 -1
  103. package/src/components/TileOverlay.tsx +44 -0
  104. package/src/components/TileOverlay.types.ts +37 -0
  105. package/src/components/TileOverlay.web.tsx +95 -0
  106. package/src/components/index.ts +9 -0
  107. package/src/components/index.web.ts +9 -0
  108. package/src/fabric/LuggCircleViewNativeComponent.ts +25 -0
  109. package/src/fabric/LuggGroundOverlayViewNativeComponent.ts +29 -0
  110. package/src/fabric/LuggTileOverlayViewNativeComponent.ts +30 -0
  111. package/src/index.ts +6 -0
  112. package/src/index.web.ts +12 -0
@@ -0,0 +1,37 @@
1
+ import type { Coordinate } from '../types';
2
+
3
+ export interface TileOverlayBounds {
4
+ northeast: Coordinate;
5
+ southwest: Coordinate;
6
+ }
7
+
8
+ export interface TileOverlayProps {
9
+ /**
10
+ * URL template for tile images.
11
+ * Use `{x}`, `{y}`, `{z}` placeholders for tile coordinates and zoom level.
12
+ * @example "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
13
+ */
14
+ urlTemplate: string;
15
+ /**
16
+ * Size of each tile in pixels
17
+ * @default 256
18
+ */
19
+ tileSize?: number;
20
+ /**
21
+ * Opacity of the tile overlay (0-1)
22
+ */
23
+ opacity?: number;
24
+ /**
25
+ * Restrict tiles to a geographic region.
26
+ * Tiles outside these bounds will not be loaded.
27
+ */
28
+ bounds?: TileOverlayBounds;
29
+ /**
30
+ * Z-index for layering
31
+ */
32
+ zIndex?: number;
33
+ /**
34
+ * Called when the tile overlay is tapped
35
+ */
36
+ onPress?: () => void;
37
+ }
@@ -0,0 +1,95 @@
1
+ import { useCallback, useEffect, useRef } from 'react';
2
+ import { useMapContext } from '../MapProvider.web';
3
+ import type { TileOverlayProps } from './TileOverlay.types';
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);
16
+
17
+ const handleClick = useCallback(() => {
18
+ onPress?.();
19
+ }, [onPress]);
20
+
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
+ }, []);
32
+
33
+ // Sync overlay with props
34
+ useEffect(() => {
35
+ if (!map) return;
36
+
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
+ }
43
+
44
+ if (!urlTemplate) return;
45
+
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;
59
+
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;
67
+ }
68
+ }
69
+
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
+ });
78
+
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
+ ]);
93
+
94
+ return null;
95
+ };
@@ -7,6 +7,8 @@ export type {
7
7
  } from './Marker.types';
8
8
  export { Polygon } from './Polygon';
9
9
  export type { PolygonProps } from './Polygon.types';
10
+ export { Circle } from './Circle';
11
+ export type { CircleProps } from './Circle.types';
10
12
  export { Polyline } from './Polyline';
11
13
  export type {
12
14
  PolylineProps,
@@ -15,3 +17,10 @@ export type {
15
17
  } from './Polyline.types';
16
18
  export { GeoJson } from './GeoJson';
17
19
  export type { GeoJsonProps } from './GeoJson.types';
20
+ export { GroundOverlay } from './GroundOverlay';
21
+ export type {
22
+ GroundOverlayProps,
23
+ GroundOverlayBounds,
24
+ } from './GroundOverlay.types';
25
+ export { TileOverlay } from './TileOverlay';
26
+ export type { TileOverlayProps, TileOverlayBounds } from './TileOverlay.types';
@@ -1,8 +1,17 @@
1
1
  export { Marker } from './Marker.web';
2
2
  export { Polygon } from './Polygon.web';
3
+ export { Circle } from './Circle.web';
3
4
  export { Polyline } from './Polyline.web';
4
5
  export type { CalloutOptions, MarkerProps } from './Marker.types';
5
6
  export type { PolygonProps } from './Polygon.types';
7
+ export type { CircleProps } from './Circle.types';
6
8
  export type { PolylineProps } from './Polyline.types';
7
9
  export { GeoJson } from './GeoJson';
8
10
  export type { GeoJsonProps } from './GeoJson.types';
11
+ export { GroundOverlay } from './GroundOverlay.web';
12
+ export type {
13
+ GroundOverlayProps,
14
+ GroundOverlayBounds,
15
+ } from './GroundOverlay.types';
16
+ export { TileOverlay } from './TileOverlay.web';
17
+ export type { TileOverlayProps, TileOverlayBounds } from './TileOverlay.types';
@@ -0,0 +1,25 @@
1
+ import { codegenNativeComponent } from 'react-native';
2
+ import type { ViewProps, HostComponent, ColorValue } from 'react-native';
3
+ import type {
4
+ Double,
5
+ DirectEventHandler,
6
+ } from 'react-native/Libraries/Types/CodegenTypes';
7
+
8
+ export interface Coordinate {
9
+ latitude: Double;
10
+ longitude: Double;
11
+ }
12
+
13
+ export interface NativeProps extends ViewProps {
14
+ center: Coordinate;
15
+ radius?: Double;
16
+ strokeColor?: ColorValue;
17
+ strokeWidth?: Double;
18
+ fillColor?: ColorValue;
19
+ tappable?: boolean;
20
+ onCirclePress?: DirectEventHandler<null>;
21
+ }
22
+
23
+ export default codegenNativeComponent<NativeProps>(
24
+ 'LuggCircleView'
25
+ ) as HostComponent<NativeProps>;
@@ -0,0 +1,29 @@
1
+ import { codegenNativeComponent } from 'react-native';
2
+ import type { ViewProps, HostComponent } from 'react-native';
3
+ import type {
4
+ Double,
5
+ DirectEventHandler,
6
+ } from 'react-native/Libraries/Types/CodegenTypes';
7
+
8
+ export interface Coordinate {
9
+ latitude: Double;
10
+ longitude: Double;
11
+ }
12
+
13
+ export interface Bounds {
14
+ northeast: Coordinate;
15
+ southwest: Coordinate;
16
+ }
17
+
18
+ export interface NativeProps extends ViewProps {
19
+ image: string;
20
+ bounds: Bounds;
21
+ opacity?: Double;
22
+ bearing?: Double;
23
+ tappable?: boolean;
24
+ onGroundOverlayPress?: DirectEventHandler<null>;
25
+ }
26
+
27
+ export default codegenNativeComponent<NativeProps>(
28
+ 'LuggGroundOverlayView'
29
+ ) as HostComponent<NativeProps>;
@@ -0,0 +1,30 @@
1
+ import { codegenNativeComponent } from 'react-native';
2
+ import type { ViewProps, HostComponent } from 'react-native';
3
+ import type {
4
+ Double,
5
+ Int32,
6
+ DirectEventHandler,
7
+ } from 'react-native/Libraries/Types/CodegenTypes';
8
+
9
+ export interface Coordinate {
10
+ latitude: Double;
11
+ longitude: Double;
12
+ }
13
+
14
+ export interface Bounds {
15
+ northeast: Coordinate;
16
+ southwest: Coordinate;
17
+ }
18
+
19
+ export interface NativeProps extends ViewProps {
20
+ urlTemplate: string;
21
+ tileSize?: Int32;
22
+ opacity?: Double;
23
+ bounds?: Bounds;
24
+ tappable?: boolean;
25
+ onTileOverlayPress?: DirectEventHandler<null>;
26
+ }
27
+
28
+ export default codegenNativeComponent<NativeProps>(
29
+ 'LuggTileOverlayView'
30
+ ) as HostComponent<NativeProps>;
package/src/index.ts CHANGED
@@ -10,6 +10,8 @@ export type {
10
10
  } from './components';
11
11
  export { Polygon } from './components';
12
12
  export type { PolygonProps } from './components';
13
+ export { Circle } from './components';
14
+ export type { CircleProps } from './components';
13
15
  export { Polyline } from './components';
14
16
  export type {
15
17
  PolylineProps,
@@ -18,6 +20,10 @@ export type {
18
20
  } from './components';
19
21
  export { GeoJson } from './components';
20
22
  export type { GeoJsonProps } from './components';
23
+ export { GroundOverlay } from './components';
24
+ export type { GroundOverlayProps, GroundOverlayBounds } from './components';
25
+ export { TileOverlay } from './components';
26
+ export type { TileOverlayProps, TileOverlayBounds } from './components';
21
27
  export type {
22
28
  MapViewProps,
23
29
  MapViewRef,
package/src/index.web.ts CHANGED
@@ -5,10 +5,22 @@ export { Marker } from './components/index.web';
5
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
+ export { Circle } from './components/index.web';
9
+ export type { CircleProps } from './components/index.web';
8
10
  export { Polyline } from './components/index.web';
9
11
  export type { PolylineProps } from './components/index.web';
10
12
  export { GeoJson } from './components/index.web';
11
13
  export type { GeoJsonProps } from './components/index.web';
14
+ export { GroundOverlay } from './components/index.web';
15
+ export type {
16
+ GroundOverlayProps,
17
+ GroundOverlayBounds,
18
+ } from './components/index.web';
19
+ export { TileOverlay } from './components/index.web';
20
+ export type {
21
+ TileOverlayProps,
22
+ TileOverlayBounds,
23
+ } from './components/index.web';
12
24
  export type {
13
25
  MapViewProps,
14
26
  MapViewRef,