@evnydd0sf/react-native-amap3d-fix 3.2.4-fix.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.
Files changed (59) hide show
  1. package/lib/android/build.gradle +34 -0
  2. package/lib/android/src/main/AndroidManifest.xml +10 -0
  3. package/lib/android/src/main/java/qiuxiang/amap3d/AMap3DPackage.kt +28 -0
  4. package/lib/android/src/main/java/qiuxiang/amap3d/Utils.kt +114 -0
  5. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/Circle.kt +65 -0
  6. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/CircleManager.kt +49 -0
  7. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/HeatMap.kt +32 -0
  8. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/HeatMapManager.kt +33 -0
  9. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/MapView.kt +174 -0
  10. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/MapViewManager.kt +153 -0
  11. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/Marker.kt +102 -0
  12. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/MarkerManager.kt +78 -0
  13. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/MultiPoint.kt +53 -0
  14. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/MultiPointManager.kt +33 -0
  15. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/Overlay.kt +8 -0
  16. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/Polygon.kt +58 -0
  17. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/PolygonManager.kt +44 -0
  18. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/Polyline.kt +69 -0
  19. package/lib/android/src/main/java/qiuxiang/amap3d/map_view/PolylineManager.kt +64 -0
  20. package/lib/android/src/main/java/qiuxiang/amap3d/modules/SdkModule.kt +31 -0
  21. package/lib/ios/.swiftformat +2 -0
  22. package/lib/ios/Bridging-Header.h +4 -0
  23. package/lib/ios/MapView/CircleManager.m +11 -0
  24. package/lib/ios/MapView/CircleManager.swift +30 -0
  25. package/lib/ios/MapView/HeatMapManager.m +9 -0
  26. package/lib/ios/MapView/HeatMapManager.swift +29 -0
  27. package/lib/ios/MapView/MapViewManager.m +35 -0
  28. package/lib/ios/MapView/MapViewManager.swift +159 -0
  29. package/lib/ios/MapView/MarkerManager.m +18 -0
  30. package/lib/ios/MapView/MarkerManager.swift +100 -0
  31. package/lib/ios/MapView/MultiPointManager.m +9 -0
  32. package/lib/ios/MapView/MultiPointManager.swift +47 -0
  33. package/lib/ios/MapView/Overlay.swift +4 -0
  34. package/lib/ios/MapView/PolygonManager.m +10 -0
  35. package/lib/ios/MapView/PolygonManager.swift +30 -0
  36. package/lib/ios/MapView/PolylineManager.m +12 -0
  37. package/lib/ios/MapView/PolylineManager.swift +41 -0
  38. package/lib/ios/Modules/SdkModule.m +8 -0
  39. package/lib/ios/Modules/SdkModule.swift +16 -0
  40. package/lib/ios/Utils.swift +104 -0
  41. package/lib/ios/react-native-amap3d.podspec +20 -0
  42. package/lib/src/circle.tsx +36 -0
  43. package/lib/src/cluster/cluster-view.tsx +47 -0
  44. package/lib/src/cluster/index.tsx +159 -0
  45. package/lib/src/component.ts +31 -0
  46. package/lib/src/heat-map.tsx +21 -0
  47. package/lib/src/index.ts +11 -0
  48. package/lib/src/map-view.tsx +230 -0
  49. package/lib/src/marker.tsx +128 -0
  50. package/lib/src/multi-point.tsx +28 -0
  51. package/lib/src/polygon.tsx +31 -0
  52. package/lib/src/polyline.tsx +65 -0
  53. package/lib/src/sdk.ts +11 -0
  54. package/lib/src/types.ts +137 -0
  55. package/license +21 -0
  56. package/package.json +56 -0
  57. package/react-native-amap3d.podspec +20 -0
  58. package/react-native.config.js +20 -0
  59. package/readme.md +186 -0
