@maydon_tech/react-native-nitro-maps 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.
- package/LICENSE +20 -0
- package/NitroMap.podspec +42 -0
- package/README.md +172 -0
- package/android/CMakeLists.txt +27 -0
- package/android/build.gradle +141 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/nitromap/ClusterIconGenerator.kt +108 -0
- package/android/src/main/java/com/margelo/nitro/nitromap/ColorUtils.kt +63 -0
- package/android/src/main/java/com/margelo/nitro/nitromap/HybridNitroMap.kt +408 -0
- package/android/src/main/java/com/margelo/nitro/nitromap/HybridNitroMapConfig.kt +68 -0
- package/android/src/main/java/com/margelo/nitro/nitromap/MarkerIconCache.kt +176 -0
- package/android/src/main/java/com/margelo/nitro/nitromap/MarkerIconFactory.kt +252 -0
- package/android/src/main/java/com/margelo/nitro/nitromap/NitroMapPackage.kt +33 -0
- package/android/src/main/java/com/margelo/nitro/nitromap/clustering/NitroClusterEngine.kt +252 -0
- package/android/src/main/java/com/margelo/nitro/nitromap/clustering/QuadTree.kt +195 -0
- package/android/src/main/java/com/margelo/nitro/nitromap/providers/GoogleMapProvider.kt +912 -0
- package/android/src/main/java/com/margelo/nitro/nitromap/providers/MapProviderInterface.kt +70 -0
- package/cpp/ClusterEngine.hpp +411 -0
- package/cpp/KDBush.hpp +238 -0
- package/cpp/QuadTree.hpp +246 -0
- package/ios/Clustering/ClusterEngineWrapper.h +58 -0
- package/ios/Clustering/ClusterEngineWrapper.mm +142 -0
- package/ios/Clustering/ClusterIconRenderer.swift +80 -0
- package/ios/Clustering/NitroClusterEngine.swift +117 -0
- package/ios/Clustering/NitroClusterIconGenerator.swift +35 -0
- package/ios/MarkerRenderer/MarkerIconFactory.swift +322 -0
- package/ios/MarkerRenderer/PriceMarkerRenderer.swift +140 -0
- package/ios/NitroMap.swift +332 -0
- package/ios/NitroMapConfig/HybridNitroMapConfig.swift +33 -0
- package/ios/Providers/GoogleMapDelegate.swift +310 -0
- package/ios/Providers/GoogleMapProvider+Camera.swift +164 -0
- package/ios/Providers/GoogleMapProvider.swift +924 -0
- package/ios/Providers/MapProviderProtocol.swift +78 -0
- package/ios/Shared/ClusterConfig+Factory.swift +58 -0
- package/ios/Shared/ClusteringManager.swift +211 -0
- package/ios/Shared/MapStyleProvider.swift +135 -0
- package/ios/Shared/MarkerSelectionHandler.swift +116 -0
- package/ios/Utils/ColorValueExtension.swift +54 -0
- package/lib/module/components/ImageMarker.js +146 -0
- package/lib/module/components/ImageMarker.js.map +1 -0
- package/lib/module/components/NitroMap.js +320 -0
- package/lib/module/components/NitroMap.js.map +1 -0
- package/lib/module/components/PriceMarker.js +165 -0
- package/lib/module/components/PriceMarker.js.map +1 -0
- package/lib/module/context/NitroMapContext.js +15 -0
- package/lib/module/context/NitroMapContext.js.map +1 -0
- package/lib/module/hooks/useNitroMarker.js +104 -0
- package/lib/module/hooks/useNitroMarker.js.map +1 -0
- package/lib/module/index.js +21 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/modules/index.js +4 -0
- package/lib/module/modules/index.js.map +1 -0
- package/lib/module/modules/module.js +30 -0
- package/lib/module/modules/module.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/specs/NitroMap.nitro.js +4 -0
- package/lib/module/specs/NitroMap.nitro.js.map +1 -0
- package/lib/module/specs/NitroMapConfig.nitro.js +4 -0
- package/lib/module/specs/NitroMapConfig.nitro.js.map +1 -0
- package/lib/module/types/map.js +2 -0
- package/lib/module/types/map.js.map +1 -0
- package/lib/module/types/marker.js +4 -0
- package/lib/module/types/marker.js.map +1 -0
- package/lib/module/utils/colors.js +147 -0
- package/lib/module/utils/colors.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/components/ImageMarker.d.ts +70 -0
- package/lib/typescript/src/components/ImageMarker.d.ts.map +1 -0
- package/lib/typescript/src/components/NitroMap.d.ts +14 -0
- package/lib/typescript/src/components/NitroMap.d.ts.map +1 -0
- package/lib/typescript/src/components/PriceMarker.d.ts +88 -0
- package/lib/typescript/src/components/PriceMarker.d.ts.map +1 -0
- package/lib/typescript/src/context/NitroMapContext.d.ts +16 -0
- package/lib/typescript/src/context/NitroMapContext.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useNitroMarker.d.ts +78 -0
- package/lib/typescript/src/hooks/useNitroMarker.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +12 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/modules/index.d.ts +2 -0
- package/lib/typescript/src/modules/index.d.ts.map +1 -0
- package/lib/typescript/src/modules/module.d.ts +22 -0
- package/lib/typescript/src/modules/module.d.ts.map +1 -0
- package/lib/typescript/src/specs/NitroMap.nitro.d.ts +227 -0
- package/lib/typescript/src/specs/NitroMap.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/NitroMapConfig.nitro.d.ts +10 -0
- package/lib/typescript/src/specs/NitroMapConfig.nitro.d.ts.map +1 -0
- package/lib/typescript/src/types/map.d.ts +154 -0
- package/lib/typescript/src/types/map.d.ts.map +1 -0
- package/lib/typescript/src/types/marker.d.ts +248 -0
- package/lib/typescript/src/types/marker.d.ts.map +1 -0
- package/lib/typescript/src/utils/colors.d.ts +82 -0
- package/lib/typescript/src/utils/colors.d.ts.map +1 -0
- package/nitro.json +21 -0
- package/nitrogen/generated/android/c++/JCamera.hpp +74 -0
- package/nitrogen/generated/android/c++/JClusterAnimationStyle.hpp +68 -0
- package/nitrogen/generated/android/c++/JClusterConfig.hpp +121 -0
- package/nitrogen/generated/android/c++/JClusterPressEvent.hpp +86 -0
- package/nitrogen/generated/android/c++/JClusterStrategy.hpp +59 -0
- package/nitrogen/generated/android/c++/JColorValue.cpp +26 -0
- package/nitrogen/generated/android/c++/JColorValue.hpp +70 -0
- package/nitrogen/generated/android/c++/JCoordinate.hpp +61 -0
- package/nitrogen/generated/android/c++/JEdgePadding.hpp +69 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_ClusterPressEvent.hpp +81 -0
- package/nitrogen/generated/android/c++/JFunc_void_MapError.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_MapPressEvent.hpp +81 -0
- package/nitrogen/generated/android/c++/JFunc_void_MarkerDragEvent.hpp +80 -0
- package/nitrogen/generated/android/c++/JFunc_void_MarkerPressEvent.hpp +80 -0
- package/nitrogen/generated/android/c++/JFunc_void_RegionChangeEvent.hpp +79 -0
- package/nitrogen/generated/android/c++/JHybridNitroMapConfigSpec.cpp +59 -0
- package/nitrogen/generated/android/c++/JHybridNitroMapConfigSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/JHybridNitroMapSpec.cpp +593 -0
- package/nitrogen/generated/android/c++/JHybridNitroMapSpec.hpp +125 -0
- package/nitrogen/generated/android/c++/JImageMarkerConfig.hpp +86 -0
- package/nitrogen/generated/android/c++/JMapBoundaries.hpp +62 -0
- package/nitrogen/generated/android/c++/JMapError.hpp +61 -0
- package/nitrogen/generated/android/c++/JMapPressEvent.hpp +64 -0
- package/nitrogen/generated/android/c++/JMapProvider.hpp +62 -0
- package/nitrogen/generated/android/c++/JMapStyleElement.hpp +87 -0
- package/nitrogen/generated/android/c++/JMapStyler.hpp +78 -0
- package/nitrogen/generated/android/c++/JMapType.hpp +62 -0
- package/nitrogen/generated/android/c++/JMarkerAnimation.hpp +62 -0
- package/nitrogen/generated/android/c++/JMarkerColor.hpp +69 -0
- package/nitrogen/generated/android/c++/JMarkerConfig.hpp +77 -0
- package/nitrogen/generated/android/c++/JMarkerData.hpp +121 -0
- package/nitrogen/generated/android/c++/JMarkerDragEvent.hpp +63 -0
- package/nitrogen/generated/android/c++/JMarkerPressEvent.hpp +63 -0
- package/nitrogen/generated/android/c++/JMarkerStyle.hpp +62 -0
- package/nitrogen/generated/android/c++/JPoint.hpp +61 -0
- package/nitrogen/generated/android/c++/JPriceMarkerStyle.hpp +102 -0
- package/nitrogen/generated/android/c++/JRegion.hpp +69 -0
- package/nitrogen/generated/android/c++/JRegionChangeEvent.hpp +62 -0
- package/nitrogen/generated/android/c++/JVariant_String_MarkerColor.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_String_MarkerColor.hpp +70 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroMapStateUpdater.cpp +144 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroMapStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Camera.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/ClusterAnimationStyle.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/ClusterConfig.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/ClusterPressEvent.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/ClusterStrategy.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/ColorValue.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Coordinate.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/EdgePadding.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Func_void_ClusterPressEvent.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Func_void_MapError.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Func_void_MapPressEvent.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Func_void_MarkerDragEvent.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Func_void_MarkerPressEvent.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Func_void_RegionChangeEvent.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/HybridNitroMapConfigSpec.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/HybridNitroMapSpec.kt +342 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/ImageMarkerConfig.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MapBoundaries.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MapError.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MapPressEvent.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MapProvider.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MapStyleElement.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MapStyler.kt +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MapType.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MarkerAnimation.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MarkerColor.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MarkerConfig.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MarkerData.kt +71 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MarkerDragEvent.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MarkerPressEvent.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/MarkerStyle.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Point.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/PriceMarkerStyle.kt +68 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Region.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/RegionChangeEvent.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/Variant_String_MarkerColor.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/nitromapOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/views/HybridNitroMapManager.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromap/views/HybridNitroMapStateUpdater.kt +23 -0
- package/nitrogen/generated/android/nitromap+autolinking.cmake +87 -0
- package/nitrogen/generated/android/nitromap+autolinking.gradle +27 -0
- package/nitrogen/generated/android/nitromapOnLoad.cpp +70 -0
- package/nitrogen/generated/android/nitromapOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/NitroMap+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroMap-Swift-Cxx-Bridge.cpp +130 -0
- package/nitrogen/generated/ios/NitroMap-Swift-Cxx-Bridge.hpp +793 -0
- package/nitrogen/generated/ios/NitroMap-Swift-Cxx-Umbrella.hpp +132 -0
- package/nitrogen/generated/ios/NitroMapAutolinking.mm +41 -0
- package/nitrogen/generated/ios/NitroMapAutolinking.swift +40 -0
- package/nitrogen/generated/ios/c++/HybridNitroMapConfigSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroMapConfigSpecSwift.hpp +84 -0
- package/nitrogen/generated/ios/c++/HybridNitroMapSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroMapSpecSwift.hpp +410 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroMapComponent.mm +206 -0
- package/nitrogen/generated/ios/swift/Camera.swift +80 -0
- package/nitrogen/generated/ios/swift/ClusterAnimationStyle.swift +52 -0
- package/nitrogen/generated/ios/swift/ClusterConfig.swift +268 -0
- package/nitrogen/generated/ios/swift/ClusterPressEvent.swift +70 -0
- package/nitrogen/generated/ios/swift/ClusterStrategy.swift +40 -0
- package/nitrogen/generated/ios/swift/ColorValue.swift +18 -0
- package/nitrogen/generated/ios/swift/Coordinate.swift +47 -0
- package/nitrogen/generated/ios/swift/EdgePadding.swift +69 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_Camera.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_ClusterPressEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_MapBoundaries.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_MapError.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_MapPressEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_MarkerDragEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_MarkerPressEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_RegionChangeEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridNitroMapConfigSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridNitroMapConfigSpec_cxx.swift +142 -0
- package/nitrogen/generated/ios/swift/HybridNitroMapSpec.swift +93 -0
- package/nitrogen/generated/ios/swift/HybridNitroMapSpec_cxx.swift +953 -0
- package/nitrogen/generated/ios/swift/ImageMarkerConfig.swift +166 -0
- package/nitrogen/generated/ios/swift/MapBoundaries.swift +47 -0
- package/nitrogen/generated/ios/swift/MapError.swift +47 -0
- package/nitrogen/generated/ios/swift/MapPressEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/MapProvider.swift +44 -0
- package/nitrogen/generated/ios/swift/MapStyleElement.swift +108 -0
- package/nitrogen/generated/ios/swift/MapStyler.swift +177 -0
- package/nitrogen/generated/ios/swift/MapType.swift +44 -0
- package/nitrogen/generated/ios/swift/MarkerAnimation.swift +44 -0
- package/nitrogen/generated/ios/swift/MarkerColor.swift +69 -0
- package/nitrogen/generated/ios/swift/MarkerConfig.swift +82 -0
- package/nitrogen/generated/ios/swift/MarkerData.swift +195 -0
- package/nitrogen/generated/ios/swift/MarkerDragEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/MarkerPressEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/MarkerStyle.swift +44 -0
- package/nitrogen/generated/ios/swift/Point.swift +47 -0
- package/nitrogen/generated/ios/swift/PriceMarkerStyle.swift +374 -0
- package/nitrogen/generated/ios/swift/Region.swift +69 -0
- package/nitrogen/generated/ios/swift/RegionChangeEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Variant_String_MarkerColor.swift +18 -0
- package/nitrogen/generated/shared/c++/Camera.hpp +92 -0
- package/nitrogen/generated/shared/c++/ClusterAnimationStyle.hpp +88 -0
- package/nitrogen/generated/shared/c++/ClusterConfig.hpp +140 -0
- package/nitrogen/generated/shared/c++/ClusterPressEvent.hpp +86 -0
- package/nitrogen/generated/shared/c++/ClusterStrategy.hpp +76 -0
- package/nitrogen/generated/shared/c++/Coordinate.hpp +79 -0
- package/nitrogen/generated/shared/c++/EdgePadding.hpp +87 -0
- package/nitrogen/generated/shared/c++/HybridNitroMapConfigSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroMapConfigSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/HybridNitroMapSpec.cpp +82 -0
- package/nitrogen/generated/shared/c++/HybridNitroMapSpec.hpp +173 -0
- package/nitrogen/generated/shared/c++/ImageMarkerConfig.hpp +103 -0
- package/nitrogen/generated/shared/c++/MapBoundaries.hpp +80 -0
- package/nitrogen/generated/shared/c++/MapError.hpp +79 -0
- package/nitrogen/generated/shared/c++/MapPressEvent.hpp +83 -0
- package/nitrogen/generated/shared/c++/MapProvider.hpp +80 -0
- package/nitrogen/generated/shared/c++/MapStyleElement.hpp +87 -0
- package/nitrogen/generated/shared/c++/MapStyler.hpp +96 -0
- package/nitrogen/generated/shared/c++/MapType.hpp +80 -0
- package/nitrogen/generated/shared/c++/MarkerAnimation.hpp +80 -0
- package/nitrogen/generated/shared/c++/MarkerColor.hpp +87 -0
- package/nitrogen/generated/shared/c++/MarkerConfig.hpp +91 -0
- package/nitrogen/generated/shared/c++/MarkerData.hpp +131 -0
- package/nitrogen/generated/shared/c++/MarkerDragEvent.hpp +81 -0
- package/nitrogen/generated/shared/c++/MarkerPressEvent.hpp +81 -0
- package/nitrogen/generated/shared/c++/MarkerStyle.hpp +80 -0
- package/nitrogen/generated/shared/c++/Point.hpp +79 -0
- package/nitrogen/generated/shared/c++/PriceMarkerStyle.hpp +119 -0
- package/nitrogen/generated/shared/c++/Region.hpp +87 -0
- package/nitrogen/generated/shared/c++/RegionChangeEvent.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroMapComponent.cpp +351 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroMapComponent.hpp +141 -0
- package/nitrogen/generated/shared/json/NitroMapConfig.json +32 -0
- package/package.json +176 -0
- package/react-native.config.js +16 -0
- package/src/components/ImageMarker.tsx +254 -0
- package/src/components/NitroMap.tsx +433 -0
- package/src/components/PriceMarker.tsx +311 -0
- package/src/context/NitroMapContext.tsx +33 -0
- package/src/hooks/useNitroMarker.ts +198 -0
- package/src/index.tsx +62 -0
- package/src/modules/index.ts +6 -0
- package/src/modules/module.ts +45 -0
- package/src/specs/NitroMap.nitro.ts +292 -0
- package/src/specs/NitroMapConfig.nitro.ts +8 -0
- package/src/types/map.ts +166 -0
- package/src/types/marker.ts +267 -0
- package/src/utils/colors.ts +159 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
// src/components/PriceMarker.tsx
|
|
2
|
+
import { memo, useCallback, useMemo } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
useNitroMarker,
|
|
5
|
+
type CommonMarkerProps,
|
|
6
|
+
} from '../hooks/useNitroMarker';
|
|
7
|
+
import type { MarkerColor } from '../types/marker';
|
|
8
|
+
import { parseColor, type ColorValue } from '../utils/colors';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Props for the PriceMarker component
|
|
12
|
+
*/
|
|
13
|
+
export interface PriceMarkerProps extends CommonMarkerProps {
|
|
14
|
+
/**
|
|
15
|
+
* Price text to display (e.g., "9M", "150K")
|
|
16
|
+
* @required
|
|
17
|
+
*/
|
|
18
|
+
price: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Currency code to display (e.g., "UZS", "USD")
|
|
22
|
+
* If provided, uses the full price marker style with currency
|
|
23
|
+
*/
|
|
24
|
+
currency?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Whether the marker is in selected state
|
|
28
|
+
* Changes background and text colors when true
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
selected?: boolean;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Background color of the marker (hex string like "#FF0000" or MarkerColor object)
|
|
35
|
+
* @default Colors.white
|
|
36
|
+
*/
|
|
37
|
+
backgroundColor?: ColorValue;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Text color of the marker (hex string like "#FF0000" or MarkerColor object)
|
|
41
|
+
* @default Colors.black
|
|
42
|
+
*/
|
|
43
|
+
textColor?: ColorValue;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Font size in pixels
|
|
47
|
+
* @default 14
|
|
48
|
+
*/
|
|
49
|
+
fontSize?: number;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Corner radius in pixels (only for simple price style)
|
|
53
|
+
* @default 8
|
|
54
|
+
*/
|
|
55
|
+
cornerRadius?: number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Background color when marker is selected (hex string like "#FF0000" or MarkerColor object)
|
|
59
|
+
*/
|
|
60
|
+
selectedBackgroundColor?: ColorValue;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Text color when marker is selected (hex string like "#FF0000" or MarkerColor object)
|
|
64
|
+
*/
|
|
65
|
+
selectedTextColor?: ColorValue;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Horizontal padding in pixels
|
|
69
|
+
*/
|
|
70
|
+
paddingHorizontal?: number;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Vertical padding in pixels
|
|
74
|
+
*/
|
|
75
|
+
paddingVertical?: number;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Shadow opacity (0-1)
|
|
79
|
+
*/
|
|
80
|
+
shadowOpacity?: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// ============ Custom Memo Comparison ============
|
|
84
|
+
const arePropsEqual = (
|
|
85
|
+
prevProps: PriceMarkerProps,
|
|
86
|
+
nextProps: PriceMarkerProps
|
|
87
|
+
): boolean => {
|
|
88
|
+
// Compare primitive props
|
|
89
|
+
if (
|
|
90
|
+
prevProps.id !== nextProps.id ||
|
|
91
|
+
prevProps.price !== nextProps.price ||
|
|
92
|
+
prevProps.currency !== nextProps.currency ||
|
|
93
|
+
prevProps.selected !== nextProps.selected ||
|
|
94
|
+
prevProps.title !== nextProps.title ||
|
|
95
|
+
prevProps.description !== nextProps.description ||
|
|
96
|
+
prevProps.draggable !== nextProps.draggable ||
|
|
97
|
+
prevProps.opacity !== nextProps.opacity ||
|
|
98
|
+
prevProps.rotation !== nextProps.rotation ||
|
|
99
|
+
prevProps.zIndex !== nextProps.zIndex ||
|
|
100
|
+
prevProps.clusteringEnabled !== nextProps.clusteringEnabled ||
|
|
101
|
+
prevProps.animation !== nextProps.animation ||
|
|
102
|
+
prevProps.fontSize !== nextProps.fontSize ||
|
|
103
|
+
prevProps.cornerRadius !== nextProps.cornerRadius ||
|
|
104
|
+
prevProps.paddingHorizontal !== nextProps.paddingHorizontal ||
|
|
105
|
+
prevProps.paddingVertical !== nextProps.paddingVertical ||
|
|
106
|
+
prevProps.shadowOpacity !== nextProps.shadowOpacity
|
|
107
|
+
) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Compare coordinate
|
|
112
|
+
if (
|
|
113
|
+
prevProps.coordinate?.latitude !== nextProps.coordinate?.latitude ||
|
|
114
|
+
prevProps.coordinate?.longitude !== nextProps.coordinate?.longitude
|
|
115
|
+
) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Compare anchor
|
|
120
|
+
if (
|
|
121
|
+
prevProps.anchor?.x !== nextProps.anchor?.x ||
|
|
122
|
+
prevProps.anchor?.y !== nextProps.anchor?.y
|
|
123
|
+
) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Compare colors (handles both hex strings and MarkerColor objects)
|
|
128
|
+
const compareColors = (
|
|
129
|
+
a: ColorValue | undefined,
|
|
130
|
+
b: ColorValue | undefined
|
|
131
|
+
) => {
|
|
132
|
+
if (!a && !b) return true;
|
|
133
|
+
if (!a || !b) return false;
|
|
134
|
+
// If both are strings, compare directly
|
|
135
|
+
if (typeof a === 'string' && typeof b === 'string') return a === b;
|
|
136
|
+
// If types differ, not equal
|
|
137
|
+
if (typeof a !== typeof b) return false;
|
|
138
|
+
// Both are MarkerColor objects
|
|
139
|
+
const aColor = a as MarkerColor;
|
|
140
|
+
const bColor = b as MarkerColor;
|
|
141
|
+
return (
|
|
142
|
+
aColor.r === bColor.r &&
|
|
143
|
+
aColor.g === bColor.g &&
|
|
144
|
+
aColor.b === bColor.b &&
|
|
145
|
+
aColor.a === bColor.a
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
if (
|
|
150
|
+
!compareColors(prevProps.backgroundColor, nextProps.backgroundColor) ||
|
|
151
|
+
!compareColors(prevProps.textColor, nextProps.textColor) ||
|
|
152
|
+
!compareColors(
|
|
153
|
+
prevProps.selectedBackgroundColor,
|
|
154
|
+
nextProps.selectedBackgroundColor
|
|
155
|
+
) ||
|
|
156
|
+
!compareColors(prevProps.selectedTextColor, nextProps.selectedTextColor)
|
|
157
|
+
) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return true;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* PriceMarker - Display price tags on the map
|
|
166
|
+
*
|
|
167
|
+
* @example Simple price tag
|
|
168
|
+
* ```tsx
|
|
169
|
+
* <PriceMarker
|
|
170
|
+
* coordinate={{ latitude: 41.29, longitude: 69.24 }}
|
|
171
|
+
* price="150K"
|
|
172
|
+
* />
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @example Full price marker with currency
|
|
176
|
+
* ```tsx
|
|
177
|
+
* <PriceMarker
|
|
178
|
+
* coordinate={{ latitude: 41.30, longitude: 69.25 }}
|
|
179
|
+
* price="9M"
|
|
180
|
+
* currency="UZS"
|
|
181
|
+
* selected={isSelected}
|
|
182
|
+
* onPress={() => setSelected(true)}
|
|
183
|
+
* />
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export const PriceMarker = memo(function PriceMarker({
|
|
187
|
+
// Required
|
|
188
|
+
coordinate,
|
|
189
|
+
price,
|
|
190
|
+
|
|
191
|
+
// Identification
|
|
192
|
+
id,
|
|
193
|
+
|
|
194
|
+
// Price-specific props
|
|
195
|
+
currency,
|
|
196
|
+
selected = false,
|
|
197
|
+
backgroundColor,
|
|
198
|
+
textColor,
|
|
199
|
+
fontSize = 14,
|
|
200
|
+
// cornerRadius prop kept for backwards compatibility but not used
|
|
201
|
+
selectedBackgroundColor,
|
|
202
|
+
selectedTextColor,
|
|
203
|
+
paddingHorizontal,
|
|
204
|
+
paddingVertical,
|
|
205
|
+
shadowOpacity,
|
|
206
|
+
|
|
207
|
+
// Common props
|
|
208
|
+
title,
|
|
209
|
+
description,
|
|
210
|
+
draggable = false,
|
|
211
|
+
opacity = 1,
|
|
212
|
+
rotation = 0,
|
|
213
|
+
zIndex = 0,
|
|
214
|
+
anchor = { x: 0.5, y: 0.5 },
|
|
215
|
+
clusteringEnabled = true,
|
|
216
|
+
animation = 'none',
|
|
217
|
+
|
|
218
|
+
// Events
|
|
219
|
+
onPress,
|
|
220
|
+
onDragStart,
|
|
221
|
+
onDrag,
|
|
222
|
+
onDragEnd,
|
|
223
|
+
}: PriceMarkerProps) {
|
|
224
|
+
// Build marker config based on style
|
|
225
|
+
const buildMarkerConfig = useCallback(() => {
|
|
226
|
+
// Always use priceMarker style - 'price' is not a valid MarkerStyle
|
|
227
|
+
return {
|
|
228
|
+
style: 'priceMarker' as const,
|
|
229
|
+
priceMarker: {
|
|
230
|
+
price,
|
|
231
|
+
currency: currency ?? '', // Default to empty string if no currency
|
|
232
|
+
selected,
|
|
233
|
+
backgroundColor: parseColor(backgroundColor),
|
|
234
|
+
selectedBackgroundColor: parseColor(selectedBackgroundColor),
|
|
235
|
+
textColor: parseColor(textColor),
|
|
236
|
+
selectedTextColor: parseColor(selectedTextColor),
|
|
237
|
+
fontSize,
|
|
238
|
+
paddingHorizontal,
|
|
239
|
+
paddingVertical,
|
|
240
|
+
shadowOpacity,
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}, [
|
|
244
|
+
price,
|
|
245
|
+
currency,
|
|
246
|
+
selected,
|
|
247
|
+
backgroundColor,
|
|
248
|
+
textColor,
|
|
249
|
+
fontSize,
|
|
250
|
+
selectedBackgroundColor,
|
|
251
|
+
selectedTextColor,
|
|
252
|
+
paddingHorizontal,
|
|
253
|
+
paddingVertical,
|
|
254
|
+
shadowOpacity,
|
|
255
|
+
]);
|
|
256
|
+
|
|
257
|
+
// Memoize handlers
|
|
258
|
+
const handlers = useMemo(
|
|
259
|
+
() => ({
|
|
260
|
+
onPress,
|
|
261
|
+
onDragStart,
|
|
262
|
+
onDrag,
|
|
263
|
+
onDragEnd,
|
|
264
|
+
}),
|
|
265
|
+
[onPress, onDragStart, onDrag, onDragEnd]
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
// Build full marker data
|
|
269
|
+
const buildMarkerData = useCallback(
|
|
270
|
+
(markerId: string) => ({
|
|
271
|
+
id: markerId,
|
|
272
|
+
coordinate,
|
|
273
|
+
title,
|
|
274
|
+
description,
|
|
275
|
+
draggable,
|
|
276
|
+
opacity,
|
|
277
|
+
rotation,
|
|
278
|
+
zIndex,
|
|
279
|
+
anchor,
|
|
280
|
+
clusteringEnabled,
|
|
281
|
+
config: buildMarkerConfig(),
|
|
282
|
+
animation,
|
|
283
|
+
}),
|
|
284
|
+
[
|
|
285
|
+
coordinate,
|
|
286
|
+
title,
|
|
287
|
+
description,
|
|
288
|
+
draggable,
|
|
289
|
+
opacity,
|
|
290
|
+
rotation,
|
|
291
|
+
zIndex,
|
|
292
|
+
anchor,
|
|
293
|
+
clusteringEnabled,
|
|
294
|
+
buildMarkerConfig,
|
|
295
|
+
animation,
|
|
296
|
+
]
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
// Use shared marker hook
|
|
300
|
+
useNitroMarker({
|
|
301
|
+
idPrefix: 'price_marker',
|
|
302
|
+
providedId: id,
|
|
303
|
+
handlers,
|
|
304
|
+
buildMarkerData,
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
// Render nothing - marker is rendered natively
|
|
308
|
+
return null;
|
|
309
|
+
}, arePropsEqual);
|
|
310
|
+
|
|
311
|
+
export default PriceMarker;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/components/NitroMapContext.tsx
|
|
2
|
+
import { createContext } from 'react';
|
|
3
|
+
import type { NitroMapMethods } from '../specs/NitroMap.nitro';
|
|
4
|
+
import type { Coordinate } from '../types/map';
|
|
5
|
+
|
|
6
|
+
// Marker event handlers
|
|
7
|
+
export interface MarkerHandlers {
|
|
8
|
+
onPress?: () => void;
|
|
9
|
+
onDragStart?: (coordinate: Coordinate) => void;
|
|
10
|
+
onDrag?: (coordinate: Coordinate) => void;
|
|
11
|
+
onDragEnd?: (coordinate: Coordinate) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Context value type
|
|
15
|
+
export interface NitroMapContextValue {
|
|
16
|
+
// Map ref for calling native methods
|
|
17
|
+
mapRef: NitroMapMethods | null;
|
|
18
|
+
|
|
19
|
+
// Register marker event handlers
|
|
20
|
+
registerMarkerHandler: (markerId: string, handlers: MarkerHandlers) => void;
|
|
21
|
+
|
|
22
|
+
// Unregister marker event handlers
|
|
23
|
+
unregisterMarkerHandler: (markerId: string) => void;
|
|
24
|
+
|
|
25
|
+
// Get handlers for a specific marker (used internally)
|
|
26
|
+
getMarkerHandler: (markerId: string) => MarkerHandlers | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Create context with null default
|
|
30
|
+
export const NitroMapContext = createContext<NitroMapContextValue | null>(null);
|
|
31
|
+
|
|
32
|
+
// Provider display name for debugging
|
|
33
|
+
NitroMapContext.displayName = 'NitroMapContext';
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// src/hooks/useNitroMarker.ts
|
|
2
|
+
import { useContext, useEffect, useRef, useCallback } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
NitroMapContext,
|
|
5
|
+
type MarkerHandlers,
|
|
6
|
+
} from '../context/NitroMapContext';
|
|
7
|
+
import type { MarkerConfig, MarkerAnimation } from '../types/marker';
|
|
8
|
+
import type { Coordinate, Point } from '../types/map';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Base marker data structure for internal use
|
|
12
|
+
*/
|
|
13
|
+
export interface BaseMarkerData {
|
|
14
|
+
id: string;
|
|
15
|
+
coordinate: Coordinate;
|
|
16
|
+
title?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
draggable: boolean;
|
|
19
|
+
opacity: number;
|
|
20
|
+
rotation: number;
|
|
21
|
+
zIndex: number;
|
|
22
|
+
anchor: Point;
|
|
23
|
+
clusteringEnabled: boolean;
|
|
24
|
+
config: MarkerConfig;
|
|
25
|
+
animation: MarkerAnimation;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Props shared by all marker components
|
|
30
|
+
*/
|
|
31
|
+
export interface CommonMarkerProps {
|
|
32
|
+
/** Unique identifier for the marker */
|
|
33
|
+
id?: string;
|
|
34
|
+
|
|
35
|
+
/** Geographic coordinates where the marker should be placed */
|
|
36
|
+
coordinate: Coordinate;
|
|
37
|
+
|
|
38
|
+
/** Title shown in info window when marker is tapped */
|
|
39
|
+
title?: string;
|
|
40
|
+
|
|
41
|
+
/** Description shown in info window below the title */
|
|
42
|
+
description?: string;
|
|
43
|
+
|
|
44
|
+
/** Whether the marker can be dragged by the user */
|
|
45
|
+
draggable?: boolean;
|
|
46
|
+
|
|
47
|
+
/** Marker opacity (0 = transparent, 1 = opaque) */
|
|
48
|
+
opacity?: number;
|
|
49
|
+
|
|
50
|
+
/** Rotation angle in degrees (clockwise from north) */
|
|
51
|
+
rotation?: number;
|
|
52
|
+
|
|
53
|
+
/** Z-index for controlling overlap order */
|
|
54
|
+
zIndex?: number;
|
|
55
|
+
|
|
56
|
+
/** Anchor point for positioning (0-1 range) */
|
|
57
|
+
anchor?: Point;
|
|
58
|
+
|
|
59
|
+
/** Whether this marker should be included in clustering */
|
|
60
|
+
clusteringEnabled?: boolean;
|
|
61
|
+
|
|
62
|
+
/** Animation when marker appears on the map */
|
|
63
|
+
animation?: MarkerAnimation;
|
|
64
|
+
|
|
65
|
+
/** Called when the marker is tapped */
|
|
66
|
+
onPress?: () => void;
|
|
67
|
+
|
|
68
|
+
/** Called when the marker starts being dragged */
|
|
69
|
+
onDragStart?: (coordinate: Coordinate) => void;
|
|
70
|
+
|
|
71
|
+
/** Called continuously while the marker is being dragged */
|
|
72
|
+
onDrag?: (coordinate: Coordinate) => void;
|
|
73
|
+
|
|
74
|
+
/** Called when the marker is dropped (drag ends) */
|
|
75
|
+
onDragEnd?: (coordinate: Coordinate) => void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ID generator
|
|
79
|
+
let markerIdCounter = 0;
|
|
80
|
+
const generateMarkerId = (prefix: string) =>
|
|
81
|
+
`${prefix}_${++markerIdCounter}_${Date.now()}`;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Hook options for useNitroMarker
|
|
85
|
+
*/
|
|
86
|
+
export interface UseNitroMarkerOptions {
|
|
87
|
+
/** ID prefix for auto-generated IDs */
|
|
88
|
+
idPrefix: string;
|
|
89
|
+
|
|
90
|
+
/** User-provided ID (optional) */
|
|
91
|
+
providedId?: string;
|
|
92
|
+
|
|
93
|
+
/** Event handlers */
|
|
94
|
+
handlers: MarkerHandlers;
|
|
95
|
+
|
|
96
|
+
/** Function to build marker data - receives the generated/provided markerId */
|
|
97
|
+
buildMarkerData: (markerId: string) => BaseMarkerData;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Shared hook for all marker components
|
|
102
|
+
* Handles ID generation, context registration, and marker lifecycle
|
|
103
|
+
*/
|
|
104
|
+
export function useNitroMarker({
|
|
105
|
+
idPrefix,
|
|
106
|
+
providedId,
|
|
107
|
+
handlers,
|
|
108
|
+
buildMarkerData,
|
|
109
|
+
}: UseNitroMarkerOptions): string {
|
|
110
|
+
// Generate stable ID
|
|
111
|
+
const markerId = useRef(providedId || generateMarkerId(idPrefix)).current;
|
|
112
|
+
|
|
113
|
+
// Get map context
|
|
114
|
+
const mapContext = useContext(NitroMapContext);
|
|
115
|
+
|
|
116
|
+
// Track if marker has been added
|
|
117
|
+
const isAddedRef = useRef(false);
|
|
118
|
+
|
|
119
|
+
// ============ Register Event Handlers ============
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (!mapContext) {
|
|
122
|
+
console.warn(`${idPrefix} must be used inside NitroMap`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Register handlers
|
|
127
|
+
mapContext.registerMarkerHandler(markerId, handlers);
|
|
128
|
+
|
|
129
|
+
// Cleanup on unmount
|
|
130
|
+
return () => {
|
|
131
|
+
mapContext.unregisterMarkerHandler(markerId);
|
|
132
|
+
};
|
|
133
|
+
// We intentionally depend on individual handler properties instead of the handlers object
|
|
134
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
135
|
+
}, [
|
|
136
|
+
markerId,
|
|
137
|
+
mapContext,
|
|
138
|
+
handlers.onPress,
|
|
139
|
+
handlers.onDragStart,
|
|
140
|
+
handlers.onDrag,
|
|
141
|
+
handlers.onDragEnd,
|
|
142
|
+
idPrefix,
|
|
143
|
+
]);
|
|
144
|
+
|
|
145
|
+
// ============ Add Marker on Mount, Remove on Unmount ============
|
|
146
|
+
// NOTE: mapContext is a ref object, so we must track mapContext.mapRef separately
|
|
147
|
+
const mapRef = mapContext?.mapRef;
|
|
148
|
+
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
if (!mapRef) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Add marker on mount
|
|
155
|
+
mapRef.addMarker(buildMarkerData(markerId));
|
|
156
|
+
isAddedRef.current = true;
|
|
157
|
+
|
|
158
|
+
// Remove marker only on unmount
|
|
159
|
+
return () => {
|
|
160
|
+
mapRef?.removeMarker(markerId);
|
|
161
|
+
isAddedRef.current = false;
|
|
162
|
+
};
|
|
163
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
164
|
+
}, [mapRef, markerId]); // mapRef is now properly tracked
|
|
165
|
+
|
|
166
|
+
// ============ Update Marker when props change ============
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
// Skip if not yet added or no map ref
|
|
169
|
+
if (!isAddedRef.current || !mapContext?.mapRef) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Update marker with new data
|
|
174
|
+
mapContext.mapRef.updateMarker(buildMarkerData(markerId));
|
|
175
|
+
}, [mapContext, buildMarkerData, markerId]);
|
|
176
|
+
|
|
177
|
+
return markerId;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Create stable handlers object that won't cause unnecessary re-renders
|
|
182
|
+
*/
|
|
183
|
+
export function useMarkerHandlers(
|
|
184
|
+
onPress?: () => void,
|
|
185
|
+
onDragStart?: (coordinate: Coordinate) => void,
|
|
186
|
+
onDrag?: (coordinate: Coordinate) => void,
|
|
187
|
+
onDragEnd?: (coordinate: Coordinate) => void
|
|
188
|
+
): MarkerHandlers {
|
|
189
|
+
return useCallback(
|
|
190
|
+
() => ({
|
|
191
|
+
onPress,
|
|
192
|
+
onDragStart,
|
|
193
|
+
onDrag,
|
|
194
|
+
onDragEnd,
|
|
195
|
+
}),
|
|
196
|
+
[onPress, onDragStart, onDrag, onDragEnd]
|
|
197
|
+
)();
|
|
198
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
|
|
3
|
+
// ============ Components ============
|
|
4
|
+
export { NitroMap, default } from './components/NitroMap';
|
|
5
|
+
|
|
6
|
+
// New specialized marker components
|
|
7
|
+
export { PriceMarker } from './components/PriceMarker';
|
|
8
|
+
export { ImageMarker } from './components/ImageMarker';
|
|
9
|
+
|
|
10
|
+
// ============ Types ============
|
|
11
|
+
export type { NitroMapProps, NitroMapRef } from './components/NitroMap';
|
|
12
|
+
|
|
13
|
+
export type {
|
|
14
|
+
Region,
|
|
15
|
+
Coordinate,
|
|
16
|
+
MapType,
|
|
17
|
+
MapPressEvent,
|
|
18
|
+
RegionChangeEvent,
|
|
19
|
+
EdgePadding,
|
|
20
|
+
Camera,
|
|
21
|
+
MapBoundaries,
|
|
22
|
+
MapStyleElement,
|
|
23
|
+
MapStyler,
|
|
24
|
+
MapProvider,
|
|
25
|
+
MapStyle,
|
|
26
|
+
MapError,
|
|
27
|
+
Point,
|
|
28
|
+
} from './types/map';
|
|
29
|
+
|
|
30
|
+
export type {
|
|
31
|
+
MarkerStyle,
|
|
32
|
+
PriceMarkerStyle,
|
|
33
|
+
MarkerColor,
|
|
34
|
+
PriceMarkerConfig,
|
|
35
|
+
ImageMarkerConfig,
|
|
36
|
+
ClusterPressEvent,
|
|
37
|
+
ClusterConfig,
|
|
38
|
+
ClusterStrategy,
|
|
39
|
+
ClusterAnimationStyle,
|
|
40
|
+
MarkerAnimation,
|
|
41
|
+
MarkerConfig,
|
|
42
|
+
MarkerData,
|
|
43
|
+
MarkerDragEvent,
|
|
44
|
+
MarkerPressEvent,
|
|
45
|
+
} from './types/marker';
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
NitroMapInitialize,
|
|
49
|
+
IsNitroMapInitialized,
|
|
50
|
+
getDefaultProvider,
|
|
51
|
+
type NitroMapInitConfig,
|
|
52
|
+
} from './modules';
|
|
53
|
+
|
|
54
|
+
// Marker component props
|
|
55
|
+
|
|
56
|
+
export type { PriceMarkerProps } from './components/PriceMarker';
|
|
57
|
+
export type { ImageMarkerProps } from './components/ImageMarker';
|
|
58
|
+
|
|
59
|
+
// ============ Utilities ============
|
|
60
|
+
// Color helpers - use these to create colors for markers and clusters
|
|
61
|
+
export { rgb, hex, Colors } from './utils/colors';
|
|
62
|
+
export type { ColorValue } from './utils/colors';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import type { NitroMapConfig } from '../specs/NitroMapConfig.nitro';
|
|
3
|
+
import type { MapProvider } from '../types/map';
|
|
4
|
+
|
|
5
|
+
const NitroMapConfig =
|
|
6
|
+
NitroModules.createHybridObject<NitroMapConfig>('NitroMapConfig');
|
|
7
|
+
|
|
8
|
+
// Store the default provider set during initialization
|
|
9
|
+
let defaultProvider: MapProvider = 'google';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for NitroMap initialization.
|
|
13
|
+
*/
|
|
14
|
+
export interface NitroMapInitConfig {
|
|
15
|
+
/** Map provider to use ('google' | 'apple' | 'yandex') */
|
|
16
|
+
provider: MapProvider;
|
|
17
|
+
/** Google Maps API key (required for Google provider) */
|
|
18
|
+
googleApiKey?: string;
|
|
19
|
+
/** Yandex Maps API key (required for Yandex provider) */
|
|
20
|
+
yandexApiKey?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the NitroMap SDK. Must be called before rendering <NitroMap>.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* NitroMapInitialize({ provider: 'google', googleApiKey: 'YOUR_KEY' });
|
|
28
|
+
*/
|
|
29
|
+
export function NitroMapInitialize(config: NitroMapInitConfig): void {
|
|
30
|
+
const apiKey =
|
|
31
|
+
config.provider === 'yandex'
|
|
32
|
+
? config.yandexApiKey ?? ''
|
|
33
|
+
: config.googleApiKey ?? '';
|
|
34
|
+
|
|
35
|
+
defaultProvider = config.provider;
|
|
36
|
+
NitroMapConfig.NitroMapInitialize(apiKey, config.provider);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function IsNitroMapInitialized(): boolean {
|
|
40
|
+
return NitroMapConfig.IsNitroMapInitialized();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getDefaultProvider(): MapProvider {
|
|
44
|
+
return defaultProvider;
|
|
45
|
+
}
|