release: 1.0.0+8
This commit is contained in:
parent
908ca8e81e
commit
5ecf421da4
|
@ -1,3 +1,7 @@
|
|||
## 1.0.0+8
|
||||
2023-12-29.
|
||||
* 废弃 `AMapWidget` 中的 `apiKey` / `privacyStatement` 字段,使用 `AMapInitializer` 初始化
|
||||
|
||||
## 1.0.0+7 - 2023-12-26.
|
||||
* github action automate publish support
|
||||
|
||||
|
|
29
README.md
29
README.md
|
@ -20,7 +20,34 @@ flutter pub add amap_map
|
|||
|
||||
|
||||
## Demo
|
||||
``` Dart
|
||||
### 初始化
|
||||
在runApp启动的**第一个**Widget中,使用`context`进行组件初始化
|
||||
|
||||
```dart
|
||||
import 'package:amap_map/amap_map.dart';
|
||||
import 'package:x_amap_base/x_amap_base.dart'; // AMapApiKey 和 AMapPrivacyStatement 定义在 package `x_amap_base` 中,需要一并引入
|
||||
|
||||
class DemoWidget extends State<AMapDemo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AMapInitializer.init(context, ConstConfig.amapApiKeys);
|
||||
|
||||
return Scaffold(
|
||||
// ...
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
### 合规处理
|
||||
高德SDK合规使用方案请参考:https://lbs.amap.com/news/sdkhgsy ,需要进行授权交互,然后通知组件。
|
||||
|
||||
```dart
|
||||
AMapInitializer.updatePrivacyAgree(ConstConfig.amapPrivacyStatement);
|
||||
```
|
||||
|
||||
### 使用地图
|
||||
``` dart
|
||||
import 'package:amap_map_example/base_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'package:amap_map/amap_map.dart';
|
||||
import 'package:amap_map_example/const_config.dart';
|
||||
import 'package:amap_map_example/pages/overlays/marker_add_after_map.dart';
|
||||
import 'package:amap_map_example/pages/overlays/marker_add_with_map.dart';
|
||||
import 'package:amap_map_example/pages/overlays/marker_config.dart';
|
||||
|
@ -75,6 +77,7 @@ class DemoWidget extends State<AMapDemo> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_checkPermissions();
|
||||
}
|
||||
|
||||
|
@ -94,6 +97,8 @@ class DemoWidget extends State<AMapDemo> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AMapInitializer.init(context, ConstConfig.amapApiKeys);
|
||||
AMapInitializer.updatePrivacyAgree(ConstConfig.amapPrivacyStatement);
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('高德地图示例')),
|
||||
body: Container(
|
||||
|
|
|
@ -34,9 +34,9 @@ class _CustomMapStyleState extends State<_CustomMapStyleBody> {
|
|||
_customStyleOptions.styleExtraData =
|
||||
styleExtraByteData.buffer.asUint8List();
|
||||
//如果需要加载完成后直接展示自定义地图,可以通过setState修改CustomStyleOptions的enable为true
|
||||
// setState(() {
|
||||
// _customStyleOptions.enabled = true;
|
||||
// });
|
||||
setState(() {
|
||||
_customStyleOptions.enabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -88,8 +88,8 @@ class _MapUiBodyState extends State<_MapUiBody> {
|
|||
Widget build(BuildContext context) {
|
||||
final AMapWidget map = AMapWidget(
|
||||
///必须正确设置的合规隐私声明,否则SDK不会工作,会造成地图白屏等问题。
|
||||
privacyStatement: ConstConfig.amapPrivacyStatement,
|
||||
apiKey: ConstConfig.amapApiKeys,
|
||||
// privacyStatement: ConstConfig.amapPrivacyStatement,
|
||||
// apiKey: ConstConfig.amapApiKeys,
|
||||
initialCameraPosition: _kInitialPosition,
|
||||
mapType: _mapType,
|
||||
trafficEnabled: _trafficEnabled,
|
||||
|
@ -362,6 +362,7 @@ class _MapUiBodyState extends State<_MapUiBody> {
|
|||
void onMapCreated(AMapController controller) {
|
||||
setState(() {
|
||||
_controller = controller;
|
||||
|
||||
printApprovalNumber();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,5 +15,6 @@ import 'package:flutter/services.dart';
|
|||
|
||||
export 'package:amap_map/src/types/types.dart';
|
||||
|
||||
part 'src/amap_initializer.dart';
|
||||
part 'src/amap_controller.dart';
|
||||
part 'src/amap_widget.dart';
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
part of amap_map;
|
||||
|
||||
class AMapInitializer {
|
||||
static AMapApiKey? _apiKey;
|
||||
static AMapPrivacyStatement? _privacyStatement;
|
||||
|
||||
AMapInitializer._();
|
||||
|
||||
static Future<void> init(BuildContext context, AMapApiKey apiKey) async {
|
||||
AMapUtil.init(context);
|
||||
_apiKey = apiKey;
|
||||
}
|
||||
|
||||
/// 在app首次启动时必须传入高德合规声明配置[privacyStatement],后续如果没有变化不需要重复设置
|
||||
/// <li>[privacyStatement.hasContains] 隐私权政策是否包含高德开平隐私权政策</li>
|
||||
/// <li>[privacyStatement.hasShow] 是否已经弹窗展示给用户</li>
|
||||
/// <li>[privacyStatement.hasAgree] 隐私权政策是否已经取得用户同意</li>
|
||||
/// 以上三个值,任何一个为false都会造成地图插件不工作(白屏情况)
|
||||
///
|
||||
/// 高德SDK合规使用方案请参考:https://lbs.amap.com/news/sdkhgsy
|
||||
///
|
||||
static updatePrivacyAgree(AMapPrivacyStatement privacyStatement) {
|
||||
_privacyStatement = privacyStatement;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ typedef void MapCreatedCallback(AMapController controller);
|
|||
///用于展示高德地图的Widget
|
||||
class AMapWidget extends StatefulWidget {
|
||||
///高德开放平台的key
|
||||
///
|
||||
@Deprecated('高德开放平台的key,请通过AMapInitializer初始化设置,将在1.0.1+移除')
|
||||
final AMapApiKey? apiKey;
|
||||
|
||||
/// 初始化时的地图中心点
|
||||
|
@ -92,11 +92,11 @@ class AMapWidget extends StatefulWidget {
|
|||
///高德合规声明配置
|
||||
///
|
||||
/// 高德SDK合规使用方案请参考:https://lbs.amap.com/news/sdkhgsy
|
||||
@Deprecated('高德开放平台的key,请通过AMapInitializer初始化设置,将在1.0.1+移除')
|
||||
final AMapPrivacyStatement? privacyStatement;
|
||||
|
||||
/// 创建一个展示高德地图的widget
|
||||
///
|
||||
/// 如果使用的高德地图SDK的版本是8.1.0及以上版本,
|
||||
/// 在app首次启动时必须传入高德合规声明配置[privacyStatement],后续如果没有变化不需要重复设置
|
||||
/// <li>[privacyStatement.hasContains] 隐私权政策是否包含高德开平隐私权政策</li>
|
||||
/// <li>[privacyStatement.hasShow] 是否已经弹窗展示给用户</li>
|
||||
|
@ -108,8 +108,9 @@ class AMapWidget extends StatefulWidget {
|
|||
/// [AssertionError] will be thrown if [initialCameraPosition] is null;
|
||||
const AMapWidget({
|
||||
Key? key,
|
||||
@Deprecated('高德开放平台的key,请通过AMapInitializer初始化设置,将在1.0.1+移除')
|
||||
this.privacyStatement,
|
||||
this.apiKey,
|
||||
@Deprecated('高德开放平台的key,请通过AMapInitializer初始化设置,将在1.0.1+移除') this.apiKey,
|
||||
this.initialCameraPosition =
|
||||
const CameraPosition(target: LatLng(39.909187, 116.397451), zoom: 10),
|
||||
this.mapType = MapType.normal,
|
||||
|
@ -155,10 +156,10 @@ class _MapState extends State<AMapWidget> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AMapUtil.init(context);
|
||||
final Map<String, dynamic> creationParams = <String, dynamic>{
|
||||
'privacyStatement': widget.privacyStatement?.toMap(),
|
||||
'apiKey': widget.apiKey?.toMap(),
|
||||
'privacyStatement':
|
||||
widget.privacyStatement?.toMap() ?? AMapInitializer._privacyStatement,
|
||||
'apiKey': widget.apiKey?.toMap() ?? AMapInitializer._apiKey,
|
||||
'initialCameraPosition': widget.initialCameraPosition.toMap(),
|
||||
'options': _mapOptions.toMap(),
|
||||
'markersToAdd': serializeOverlaySet(widget.markers),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: amap_map
|
||||
description: Amap SDK Flutter plugin for integrating AMapSDK in iOS and Android applications.
|
||||
version: 1.0.0+7
|
||||
version: 1.0.0+8
|
||||
homepage: https://github.com/kuloud/amap_map
|
||||
issue_tracker: https://github.com/kuloud/amap_map/issues
|
||||
platforms:
|
||||
|
|
Loading…
Reference in New Issue