更换高德地图插件为官方插件

hmxc
张萌 4 years ago
parent 8b6a407d95
commit 54789087be

@ -42,10 +42,14 @@ android {
} }
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). //Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.akucommunity.aku_community_manager" applicationId "com.akucommunity.aku_community_manager"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
ndk {
abiFilters 'arm64-v8a'
abiFilters 'armeabi-v7a'
}
manifestPlaceholders = [ manifestPlaceholders = [
JPUSH_PKGNAME : applicationId, JPUSH_PKGNAME : applicationId,
JPUSH_APPKEY : "99067fe33fa04aad88c3acac", //appkey. JPUSH_APPKEY : "99067fe33fa04aad88c3acac", //appkey.
@ -82,4 +86,6 @@ flutter {
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.amap.api:3dmap:latest.integration'
implementation 'com.amap.api:location:latest.integration'
} }

@ -5,7 +5,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
import 'package:amap_map_fluttify/amap_map_fluttify.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -22,8 +21,8 @@ import 'package:aku_community_manager/ui/splash/splash_page.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await AmapCore.init(''); // await AmapCore.init('');
await AmapLocation.instance.init(iosKey: ''); // await AmapLocation.instance.init(iosKey: '');
JPush jpush = new JPush(); JPush jpush = new JPush();
DevUtil.setDev(true); DevUtil.setDev(true);
jpush.addEventHandler( jpush.addEventHandler(

@ -1,4 +1,6 @@
// Flutter imports: // Flutter imports:
import 'package:amap_flutter_location/amap_flutter_location.dart';
import 'package:amap_flutter_location/amap_location_option.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Project imports: // Project imports:
@ -26,4 +28,26 @@ class AppProvider extends ChangeNotifier {
_recentUsedApp.clear(); _recentUsedApp.clear();
notifyListeners(); notifyListeners();
} }
Map<String, Object> _location;
Map<String, Object> get location => _location;
AMapFlutterLocation _flutterLocation;
startLocation() {
_flutterLocation = AMapFlutterLocation();
_flutterLocation.onLocationChanged().listen((event) {
_location = event;
if (_location != null) {
stopLocation();
}
});
_flutterLocation.setLocationOption(
AMapLocationOption(onceLocation: true, needAddress: true));
_flutterLocation.startLocation();
}
stopLocation() {
_flutterLocation.stopLocation();
_flutterLocation.destroy();
}
} }

@ -1,6 +1,5 @@
import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
import 'package:amap_map_fluttify/amap_map_fluttify.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart'; import 'package:qr_code_scanner/qr_code_scanner.dart';

@ -1,6 +1,7 @@
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/manager/item_num_model.dart'; import 'package:aku_community_manager/models/manager/item_num_model.dart';
import 'package:aku_community_manager/provider/app_provider.dart';
import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/provider/user_provider.dart';
import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/utils/dev_util.dart'; import 'package:aku_community_manager/utils/dev_util.dart';
@ -9,11 +10,11 @@ import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
import 'package:amap_map_fluttify/amap_map_fluttify.dart';
import 'package:get/get.dart' hide Response; import 'package:get/get.dart' hide Response;
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart'; import 'package:hive_flutter/hive_flutter.dart';
import 'package:jpush_flutter/jpush_flutter.dart'; import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:power_logger/power_logger.dart'; import 'package:power_logger/power_logger.dart';
// Project imports: // Project imports:
@ -39,7 +40,14 @@ class _SplashPageState extends State<SplashPage> {
} }
//AMap //AMap
await AmapLocation.instance.init(iosKey: 'ios key'); // await AmapLocation.instance.init(iosKey: 'ios key');
await Permission.locationWhenInUse.request();
}
Future _initOp() async {
await _originOp();
final appProvider = Provider.of<AppProvider>(context, listen: false);
appProvider.startLocation();
} }
@override @override
@ -49,7 +57,7 @@ class _SplashPageState extends State<SplashPage> {
if (mounted) PowerLogger.start(context, debug: DevUtil.isDev); if (mounted) PowerLogger.start(context, debug: DevUtil.isDev);
}); });
Future.delayed(Duration(milliseconds: 2000), () async { Future.delayed(Duration(milliseconds: 2000), () async {
await _originOp(); await _initOp();
Get.off(HomePage()); Get.off(HomePage());
}); });
} }

