map_widget

main
zhuce 2024-03-16 14:15:04 +08:00
parent 135caf5adc
commit 97128918e4
2 changed files with 75 additions and 4 deletions

View File

@ -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<HomePage> {
)),
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()
],
),
),

View File

@ -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<MapWidget> createState() => _MapWidgetState();
}
class _MapWidgetState extends State<MapWidget> {
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');
}
}