package/lib/src/sdk.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { NativeModules } from "react-native";
2
+
3
+ const { AMapSdk } = NativeModules;
4
+
5
+ export function init(apiKey?: string) {
6
+ AMapSdk.initSDK(apiKey);
7
+ }
8
+
9
+ export function getVersion(): Promise<string> {
10
+ return AMapSdk.getVersion();
11
+ }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * 点坐标
3
+ */
4
+ export interface Point {
5
+ x: number;
6
+ y: number;
7
+ }
8
+
9
+ /**
10
+ * 地理坐标
11
+ */
12
+ export interface LatLng {
13
+ /**
14
+ * 纬度
15
+ */
16
+ latitude: number;
17
+
18
+ /**
19
+ * 经度
20
+ */
21
+ longitude: number;
22
+ }
23
+
24
+ /**
25
+ * 地图标注点
26
+ */
27
+ export interface MapPoi {
28
+ /**
29
+ * 标注点 ID
30
+ */
31
+ id: string;
32
+
33
+ /**
34
+ * 标注点名称
35
+ */
36
+ name: string;
37
+
38
+ /**
39
+ * 标注点坐标
40
+ */
41
+ position: LatLng;
42
+ }
43
+
44
+ /**
45
+ * 矩形坐标边界
46
+ */
47
+ export interface LatLngBounds {
48
+ /**
49
+ * 西南坐标
50
+ */
51
+ southwest: LatLng;
52
+
53
+ /**
54
+ * 东北坐标
55
+ */
56
+ northeast: LatLng;
57
+ }
58
+
59
+ /**
60
+ * 地图状态
61
+ */
62
+ export interface CameraPosition {
63
+ /**
64
+ * 中心坐标
65
+ */
66
+ target?: LatLng;
67
+
68
+ /**
69
+ * 缩放级别
70
+ */
71
+ zoom?: number;
72
+
73
+ /**
74
+ * 朝向、旋转角度
75
+ */
76
+ bearing?: number;
77
+
78
+ /**
79
+ * 倾斜角度
80
+ */
81
+ tilt?: number;
82
+ }
83
+
84
+ /**
85
+ * 定位
86
+ */
87
+ export interface Location extends LatLng {
88
+ /**
89
+ * 精度
90
+ */
91
+ accuracy: number;
92
+
93
+ /**
94
+ * 朝向
95
+ */
96
+ heading: number;
97
+
98
+ /**
99
+ * 海拔
100
+ */
101
+ altitude: number;
102
+
103
+ /**
104
+ * 运动速度
105
+ */
106
+ speed: number;
107
+ }
108
+
109
+ /**
110
+ * 地图类型
111
+ */
112
+ export enum MapType {
113
+ /**
114
+ * 标准地图
115
+ */
116
+ Standard,
117
+
118
+ /**
119
+ * 卫星地图
120
+ */
121
+ Satellite,
122
+
123
+ /**
124
+ * 夜间地图
125
+ */
126
+ Night,
127
+
128
+ /**
129
+ * 导航地图
130
+ */
131
+ Navi,
132
+
133
+ /**
134
+ * 公交地图
135
+ */
136
+ Bus,
137
+ }
package/license ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 7c00 <i@7c00.cc>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@evnydd0sf/react-native-amap3d-fix",
3
+ "version": "3.2.4-fix.1",
4
+ "description": "react-native 高德地图组件,支持 Android + iOS (Fork with compilation fix)",
5
+ "author": "evnydd0sf <me@evnydd0sf.club>",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "react-native",
9
+ "amap",
10
+ "maps",
11
+ "mapview"
12
+ ],
13
+ "main": "lib/src",
14
+ "files": [
15
+ "lib/src",
16
+ "lib/android/src",
17
+ "lib/android/build.gradle",
18
+ "lib/ios",
19
+ "react-native.config.js",
20
+ "react-native-amap3d.podspec"
21
+ ],
22
+ "homepage": "https://github.com/evnydd0sf/react-native-amap3d",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/evnydd0sf/react-native-amap3d"
26
+ },
27
+ "original": {
28
+ "name": "react-native-amap3d",
29
+ "author": "7c00 <i@7c00.cc>",
30
+ "repository": "https://github.com/qiuxiang/react-native-amap3d"
31
+ },
32
+ "scripts": {
33
+ "start": "react-native start",
34
+ "android": "react-native run-android",
35
+ "release-android": "react-native run-android --variant=release",
36
+ "reload": "adb reverse tcp:8081 tcp:8081 && adb shell input text rr",
37
+ "ios": "react-native run-ios"
38
+ },
39
+ "dependencies": {
40
+ "supercluster": "^7.1.4"
41
+ },
42
+ "devDependencies": {
43
+ "@react-native-picker/picker": "^2.4.8",
44
+ "@react-navigation/native": "^6.1.3",
45
+ "@react-navigation/native-stack": "^6.9.9",
46
+ "@types/react-native": "^0.71.2",
47
+ "@types/supercluster": "^7.1.0",
48
+ "react": "18.2.0",
49
+ "react-native": "^0.71.2",
50
+ "react-native-safe-area-context": "^4.5.0",
51
+ "react-native-screens": "^3.19.0"
52
+ },
53
+ "prettier": {
54
+ "printWidth": 100
55
+ }
56
+ }
@@ -0,0 +1,20 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "react-native-amap3d"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => "10.0" }
14
+ s.source = { :git => "https://github.com/evnydd0sf/react-native-amap3d.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "lib/ios/**/*.{h,m,mm,swift}"
17
+
18
+ s.dependency "React-Core"
19
+ s.dependency 'AMap3DMap', "10.0.1000"
20
+ end
@@ -0,0 +1,20 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ ios: { project: "lib/ios/react-native-amap3d.podspec" },
5
+ android: { sourceDir: "lib/android" },
6
+ },
7
+ },
8
+ dependencies: {
9
+ "react-native-amap3d": {
10
+ root: __dirname,
11
+ platforms: {
12
+ android: {
13
+ sourceDir: __dirname + "/lib/android",
14
+ packageImportPath: "import qiuxiang.amap3d.AMap3DPackage;",
15
+ packageInstance: "new AMap3DPackage()",
16
+ },
17
+ },
18
+ },
19
+ },
20
+ };
package/readme.md ADDED
@@ -0,0 +1,186 @@
1
+ # react-native-amap3d [![][version-badge]][npm] [![](https://github.com/evnydd0sf/react-native-amap3d/actions/workflows/build.yml/badge.svg)](https://github.com/evnydd0sf/react-native-amap3d/actions/workflows/build.yml)
2
+
3
+ > 这是 [react-native-amap3d](https://github.com/qiuxiang/react-native-amap3d) 的 fork 版本,仅为 react-native-amap3d 修复 Xcode 编译问题而创建。
4
+
5
+ ## 修复内容
6
+
7
+ - **修复了 iOS 编译时的链接错误问题**
8
+ - **问题描述**:在正式编译时出现 `ld: pointer not aligned in '_dbl_lnds_data_TileDataRespMsg_fields'` 错误
9
+ - **根本原因**:AMap3DMap SDK 版本兼容性问题,原 podspec 中的版本依赖导致链接器错误
10
+ - **解决方案**:将 `react-native-amap3d.podspec` 中的 AMap3DMap 依赖版本固定为 `10.0.1000`
11
+ - **测试状态**:✅ 开发调试正常 ✅ 正式编译通过
12
+
13
+ ## 功能
14
+
15
+ - 地图模式切换(常规、卫星、导航、夜间)
16
+ - 3D 建筑、路况、室内地图
17
+ - 内置地图控件的显示隐藏(指南针、比例尺、定位按钮、缩放按钮)
18
+ - 手势交互控制(平移、缩放、旋转、倾斜)
19
+ - 中心坐标、缩放级别、倾斜度的设置,支持动画过渡
20
+ - 地图事件(onPress、onLongPress、onLocation、onCameraMove、onCameraIdle 等)
21
+ - 地图标记(Marker)
22
+ - 折线绘制(Polyline)
23
+ - 多边形绘制(Polygon)
24
+ - 圆形绘制(Circle)
25
+ - 热力图(HeatMap)
26
+ - 海量点(MultiPoint)
27
+ - 点聚合(Cluster)
28
+
29
+ ## 接口文档
30
+
31
+ <https://qiuxiang.github.io/react-native-amap3d/api/>
32
+
33
+ ## 安装
34
+
35
+ ```bash
36
+ npm i @evnydd0sf/react-native-amap3d
37
+ ```
38
+
39
+ ### 添加高德 API Key
40
+
41
+ 首先你需要获取高德地图 API Key:
42
+
43
+ - [Aandroid](http://lbs.amap.com/api/android-sdk/guide/create-project/get-key)
44
+ - [iOS](https://lbs.amap.com/api/ios-sdk/guide/create-project/get-key)
45
+
46
+ 然后你需要在显示地图前调用接口设置 API key:
47
+
48
+ ```js
49
+ import { AMapSdk } from "@evnydd0sf/react-native-amap3d";
50
+ import { Platform } from "react-native";
51
+
52
+ AMapSdk.init(
53
+ Platform.select({
54
+ android: "c52c7169e6df23490e3114330098aaac",
55
+ ios: "186d3464209b74effa4d8391f441f14d",
56
+ })
57
+ );
58
+ ```
59
+
60
+ ## 用法
61
+
62
+ ### 显示地图
63
+
64
+ ```jsx
65
+ import { MapView, MapType } from "@evnydd0sf/react-native-amap3d";
66
+
67
+ <MapView
68
+ mapType={MapType.Satellite}
69
+ initialCameraPosition={{
70
+ target: {
71
+ latitude: 39.91095,
72
+ longitude: 116.37296,
73
+ },
74
+ zoom: 8,
75
+ }}
76
+ />;
77
+ ```
78
+
79
+ <img src=<https://user-images.githubusercontent.com/1709072/140698774-bdbfee64-d403-4e49-9a85-716d44783cfd.png> height=500> <img src=<https://user-images.githubusercontent.com/1709072/140849895-dada3f51-74c0-4685-b5d6-c1b69a4d06bb.PNG> height=500>
80
+
81
+ ### 监听地图事件
82
+
83
+ ```jsx
84
+ import { MapView } from "@evnydd0sf/react-native-amap3d";
85
+
86
+ <MapView
87
+ onLoad={() => console.log("onLoad")}
88
+ onPress={({ nativeEvent }) => console.log(nativeEvent)}
89
+ onCameraIdle={({ nativeEvent }) => console.log(nativeEvent)}
90
+ />;
91
+ ```
92
+
93
+ <img src=<https://user-images.githubusercontent.com/1709072/140705501-9ed3e038-e52a-48c2-a98a-235c5c890549.png> height=500> <img src=<https://user-images.githubusercontent.com/1709072/140849894-3add3858-fc7f-47cd-9786-94aeef399ebc.PNG> height=500>
94
+
95
+ ### 添加标记
96
+
97
+ 其中 `icon` 支持 [ImageSource](https://reactnative.dev/docs/image#imagesource)。
98
+
99
+ 同时支持 `children` 作为标记图标。
100
+
101
+ ```jsx
102
+ import { MapView, Marker } from "@evnydd0sf/react-native-amap3d";
103
+
104
+ <MapView>
105
+ <Marker
106
+ position={{ latitude: 39.806901, longitude: 116.397972 }}
107
+ icon={require("../images/flag.png")}
108
+ onPress={() => alert("onPress")}
109
+ />
110
+ <Marker
111
+ position={{ latitude: 39.806901, longitude: 116.297972 }}
112
+ icon={{
113
+ uri: "https://reactnative.dev/img/pwa/manifest-icon-512.png",
114
+ width: 64,
115
+ height: 64,
116
+ }}
117
+ />
118
+ <Marker position={{ latitude: 39.906901, longitude: 116.397972 }}>
119
+ <Text
120
+ style={{
121
+ color: "#fff",
122
+ backgroundColor: "#009688",
123
+ alignItems: "center",
124
+ borderRadius: 5,
125
+ padding: 5,
126
+ }}
127
+ >
128
+ {new Date().toLocaleString()}
129
+ </Text>
130
+ </Marker>
131
+ </MapView>;
132
+ ```
133
+
134
+ <img src=<https://user-images.githubusercontent.com/1709072/140707579-4abe070a-3fc1-481d-8a2e-91ac2ad8bdc7.png> height=500> <img src=<https://user-images.githubusercontent.com/1709072/140849886-7eb9322b-8fa8-4049-a7b0-3eb36d006992.PNG> height=500>
135
+
136
+ ### 点聚合
137
+
138
+ Marker 数量过多(尤其是使用自定义 View 的情况下)会导致性能问题,而且显示过于密集,这时候可以用点聚合改善。
139
+
140
+ ```jsx
141
+ import { Cluster, MapView, Marker } from "@evnydd0sf/react-native-amap3d";
142
+
143
+ const markers = Array(1000)
144
+ .fill(0)
145
+ .map((_, i) => ({
146
+ position: { latitude: 39.5 + Math.random(), longitude: 116 + Math.random() },
147
+ properties: { key: `Marker${i}` },
148
+ }));
149
+
150
+ <MapView
151
+ ref={(ref) => (this.mapView = ref)}
152
+ onLoad={() => this.mapView?.moveCamera({ zoom: 8 }, 100)}
153
+ onCameraIdle={({ nativeEvent }) => {
154
+ this.status = nativeEvent;
155
+ this.cluster?.update(nativeEvent);
156
+ }}
157
+ >
158
+ <Cluster
159
+ ref={(ref) => (this.cluster = ref)}
160
+ points={markers}
161
+ renderMarker={(item) => (
162
+ <Marker
163
+ key={item.properties.key}
164
+ icon={require("../images/flag.png")}
165
+ position={item.position}
166
+ />
167
+ )}
168
+ />
169
+ </MapView>;
170
+ ```
171
+
172
+ <img src=<https://user-images.githubusercontent.com/1709072/140710764-40f767cd-74fd-47ca-8310-897bbf58fbbd.png> height=500> <img src=<https://user-images.githubusercontent.com/1709072/140849888-6b6609c1-2e55-41c2-bdc3-f9d3fcc7a112.PNG> height=500>
173
+
174
+ <img src=<https://user-images.githubusercontent.com/1709072/140710758-63e81ade-2635-4412-a5fa-b6948605fe75.png> height=500> <img src=<https://user-images.githubusercontent.com/1709072/140849880-9eb7609d-55a7-43be-8b6a-bac725fb0a82.PNG> height=500>
175
+
176
+ ### 更多示例
177
+
178
+ 参考 [example](https://github.com/evnydd0sf/react-native-amap3d/tree/master/example-app)。
179
+
180
+ ## 常见问题
181
+
182
+ - 尽量使用真实设备进行测试,在模拟器可能存在一些问题(常见的是 Android 模拟器因为缺少 GPU 加速而导致闪退)。
183
+ - onLocation 没有返回定位数据通常是因为 key 不正确,或没有申请 PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION 权限
184
+
185
+ [npm]: https://www.npmjs.com/package/react-native-amap3d
186
+ [version-badge]: https://img.shields.io/npm/v/react-native-amap3d.svg