@ -1,22 +1,30 @@
// Flutter imports: // Flutter imports:
import 'dart:ui'; import 'dart:ui';
import 'package:aku_community_manager/provider/app_provider.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
import 'package:aku_ui/common_widgets/aku_cupertino_button.dart'; import 'package:aku_ui/common_widgets/aku_cupertino_button.dart';
import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart';
import 'package:amap_map_fluttify/amap_map_fluttify.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
// Project imports: // Project imports:
import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/tools/permission_tool.dart';
import 'package:aku_community_manager/tools/widget_tool.dart'; import 'package:aku_community_manager/tools/widget_tool.dart';
import 'package:aku_community_manager/ui/tool_pages/warning/warning_detail_page.dart'; import 'package:aku_community_manager/ui/tool_pages/warning/warning_detail_page.dart';
import 'package:aku_community_manager/ui/tool_pages/warning/warning_sub_page.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:amap_flutter_base/amap_flutter_base.dart';
import 'package:amap_flutter_map/amap_flutter_map.dart';
class PermissonUtil {
static Future getLocationPermisson() async {
return await Permission.locationWhenInUse.request().isGranted;
}
}
class WarningPage extends StatefulWidget { class WarningPage extends StatefulWidget {
WarningPage({Key key}) : super(key: key); WarningPage({Key key}) : super(key: key);
@ -26,11 +34,22 @@ class WarningPage extends StatefulWidget {
} }
class _WarningPageState extends State<WarningPage> { class _WarningPageState extends State<WarningPage> {
AmapController _amapController; AMapController _mapController;
Location _location; @override
void initState() {
super.initState();
PermissonUtil.getLocationPermisson();
}
@override
void dispose() {
_mapController?.disponse();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appProvider = Provider.of<AppProvider>(context, listen: false);
return AkuScaffold( return AkuScaffold(
title: '一键报警', title: '一键报警',
actions: [ actions: [
@ -50,16 +69,24 @@ class _WarningPageState extends State<WarningPage> {
], ],
body: Stack( body: Stack(
children: [ children: [
AmapView( AMapWidget(
zoomLevel: 15, onMapCreated: (controller) {
showZoomControl: false, LatLng _target = LatLng(
showCompass: false, appProvider.location['latitude'],
showScaleControl: false, appProvider.location['longitude'],
onMapCreated: (controller) async { );
_amapController = controller;
_amapController.showMyLocation(MyLocationOption()); _mapController = controller;
_getLocation(); _mapController.moveCamera(
CameraUpdate.newCameraPosition(
CameraPosition(target: _target, zoom: 18),
),
);
}, },
myLocationStyleOptions: MyLocationStyleOptions(true,
circleFillColor:
Theme.of(context).primaryColor.withOpacity(0.2),
circleStrokeColor: Theme.of(context).primaryColor),
), ),
/// ///
@ -99,7 +126,9 @@ class _WarningPageState extends State<WarningPage> {
AkuBox.w(10), AkuBox.w(10),
Expanded( Expanded(
child: Text( child: Text(
_location?.address ?? '加载中', (appProvider.location == null)
? '加载中……'
: appProvider.location['address'],
style: TextStyle( style: TextStyle(
color: AppStyle.minorTextColor, color: AppStyle.minorTextColor,
fontSize: 28.sp, fontSize: 28.sp,
@ -210,7 +239,15 @@ class _WarningPageState extends State<WarningPage> {
child: AkuCupertinoButton( child: AkuCupertinoButton(
minWidth: 0, minWidth: 0,
onPressed: () { onPressed: () {
_getLocation(); LatLng _target = LatLng(
appProvider.location['latitude'],
appProvider.location['longitude'],
);
_mapController.moveCamera(
CameraUpdate.newCameraPosition(
CameraPosition(target: _target, zoom: 18),
),
);
}, },
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
@ -241,17 +278,17 @@ class _WarningPageState extends State<WarningPage> {
); );
} }
_getLocation() { // _getLocation() {
_location = null; // _location = null;
setState(() {}); // setState(() {});
PermissionTool.getLocationPermission().then((state) { // PermissionTool.getLocationPermission().then((state) {
if (state) { // if (state) {
AmapLocation.instance.fetchLocation().then((location) { // AmapLocation.instance.fetchLocation().then((location) {
_amapController.setCenterCoordinate(location.latLng); // _amapController.setCenterCoordinate(location.latLng);
_location = location; // _location = location;
setState(() {}); // setState(() {});
}); // });
} // }
}); // });
} // }
} }

@ -17,34 +17,29 @@ packages:
url: "http://test.akuhotel.com:8099/aku_fe/aku_ui.git" url: "http://test.akuhotel.com:8099/aku_fe/aku_ui.git"
source: git source: git
version: "0.0.1" version: "0.0.1"
amap_core_fluttify: amap_flutter_base:
dependency: transitive dependency: "direct main"
description:
name: amap_core_fluttify
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.0"
amap_location_fluttify:
dependency: transitive
description: description:
name: amap_location_fluttify name: amap_flutter_base
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.18.0" version: "1.0.2"
amap_map_fluttify: amap_flutter_location:
dependency: "direct main" dependency: "direct main"
description: description:
name: amap_map_fluttify name: amap_flutter_location
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.29.0" version: "1.0.1"
amap_search_fluttify: amap_flutter_map:
dependency: transitive dependency: "direct main"
description: description:
name: amap_search_fluttify path: "."
url: "https://pub.flutter-io.cn" ref: nullsafety
source: hosted resolved-ref: "5c50cf60d2157cc2779a171ca65c327d571389a7"
version: "0.14.0" url: "http://159.75.73.143:8080/third_packages/amap_flutter_map"
source: git
version: "2.0.2-nullsafety"
analyzer: analyzer:
dependency: transitive dependency: transitive
description: description:
@ -164,13 +159,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.0" version: "3.0.0"
core_location_fluttify:
dependency: transitive
description:
name: core_location_fluttify
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.1"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@ -324,13 +312,6 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
foundation_fluttify:
dependency: transitive
description:
name: foundation_fluttify
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.9.10+1"
get: get:
dependency: "direct main" dependency: "direct main"
description: description:
@ -528,21 +509,7 @@ packages:
name: path_provider name: path_provider
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.6.9" version: "1.2.0"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.4+8"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.4"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
@ -556,14 +523,14 @@ packages:
name: permission_handler name: permission_handler
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.0.1+1" version: "6.1.1"
permission_handler_platform_interface: permission_handler_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: permission_handler_platform_interface name: permission_handler_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.1" version: "3.1.2"
pin_input_text_field: pin_input_text_field:
dependency: "direct main" dependency: "direct main"
description: description:
@ -584,7 +551,7 @@ packages:
name: plugin_platform_interface name: plugin_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.3" version: "2.0.0"
power_logger: power_logger:
dependency: "direct main" dependency: "direct main"
description: description:
@ -660,6 +627,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
stream_transform:
dependency: transitive
description:
name: stream_transform
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
@ -694,42 +668,42 @@ packages:
name: url_launcher name: url_launcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.7.10" version: "6.0.3"
url_launcher_linux: url_launcher_linux:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_linux name: url_launcher_linux
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.1+4" version: "2.0.0"
url_launcher_macos: url_launcher_macos:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_macos name: url_launcher_macos
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.1+9" version: "2.0.0"
url_launcher_platform_interface: url_launcher_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_platform_interface name: url_launcher_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.9" version: "2.0.2"
url_launcher_web: url_launcher_web:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_web name: url_launcher_web
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.1.5+1" version: "2.0.0"
url_launcher_windows: url_launcher_windows:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_windows name: url_launcher_windows
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.1+3" version: "2.0.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:

@ -41,11 +41,14 @@ dependencies:
expandable: ^5.0.1 expandable: ^5.0.1
url_launcher: ^5.7.10 url_launcher: ^6.0.3
amap_flutter_map:
amap_map_fluttify: ^0.29.0 git:
url: http://159.75.73.143:8080/third_packages/amap_flutter_map
permission_handler: ^5.0.1+1 ref: nullsafety
amap_flutter_location: ^1.0.1
amap_flutter_base: ^1.0.2
permission_handler: ^6.1.1
velocity_x: ^2.6.0 velocity_x: ^2.6.0
dotted_border: ^2.0.0-nullsafety.0 dotted_border: ^2.0.0-nullsafety.0

Loading…
Cancel
Save