expo-gaode-map 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +320 -0
- package/README.md +2 -0
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapModule.kt +1 -298
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +19 -3
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapViewModule.kt +126 -0
- package/android/src/main/java/expo/modules/gaodemap/managers/UIManager.kt +22 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/CircleViewModule.kt +41 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/ClusterViewModule.kt +29 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/HeatMapViewModule.kt +27 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +53 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerViewModule.kt +49 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/MultiPointViewModule.kt +21 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolygonViewModule.kt +37 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineView.kt +2 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineViewModule.kt +45 -0
- package/build/ExpoGaodeMapView.js +1 -1
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/components/overlays/Cluster.d.ts.map +1 -1
- package/build/components/overlays/Cluster.js +1 -1
- package/build/components/overlays/Cluster.js.map +1 -1
- package/build/components/overlays/HeatMap.d.ts.map +1 -1
- package/build/components/overlays/HeatMap.js +1 -1
- package/build/components/overlays/HeatMap.js.map +1 -1
- package/build/components/overlays/Marker.d.ts.map +1 -1
- package/build/components/overlays/Marker.js +29 -0
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/components/overlays/MultiPoint.d.ts.map +1 -1
- package/build/components/overlays/MultiPoint.js +1 -1
- package/build/components/overlays/MultiPoint.js.map +1 -1
- package/build/types/map-view.types.d.ts +2 -1
- package/build/types/map-view.types.d.ts.map +1 -1
- package/build/types/map-view.types.js.map +1 -1
- package/docs/API.en.md +418 -0
- package/docs/API.md +2 -0
- package/docs/ARCHITECTURE.en.md +423 -0
- package/docs/ARCHITECTURE.md +2 -0
- package/docs/EXAMPLES.en.md +642 -0
- package/docs/EXAMPLES.md +2 -0
- package/docs/INITIALIZATION.en.md +346 -0
- package/docs/INITIALIZATION.md +2 -0
- package/expo-module.config.json +22 -2
- package/ios/ExpoGaodeMapModule.swift +0 -334
- package/ios/ExpoGaodeMapView.swift +19 -5
- package/ios/ExpoGaodeMapViewModule.swift +155 -0
- package/ios/managers/UIManager.swift +32 -4
- package/ios/overlays/CircleViewModule.swift +31 -0
- package/ios/overlays/ClusterViewModule.swift +23 -0
- package/ios/overlays/HeatMapViewModule.swift +21 -0
- package/ios/overlays/MarkerView.swift +50 -2
- package/ios/overlays/MarkerViewModule.swift +53 -0
- package/ios/overlays/MultiPointViewModule.swift +15 -0
- package/ios/overlays/PolygonViewModule.swift +27 -0
- package/ios/overlays/PolylineViewModule.swift +39 -0
- package/package.json +1 -1
- package/src/ExpoGaodeMapView.tsx +1 -1
- package/src/components/overlays/Cluster.tsx +2 -1
- package/src/components/overlays/HeatMap.tsx +2 -1
- package/src/components/overlays/Marker.tsx +47 -0
- package/src/components/overlays/MultiPoint.tsx +2 -1
- package/src/types/map-view.types.ts +2 -1
|
@@ -49,6 +49,8 @@ class MarkerView: ExpoView {
|
|
|
49
49
|
|
|
50
50
|
required init(appContext: AppContext? = nil) {
|
|
51
51
|
super.init(appContext: appContext)
|
|
52
|
+
// 不可交互,通过父视图定位到屏幕外
|
|
53
|
+
isUserInteractionEnabled = false
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
/**
|
|
@@ -84,8 +86,54 @@ class MarkerView: ExpoView {
|
|
|
84
86
|
mapView.addAnnotation(annotation)
|
|
85
87
|
self.annotation = annotation
|
|
86
88
|
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
+
// 延迟处理子视图,等待 React Native 添加完成
|
|
90
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
|
|
91
|
+
guard let self = self else { return }
|
|
92
|
+
if let view = mapView.view(for: annotation), self.subviews.count > 0 {
|
|
93
|
+
self.annotationView = view
|
|
94
|
+
if let image = self.createImageFromSubviews() {
|
|
95
|
+
view.image = image
|
|
96
|
+
view.centerOffset = CGPoint(x: 0, y: -image.size.height / 2)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 将子视图转换为图片
|
|
104
|
+
*/
|
|
105
|
+
private func createImageFromSubviews() -> UIImage? {
|
|
106
|
+
guard subviews.count > 0 else { return nil }
|
|
107
|
+
|
|
108
|
+
// 强制布局
|
|
109
|
+
setNeedsLayout()
|
|
110
|
+
layoutIfNeeded()
|
|
111
|
+
|
|
112
|
+
let size = bounds.size
|
|
113
|
+
guard size.width > 0 && size.height > 0 else { return nil }
|
|
114
|
+
|
|
115
|
+
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
|
|
116
|
+
defer { UIGraphicsEndImageContext() }
|
|
117
|
+
|
|
118
|
+
guard let context = UIGraphicsGetCurrentContext() else { return nil }
|
|
119
|
+
layer.render(in: context)
|
|
120
|
+
|
|
121
|
+
return UIGraphicsGetImageFromCurrentImageContext()
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
override func didAddSubview(_ subview: UIView) {
|
|
125
|
+
super.didAddSubview(subview)
|
|
126
|
+
|
|
127
|
+
// 当添加子视图时,更新标记图标
|
|
128
|
+
DispatchQueue.main.async { [weak self] in
|
|
129
|
+
guard let self = self else { return }
|
|
130
|
+
if self.subviews.count > 0, let view = self.annotationView {
|
|
131
|
+
if let image = self.createImageFromSubviews() {
|
|
132
|
+
view.image = image
|
|
133
|
+
view.centerOffset = CGPoint(x: 0, y: -image.size.height / 2)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
89
137
|
}
|
|
90
138
|
|
|
91
139
|
/**
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
public class MarkerViewModule: Module {
|
|
4
|
+
public func definition() -> ModuleDefinition {
|
|
5
|
+
Name("MarkerView")
|
|
6
|
+
|
|
7
|
+
View(MarkerView.self) {
|
|
8
|
+
Prop("position") { (view: MarkerView, position: [String: Double]) in
|
|
9
|
+
view.setPosition(position)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Prop("title") { (view: MarkerView, title: String) in
|
|
13
|
+
view.setTitle(title)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Prop("snippet") { (view: MarkerView, snippet: String) in
|
|
17
|
+
view.setDescription(snippet)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Prop("draggable") { (view: MarkerView, draggable: Bool) in
|
|
21
|
+
view.setDraggable(draggable)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Prop("icon") { (view: MarkerView, source: [String: Any]?) in
|
|
25
|
+
view.setIcon(source)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Prop("iconWidth") { (view: MarkerView, width: Double) in
|
|
29
|
+
view.iconWidth = width
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Prop("iconHeight") { (view: MarkerView, height: Double) in
|
|
33
|
+
view.iconHeight = height
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Prop("centerOffset") { (view: MarkerView, offset: [String: Double]) in
|
|
37
|
+
view.setCenterOffset(offset)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Prop("animatesDrop") { (view: MarkerView, animate: Bool) in
|
|
41
|
+
view.setAnimatesDrop(animate)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Prop("pinColor") { (view: MarkerView, color: String) in
|
|
45
|
+
view.setPinColor(color)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Prop("canShowCallout") { (view: MarkerView, show: Bool) in
|
|
49
|
+
view.setCanShowCallout(show)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
public class MultiPointViewModule: Module {
|
|
4
|
+
public func definition() -> ModuleDefinition {
|
|
5
|
+
Name("MultiPointView")
|
|
6
|
+
|
|
7
|
+
View(MultiPointView.self) {
|
|
8
|
+
Events("onPress")
|
|
9
|
+
|
|
10
|
+
Prop("points") { (view: MultiPointView, points: [[String: Any]]) in
|
|
11
|
+
view.setPoints(points)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
public class PolygonViewModule: Module {
|
|
4
|
+
public func definition() -> ModuleDefinition {
|
|
5
|
+
Name("PolygonView")
|
|
6
|
+
|
|
7
|
+
View(PolygonView.self) {
|
|
8
|
+
Events("onPress")
|
|
9
|
+
|
|
10
|
+
Prop("points") { (view: PolygonView, points: [[String: Double]]) in
|
|
11
|
+
view.setPoints(points)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Prop("fillColor") { (view: PolygonView, color: String) in
|
|
15
|
+
view.setFillColor(color)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Prop("strokeColor") { (view: PolygonView, color: String) in
|
|
19
|
+
view.setStrokeColor(color)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Prop("strokeWidth") { (view: PolygonView, width: Double) in
|
|
23
|
+
view.setStrokeWidth(Float(width))
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
public class PolylineViewModule: Module {
|
|
4
|
+
public func definition() -> ModuleDefinition {
|
|
5
|
+
Name("PolylineView")
|
|
6
|
+
|
|
7
|
+
View(PolylineView.self) {
|
|
8
|
+
Events("onPress")
|
|
9
|
+
|
|
10
|
+
Prop("points") { (view: PolylineView, points: [[String: Double]]) in
|
|
11
|
+
view.setPoints(points)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Prop("width") { (view: PolylineView, width: Double) in
|
|
15
|
+
view.setStrokeWidth(Float(width))
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Prop("strokeWidth") { (view: PolylineView, width: Double) in
|
|
19
|
+
view.setStrokeWidth(Float(width))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Prop("color") { (view: PolylineView, color: String) in
|
|
23
|
+
view.setStrokeColor(color)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Prop("strokeColor") { (view: PolylineView, color: String) in
|
|
27
|
+
view.setStrokeColor(color)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Prop("texture") { (view: PolylineView, url: String?) in
|
|
31
|
+
view.setTexture(url)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Prop("dotted") { (view: PolylineView, dotted: Bool) in
|
|
35
|
+
view.setDotted(dotted)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
package/package.json
CHANGED
package/src/ExpoGaodeMapView.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
|
|
17
17
|
export type { MapViewRef } from './types';
|
|
18
18
|
|
|
19
|
-
const NativeView: React.ComponentType<MapViewProps & { ref?: React.Ref<NativeMapViewRef> }> = requireNativeViewManager('
|
|
19
|
+
const NativeView: React.ComponentType<MapViewProps & { ref?: React.Ref<NativeMapViewRef> }> = requireNativeViewManager('ExpoGaodeMapView');
|
|
20
20
|
|
|
21
21
|
export const MapContext = React.createContext<React.RefObject<MapViewRef | null> | null>(null);
|
|
22
22
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
|
|
1
2
|
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import type { ClusterProps } from '../../types';
|
|
4
5
|
|
|
5
|
-
const NativeCluster = requireNativeViewManager('
|
|
6
|
+
const NativeCluster = requireNativeViewManager('ClusterView');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
|
|
1
2
|
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import type { HeatMapProps } from '../../types';
|
|
4
5
|
|
|
5
|
-
const NativeHeatMap = requireNativeViewManager('
|
|
6
|
+
const NativeHeatMap = requireNativeViewManager('HeatMapView');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -1,12 +1,59 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Image } from 'react-native';
|
|
3
|
+
import { requireNativeViewManager } from 'expo-modules-core';
|
|
3
4
|
import { MapContext, MarkerEventContext } from '../../ExpoGaodeMapView';
|
|
4
5
|
import type { MarkerProps } from '../../types';
|
|
5
6
|
|
|
7
|
+
const NativeMarkerView = requireNativeViewManager('MarkerView');
|
|
8
|
+
|
|
6
9
|
export default function Marker(props: MarkerProps) {
|
|
10
|
+
// 如果有 children,使用声明式 API
|
|
11
|
+
if (props.children) {
|
|
12
|
+
return <MarkerDeclarative {...props} />;
|
|
13
|
+
}
|
|
14
|
+
// 否则使用命令式 API
|
|
7
15
|
return <MarkerImperative {...props} />;
|
|
8
16
|
}
|
|
9
17
|
|
|
18
|
+
function MarkerDeclarative(props: MarkerProps) {
|
|
19
|
+
const eventManager = React.useContext(MarkerEventContext);
|
|
20
|
+
const markerIdRef = React.useRef(`marker_${Date.now()}_${Math.random()}`);
|
|
21
|
+
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (eventManager) {
|
|
24
|
+
eventManager.register(markerIdRef.current, {
|
|
25
|
+
onPress: props.onPress,
|
|
26
|
+
onDragStart: props.onDragStart,
|
|
27
|
+
onDrag: props.onDrag,
|
|
28
|
+
onDragEnd: props.onDragEnd,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return () => {
|
|
32
|
+
if (eventManager) {
|
|
33
|
+
eventManager.unregister(markerIdRef.current);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, [props.onPress, props.onDragStart, props.onDrag, props.onDragEnd]);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<NativeMarkerView
|
|
40
|
+
position={props.position}
|
|
41
|
+
title={props.title}
|
|
42
|
+
draggable={props.draggable}
|
|
43
|
+
opacity={props.opacity}
|
|
44
|
+
anchor={props.anchor}
|
|
45
|
+
flat={props.flat}
|
|
46
|
+
zIndex={props.zIndex}
|
|
47
|
+
onPress={props.onPress}
|
|
48
|
+
onDragStart={props.onDragStart}
|
|
49
|
+
onDrag={props.onDrag}
|
|
50
|
+
onDragEnd={props.onDragEnd}
|
|
51
|
+
>
|
|
52
|
+
{props.children}
|
|
53
|
+
</NativeMarkerView>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
10
57
|
function MarkerImperative(props: MarkerProps) {
|
|
11
58
|
const mapRef = React.useContext(MapContext);
|
|
12
59
|
const eventManager = React.useContext(MarkerEventContext);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
|
|
1
2
|
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import type { MultiPointProps } from '../../types';
|
|
4
5
|
|
|
5
|
-
const NativeMultiPoint = requireNativeViewManager('
|
|
6
|
+
const NativeMultiPoint = requireNativeViewManager('MultiPointView');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
7
7
|
import type { CameraPosition, LatLng, LatLngBounds, MapPoi, MapType, Point } from './common.types';
|
|
8
|
+
import type { Coordinates, ReGeocode } from './location.types';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* 地图相机事件
|
|
@@ -197,7 +198,7 @@ export interface MapViewProps {
|
|
|
197
198
|
/**
|
|
198
199
|
* 地图定位更新事件
|
|
199
200
|
*/
|
|
200
|
-
onLocation?: (event:
|
|
201
|
+
onLocation?: (event: Coordinates | ReGeocode) => void;
|
|
201
202
|
|
|
202
203
|
/**
|
|
203
204
|
* Marker 点击事件
|