diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 0d3a1a5..620d289 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -1,11 +1,11 @@ import 'package:amap_flutter_map/amap_flutter_map.dart'; +import 'package:autosos_flutter/config/theme_colors.dart'; import 'package:autosos_flutter/const_config.dart'; import 'package:autosos_flutter/pages/home/widgets/image_block.dart'; +import 'package:autosos_flutter/pages/home/widgets/map_widget.dart'; import 'package:autosos_flutter/pages/home/widgets/number_block.dart'; import 'package:flutter/material.dart'; -import '../../config/theme_colors.dart'; - class HomePage extends StatefulWidget { const HomePage({super.key}); @@ -37,14 +37,14 @@ class _HomePageState extends State { )), backgroundColor: const Color(0xFFF3F3F3), body: PopScope( - canPop: false, + canPop: true, //能否向右滑动返回上一页 child: Padding( padding: const EdgeInsets.all(10), child: Column( children: [ buildTopWidget(), buildMiddleWidget(), - buildBottomWidget() + const MapWidget() ], ), ), diff --git a/lib/pages/home/widgets/map_widget.dart b/lib/pages/home/widgets/map_widget.dart new file mode 100644 index 0000000..24cdf88 --- /dev/null +++ b/lib/pages/home/widgets/map_widget.dart @@ -0,0 +1,71 @@ +import 'package:amap_flutter_map/amap_flutter_map.dart'; +import 'package:autosos_flutter/const_config.dart'; +import 'package:flutter/material.dart'; + + + +class MapWidget extends StatefulWidget { + const MapWidget({super.key}); + + @override + State createState() => _MapWidgetState(); +} + +class _MapWidgetState extends State { + late AMapController _mapController; + @override + Widget build(BuildContext context) { + AMapWidget map = AMapWidget( + ///必须正确设置的合规隐私声明,否则SDK不会工作,会造成地图白屏等问题。 + privacyStatement: ConstConfig.amapPrivacyStatement, + apiKey: ConstConfig.amapApiKeys, + mapType: MapType.navi, + scaleEnabled: false, + myLocationStyleOptions: MyLocationStyleOptions( + true, + circleFillColor: Colors.lightBlue, + circleStrokeColor: Colors.blue, + circleStrokeWidth: 1, + ), + onMapCreated: (AMapController controller) { + setState(() { + _mapController = controller; + getApprovalNumber(); + }); + }, + ); + return Expanded( + child: Stack( + children: [ + Container( + margin: const EdgeInsets.only(top: 10, bottom: 10), + decoration: const BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(5))), + child: map, + ), + Positioned( + bottom: 20, + right: 20, + child: Image.asset( + "images/3.0x/current_location.png", + width: 30, + height: 30, + ), + ) + ], + )); + } + + ///获取审图号 + void getApprovalNumber() async { + //普通地图审图号 + String? mapContentApprovalNumber = + await _mapController.getMapContentApprovalNumber(); + //卫星地图审图号 + String? satelliteImageApprovalNumber = + await _mapController.getSatelliteImageApprovalNumber(); + print('地图审图号(普通地图): $mapContentApprovalNumber'); + print('地图审图号(卫星地图): $satelliteImageApprovalNumber'); + } +}