@react-native-ohos/react-native-amap3d 3.2.5-rc.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.
- package/LICENSE +21 -0
- package/README.OpenSource +11 -0
- package/README.md +10 -0
- package/harmony/rn_amap3d/BuildProfile.ets +6 -0
- package/harmony/rn_amap3d/build-profile.json5 +28 -0
- package/harmony/rn_amap3d/consumer-rules.txt +0 -0
- package/harmony/rn_amap3d/hvigorfile.ts +6 -0
- package/harmony/rn_amap3d/index.ets +30 -0
- package/harmony/rn_amap3d/obfuscation-rules.txt +18 -0
- package/harmony/rn_amap3d/oh-package.json5 +16 -0
- package/harmony/rn_amap3d/src/main/cpp/AMap3dEventEmitRequestHandler.h +218 -0
- package/harmony/rn_amap3d/src/main/cpp/AMapEventEmitters.cpp +132 -0
- package/harmony/rn_amap3d/src/main/cpp/AMapEventEmitters.h +111 -0
- package/harmony/rn_amap3d/src/main/cpp/CMakeLists.txt +7 -0
- package/harmony/rn_amap3d/src/main/cpp/ComponentDescriptors.h +19 -0
- package/harmony/rn_amap3d/src/main/cpp/MapViewJSIBinder.h +168 -0
- package/harmony/rn_amap3d/src/main/cpp/MapViewPackage.h +43 -0
- package/harmony/rn_amap3d/src/main/cpp/Props.cpp +86 -0
- package/harmony/rn_amap3d/src/main/cpp/Props.h +258 -0
- package/harmony/rn_amap3d/src/main/cpp/ShadowNodes.cpp +15 -0
- package/harmony/rn_amap3d/src/main/cpp/ShadowNodes.h +33 -0
- package/harmony/rn_amap3d/src/main/ets/AMap3DModule.ts +32 -0
- package/harmony/rn_amap3d/src/main/ets/AMap3DPackage.ts +46 -0
- package/harmony/rn_amap3d/src/main/ets/GlobalCache.ets +24 -0
- package/harmony/rn_amap3d/src/main/ets/Logger.ets +65 -0
- package/harmony/rn_amap3d/src/main/ets/View/AMapCircle.ets +96 -0
- package/harmony/rn_amap3d/src/main/ets/View/AMapMarker.ets +83 -0
- package/harmony/rn_amap3d/src/main/ets/View/AMapPolygon.ets +52 -0
- package/harmony/rn_amap3d/src/main/ets/View/AMapPolyline.ets +89 -0
- package/harmony/rn_amap3d/src/main/ets/View/MapView.ets +686 -0
- package/harmony/rn_amap3d/src/main/module.json5 +17 -0
- package/harmony/rn_amap3d/src/main/resources/base/element/string.json +8 -0
- package/harmony/rn_amap3d/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/rn_amap3d/src/main/resources/rawfile/location_map_gps_locked.png +0 -0
- package/harmony/rn_amap3d/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/rn_amap3d/ts.ts +28 -0
- package/harmony/rn_amap3d.har +0 -0
- package/lib/src/NativeAMapSdk.ts +9 -0
- package/lib/src/circle.tsx +17 -0
- package/lib/src/circleNativeComponent.ts +47 -0
- package/lib/src/cluster/cluster-view.tsx +47 -0
- package/lib/src/cluster/index.tsx +159 -0
- package/lib/src/component.ts +31 -0
- package/lib/src/heat-map.tsx +17 -0
- package/lib/src/heat-mapNativeComponent.ts +34 -0
- package/lib/src/index.ts +11 -0
- package/lib/src/map-view.tsx +73 -0
- package/lib/src/map-viewNativeComponent.ts +232 -0
- package/lib/src/marker.tsx +32 -0
- package/lib/src/markerNativeComponent.ts +105 -0
- package/lib/src/multi-point.tsx +17 -0
- package/lib/src/multi-pointNativeComponent.ts +51 -0
- package/lib/src/polygon.tsx +17 -0
- package/lib/src/polygonNativeComponent.ts +42 -0
- package/lib/src/polyline.tsx +21 -0
- package/lib/src/polylineNativeComponent.ts +67 -0
- package/lib/src/types.ts +34 -0
- package/package.json +53 -0
- package/react-native.config.js +20 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export * from "./src/main/ets/AMap3DPackage";
|
|
27
|
+
|
|
28
|
+
export * from "./src/main/ets/AMap3DModule";
|
|
Binary file
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TurboModule } from "react-native";
|
|
2
|
+
import { TurboModuleRegistry } from "react-native";
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
initSDK(sdk : string): void;
|
|
6
|
+
getVersion(): Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default TurboModuleRegistry.get<Spec>("AMapSdk");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import AMapCircle ,{CircleProps} from './circleNativeComponent'
|
|
3
|
+
import React , {Component} from 'react';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default class Circle extends Component<CircleProps> {
|
|
7
|
+
|
|
8
|
+
constructor(props: CircleProps) {
|
|
9
|
+
super(props);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
render() {
|
|
13
|
+
return (
|
|
14
|
+
<AMapCircle {...this.props} />
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
HostComponent,
|
|
4
|
+
ViewProps,
|
|
5
|
+
} from "react-native";
|
|
6
|
+
|
|
7
|
+
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent"
|
|
8
|
+
import { Float,Int32 } from "react-native/Libraries/Types/CodegenTypes";
|
|
9
|
+
|
|
10
|
+
type LatLng = Readonly<{
|
|
11
|
+
latitude: Float;
|
|
12
|
+
longitude: Float;
|
|
13
|
+
}>
|
|
14
|
+
|
|
15
|
+
export interface CircleProps extends ViewProps {
|
|
16
|
+
/**
|
|
17
|
+
* 圆点坐标
|
|
18
|
+
*/
|
|
19
|
+
center: LatLng;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 半径(米)
|
|
23
|
+
*/
|
|
24
|
+
radius: Float;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 边线宽度
|
|
28
|
+
*/
|
|
29
|
+
strokeWidth?: Float;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 边线颜色
|
|
33
|
+
*/
|
|
34
|
+
strokeColor?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 填充颜色
|
|
38
|
+
*/
|
|
39
|
+
fillColor?: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 层级
|
|
43
|
+
*/
|
|
44
|
+
zIndex?: Int32;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default codegenNativeComponent<CircleProps>("AMapCircle")as HostComponent<CircleProps>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleSheet, Text, View, ViewStyle } from "react-native";
|
|
3
|
+
import { ClusterParams } from ".";
|
|
4
|
+
import Marker from "../marker";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
cluster: ClusterParams;
|
|
8
|
+
style?: ViewStyle;
|
|
9
|
+
textStyle?: ViewStyle;
|
|
10
|
+
onPress?: (params: ClusterParams) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default class ClusterView extends React.PureComponent<Props> {
|
|
14
|
+
onPress = () => {
|
|
15
|
+
this.props.onPress?.call(this, this.props.cluster);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
renderClusterView = () => {
|
|
19
|
+
const { count } = this.props.cluster;
|
|
20
|
+
const size = 36 + Math.log2(count);
|
|
21
|
+
const clusterStyle = { width: size, height: size, borderRadius: size / 2 };
|
|
22
|
+
return (
|
|
23
|
+
<View style={[style.cluster, clusterStyle, this.props.style]}>
|
|
24
|
+
<Text style={[style.text, this.props.textStyle]}>{count}</Text>
|
|
25
|
+
</View>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
return (
|
|
31
|
+
<Marker onPress={this.onPress} position={this.props.cluster.position}>
|
|
32
|
+
{this.renderClusterView()}
|
|
33
|
+
</Marker>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const style = StyleSheet.create({
|
|
39
|
+
cluster: {
|
|
40
|
+
borderWidth: 4,
|
|
41
|
+
borderColor: "#fff",
|
|
42
|
+
backgroundColor: "rgba(245,83,61,0.9)",
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
justifyContent: "center",
|
|
45
|
+
},
|
|
46
|
+
text: { color: "#fff", fontWeight: "600" },
|
|
47
|
+
});
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ViewStyle } from "react-native";
|
|
3
|
+
import Supercluster, { ClusterFeature, ClusterProperties } from "supercluster";
|
|
4
|
+
import { CameraEvent } from "../map-view";
|
|
5
|
+
import { LatLng } from "../types";
|
|
6
|
+
import ClusterView from "./cluster-view";
|
|
7
|
+
|
|
8
|
+
export interface ClusterParams {
|
|
9
|
+
/**
|
|
10
|
+
* 唯一标识
|
|
11
|
+
*/
|
|
12
|
+
id: number;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 包含的 Marker 数量
|
|
16
|
+
*/
|
|
17
|
+
count: number;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 坐标
|
|
21
|
+
*/
|
|
22
|
+
position: LatLng;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ClusterPoint {
|
|
26
|
+
/**
|
|
27
|
+
* 坐标
|
|
28
|
+
*/
|
|
29
|
+
position: LatLng;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 携带的数据,可以是任意类型
|
|
33
|
+
*/
|
|
34
|
+
properties?: any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface Props {
|
|
38
|
+
/**
|
|
39
|
+
* 聚合半径
|
|
40
|
+
*/
|
|
41
|
+
radius?: number;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 聚合点样式
|
|
45
|
+
*/
|
|
46
|
+
clusterStyle?: ViewStyle;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 聚合点文本样式
|
|
50
|
+
*/
|
|
51
|
+
clusterTextStyle?: ViewStyle;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 坐标点列表
|
|
55
|
+
*/
|
|
56
|
+
points: ClusterPoint[];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 渲染 Marker
|
|
60
|
+
*/
|
|
61
|
+
renderMarker: (item: ClusterPoint) => React.ReactNode;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 渲染聚合点
|
|
65
|
+
*/
|
|
66
|
+
renderCluster?: (params: ClusterParams) => React.ComponentType<any>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 聚合点点击事件
|
|
70
|
+
*/
|
|
71
|
+
onPress?: (params: ClusterParams) => void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface State {
|
|
75
|
+
clusters: ClusterFeature<ClusterProperties>[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default class Cluster extends React.PureComponent<Props, State> {
|
|
79
|
+
static defaultProps = { radius: 200 };
|
|
80
|
+
state: State = { clusters: [] };
|
|
81
|
+
status?: CameraEvent;
|
|
82
|
+
cluster?: Supercluster<any, ClusterProperties>;
|
|
83
|
+
|
|
84
|
+
componentDidMount() {
|
|
85
|
+
this.init();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
componentDidUpdate(props: Props) {
|
|
89
|
+
if (props.points != this.props.points) {
|
|
90
|
+
this.init();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async init() {
|
|
95
|
+
const { radius, points } = this.props;
|
|
96
|
+
// 如果主线程占用太多计算资源,会导致 ios onLoad 事件无法触发,非常蛋疼
|
|
97
|
+
// 暂时想到的解决办法是等一个事件循环
|
|
98
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
99
|
+
const options = { radius, minZoom: 3, maxZoom: 21 };
|
|
100
|
+
this.cluster = new Supercluster<any, ClusterProperties>(options).load(
|
|
101
|
+
points.map((marker) => ({
|
|
102
|
+
type: "Feature",
|
|
103
|
+
geometry: {
|
|
104
|
+
type: "Point",
|
|
105
|
+
coordinates: [marker.position.longitude, marker.position.latitude],
|
|
106
|
+
},
|
|
107
|
+
properties: marker.properties,
|
|
108
|
+
}))
|
|
109
|
+
);
|
|
110
|
+
if (this.status) {
|
|
111
|
+
this.update(this.status);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 需要在 MapView.onCameraIdle({ nativeEvent }) 回调里调用,参数为 nativeEvent
|
|
117
|
+
*/
|
|
118
|
+
async update(status: CameraEvent) {
|
|
119
|
+
this.status = status;
|
|
120
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
121
|
+
const { cameraPosition, latLngBounds } = status;
|
|
122
|
+
const { southwest, northeast } = latLngBounds;
|
|
123
|
+
const clusters = this.cluster!.getClusters(
|
|
124
|
+
[southwest.longitude, southwest.latitude, northeast.longitude, northeast.latitude],
|
|
125
|
+
Math.round(cameraPosition.zoom!)
|
|
126
|
+
);
|
|
127
|
+
this.setState({ clusters });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
renderCluster = (cluster: ClusterParams) => {
|
|
131
|
+
return (
|
|
132
|
+
<ClusterView
|
|
133
|
+
key={cluster.id}
|
|
134
|
+
cluster={cluster}
|
|
135
|
+
onPress={this.props.onPress}
|
|
136
|
+
style={this.props.clusterStyle}
|
|
137
|
+
textStyle={this.props.clusterTextStyle}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
render() {
|
|
143
|
+
const { renderCluster, renderMarker } = this.props;
|
|
144
|
+
const render = renderCluster || this.renderCluster;
|
|
145
|
+
return this.state.clusters.map(({ geometry, properties }) => {
|
|
146
|
+
const position = {
|
|
147
|
+
latitude: geometry.coordinates[1],
|
|
148
|
+
longitude: geometry.coordinates[0],
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
if (properties.point_count > 0) {
|
|
152
|
+
const { cluster_id, point_count } = properties;
|
|
153
|
+
return render({ position, id: cluster_id, count: point_count });
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return renderMarker({ position, properties });
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PureComponent } from "react";
|
|
2
|
+
import { findNodeHandle, UIManager } from "react-native";
|
|
3
|
+
|
|
4
|
+
export default class Component<P, S = {}> extends PureComponent<P, S> {
|
|
5
|
+
/**
|
|
6
|
+
* 原生 View 名称,继承时必须指定
|
|
7
|
+
*/
|
|
8
|
+
name = "";
|
|
9
|
+
mounted = false;
|
|
10
|
+
|
|
11
|
+
componentDidMount() {
|
|
12
|
+
this.mounted = true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
componentWillUnmount() {
|
|
16
|
+
this.mounted = false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 调用原生方法
|
|
21
|
+
*/
|
|
22
|
+
invoke(name: string, params?: any[]) {
|
|
23
|
+
if (!this.mounted) return;
|
|
24
|
+
|
|
25
|
+
const handle = findNodeHandle(this);
|
|
26
|
+
if (handle) {
|
|
27
|
+
const command = UIManager.getViewManagerConfig(this.name).Commands[name];
|
|
28
|
+
UIManager.dispatchViewManagerCommand(handle, command, params);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import AHeatMap ,{HeatMapProps} from './heat-mapNativeComponent'
|
|
3
|
+
import React , {Component} from 'react';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default class HatMap extends Component<HeatMapProps> {
|
|
7
|
+
|
|
8
|
+
constructor(props: HeatMapProps) {
|
|
9
|
+
super(props);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
render() {
|
|
13
|
+
return (
|
|
14
|
+
<AHeatMap {...this.props} />
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
HostComponent,
|
|
4
|
+
ViewProps,
|
|
5
|
+
} from "react-native";
|
|
6
|
+
|
|
7
|
+
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent"
|
|
8
|
+
import { Float } from "react-native/Libraries/Types/CodegenTypes";
|
|
9
|
+
|
|
10
|
+
type LatLng = Readonly<{
|
|
11
|
+
latitude: Float;
|
|
12
|
+
longitude: Float;
|
|
13
|
+
}>
|
|
14
|
+
|
|
15
|
+
export interface HeatMapProps extends ViewProps {
|
|
16
|
+
/**
|
|
17
|
+
* 节点坐标
|
|
18
|
+
*/
|
|
19
|
+
data: LatLng[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 半径(米)
|
|
23
|
+
*/
|
|
24
|
+
radius?: Float;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 透明度
|
|
28
|
+
*/
|
|
29
|
+
opacity?: Float;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export default codegenNativeComponent<HeatMapProps>("AMapHeatMap") as HostComponent<HeatMapProps>;
|
|
34
|
+
|
package/lib/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as Circle } from "./circle";
|
|
2
|
+
export { default as Cluster } from "./cluster";
|
|
3
|
+
export { default as HeatMap } from "./heat-map";
|
|
4
|
+
export { default as MapView } from "./map-view";
|
|
5
|
+
export * from "./map-viewNativeComponent";
|
|
6
|
+
export { default as Marker } from "./marker";
|
|
7
|
+
export { default as MultiPoint } from "./multi-point";
|
|
8
|
+
export { default as Polygon } from "./polygon";
|
|
9
|
+
export { default as Polyline } from "./polyline";
|
|
10
|
+
export * from "./types"
|
|
11
|
+
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
|
|
2
|
+
import AMapView, { Location, MapViewProps, voidEvent } from './map-viewNativeComponent'
|
|
3
|
+
import React, { Component } from 'react';
|
|
4
|
+
import type * as ReactNative from "react-native";
|
|
5
|
+
import {NativeMethods} from "react-native";
|
|
6
|
+
import { LatLng, CameraPosition, LatLngBounds, onCameraEvent, MapPoi, Commands } from './map-viewNativeComponent'
|
|
7
|
+
|
|
8
|
+
export default class MapView extends Component<MapViewProps> {
|
|
9
|
+
constructor(props: MapViewProps) {
|
|
10
|
+
super(props);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
ref: React.ElementRef<typeof AMapView> | null = null;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 移动视角
|
|
17
|
+
*/
|
|
18
|
+
moveCamera(cameraPosition: CameraPosition, duration = 0) {
|
|
19
|
+
console.info("AMapViewEventType map3d demo moveCamera")
|
|
20
|
+
if (this.ref) {
|
|
21
|
+
Commands.moveCamera(
|
|
22
|
+
this.ref,
|
|
23
|
+
cameraPosition,
|
|
24
|
+
duration
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
return (
|
|
31
|
+
<AMapView {...this.props} ref={(ref) => (this.ref = ref)}
|
|
32
|
+
{...this.props}
|
|
33
|
+
onPress={(event: ReactNative.NativeSyntheticEvent<LatLng>) => {
|
|
34
|
+
console.info("AMapViewEventType map3d demo 10.11")
|
|
35
|
+
if (event.nativeEvent.latitude) {
|
|
36
|
+
this.props.onPress?.call(this, event);
|
|
37
|
+
}
|
|
38
|
+
}}
|
|
39
|
+
onLongPress={(event: ReactNative.NativeSyntheticEvent<LatLng>) => {
|
|
40
|
+
console.info("AMapViewEventType map3d demo long event 11.32")
|
|
41
|
+
if (event.nativeEvent.latitude) {
|
|
42
|
+
this.props.onLongPress?.call(this, event);
|
|
43
|
+
}
|
|
44
|
+
}}
|
|
45
|
+
onCameraMove={(event: ReactNative.NativeSyntheticEvent<CameraPosition>) => {
|
|
46
|
+
console.info("AMapViewEventType map3d demo Move start event")
|
|
47
|
+
if (event.nativeEvent.targetValue?.latitude) {
|
|
48
|
+
this.props.onCameraMove?.call(this, event);
|
|
49
|
+
}
|
|
50
|
+
}}
|
|
51
|
+
onCameraIdle={(event: ReactNative.NativeSyntheticEvent<CameraPosition>) => {
|
|
52
|
+
console.info("AMapViewEventType map3d demo Move end event")
|
|
53
|
+
if (event.nativeEvent.targetValue?.latitude) {
|
|
54
|
+
this.props.onCameraIdle?.call(this, event);
|
|
55
|
+
}
|
|
56
|
+
}}
|
|
57
|
+
onPressPoi={(event: ReactNative.NativeSyntheticEvent<MapPoi>) => {
|
|
58
|
+
console.info("AMapViewEventType map3d demo MapPoi")
|
|
59
|
+
if (event.nativeEvent.position.latitude) {
|
|
60
|
+
this.props.onPressPoi?.call(this, event);
|
|
61
|
+
}
|
|
62
|
+
}}
|
|
63
|
+
onLocation={(event: ReactNative.NativeSyntheticEvent<Location>) => {
|
|
64
|
+
console.info("AMapViewEventType map3d demo onLocation")
|
|
65
|
+
this.props.onLocation?.call(this, event);
|
|
66
|
+
}}
|
|
67
|
+
onLoad={(event: ReactNative.NativeSyntheticEvent<voidEvent>) => {
|
|
68
|
+
this.props.onLoad?.call(this, event);
|
|
69
|
+
}}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|