jjsos_autosos_flutter/lib/pages/home/widgets/map_widget.dart

72 lines
2.1 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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');
}
}