expo-gaode-map 2.2.14 → 2.2.15
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.
|
@@ -42,7 +42,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
42
42
|
|
|
43
43
|
if (!apiKey.isNullOrEmpty()) {
|
|
44
44
|
try {
|
|
45
|
-
|
|
45
|
+
MapsInitializer.setApiKey(apiKey)
|
|
46
46
|
com.amap.api.location.AMapLocationClient.setApiKey(apiKey)
|
|
47
47
|
android.util.Log.d("ExpoGaodeMap", "✅ 从 AndroidManifest.xml 读取并设置 API Key 成功")
|
|
48
48
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-gaode-map",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.15",
|
|
4
4
|
"description": "A full-featured AMap (Gaode Map) React Native component library built with Expo Modules, providing map display, location services, overlays, and more.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -4,9 +4,9 @@ import { ConfigPlugin } from '@expo/config-plugins';
|
|
|
4
4
|
*/
|
|
5
5
|
export type GaodeMapPluginProps = {
|
|
6
6
|
/** iOS 平台 API Key */
|
|
7
|
-
|
|
7
|
+
iosKey?: string;
|
|
8
8
|
/** Android 平台 API Key */
|
|
9
|
-
|
|
9
|
+
androidKey?: string;
|
|
10
10
|
/** 是否启用定位功能 */
|
|
11
11
|
enableLocation?: boolean;
|
|
12
12
|
/** iOS 定位权限描述 */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
4
|
-
const pkg = require('
|
|
4
|
+
const pkg = require('../../package.json');
|
|
5
5
|
/** 默认定位权限描述 */
|
|
6
6
|
const DEFAULT_LOCATION_USAGE = '需要访问您的位置信息以提供地图服务';
|
|
7
7
|
/**
|
|
@@ -35,8 +35,8 @@ const withGaodeMapIOSPermissions = (config, props) => {
|
|
|
35
35
|
const withGaodeMapInfoPlist = (config, props) => {
|
|
36
36
|
return (0, config_plugins_1.withInfoPlist)(config, (config) => {
|
|
37
37
|
// 添加高德地图 API Key
|
|
38
|
-
if (props.
|
|
39
|
-
config.modResults.AMapApiKey = props.
|
|
38
|
+
if (props.iosKey) {
|
|
39
|
+
config.modResults.AMapApiKey = props.iosKey;
|
|
40
40
|
}
|
|
41
41
|
// 添加后台定位模式(如果启用)
|
|
42
42
|
if (props.enableBackgroundLocation) {
|
|
@@ -117,7 +117,7 @@ const withGaodeMapAndroidManifest = (config, props) => {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
// 添加 API Key 到 application 标签
|
|
120
|
-
if (mainApplication && props.
|
|
120
|
+
if (mainApplication && props.androidKey) {
|
|
121
121
|
if (!mainApplication['meta-data']) {
|
|
122
122
|
mainApplication['meta-data'] = [];
|
|
123
123
|
}
|
|
@@ -127,7 +127,7 @@ const withGaodeMapAndroidManifest = (config, props) => {
|
|
|
127
127
|
mainApplication['meta-data'].push({
|
|
128
128
|
$: {
|
|
129
129
|
'android:name': 'com.amap.api.v2.apikey',
|
|
130
|
-
'android:value': props.
|
|
130
|
+
'android:value': props.androidKey,
|
|
131
131
|
},
|
|
132
132
|
});
|
|
133
133
|
}
|
|
@@ -137,7 +137,7 @@ const withGaodeMapAndroidManifest = (config, props) => {
|
|
|
137
137
|
if (apiKeyIndex !== -1) {
|
|
138
138
|
mainApplication['meta-data'][apiKeyIndex].$ = {
|
|
139
139
|
'android:name': 'com.amap.api.v2.apikey',
|
|
140
|
-
'android:value': props.
|
|
140
|
+
'android:value': props.androidKey,
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -160,8 +160,8 @@ const withGaodeMapAppBuildGradle = (config, props) => {
|
|
|
160
160
|
*/
|
|
161
161
|
const withGaodeMap = (config, props = {}) => {
|
|
162
162
|
// 验证配置
|
|
163
|
-
if (!props.
|
|
164
|
-
config_plugins_1.WarningAggregator.addWarningIOS('expo-gaode-map', '未配置 API Key。请在 app.json 的 plugins 中配置
|
|
163
|
+
if (!props.iosKey && !props.androidKey) {
|
|
164
|
+
config_plugins_1.WarningAggregator.addWarningIOS('expo-gaode-map', '未配置 API Key。请在 app.json 的 plugins 中配置 iosKey 和 androidKey');
|
|
165
165
|
}
|
|
166
166
|
// 应用 iOS 配置
|
|
167
167
|
config = withGaodeMapIOSPermissions(config, props); // 使用 IOSConfig 添加权限
|