map_widget
parent
135caf5adc
commit
97128918e4
|
@ -1,11 +1,11 @@
|
||||||
import 'package:amap_flutter_map/amap_flutter_map.dart';
|
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/const_config.dart';
|
||||||
import 'package:autosos_flutter/pages/home/widgets/image_block.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:autosos_flutter/pages/home/widgets/number_block.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../config/theme_colors.dart';
|
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
const HomePage({super.key});
|
const HomePage({super.key});
|
||||||
|
|
||||||
|
@ -37,14 +37,14 @@ class _HomePageState extends State<HomePage> {
|
||||||
)),
|
)),
|
||||||
backgroundColor: const Color(0xFFF3F3F3),
|
backgroundColor: const Color(0xFFF3F3F3),
|
||||||
body: PopScope(
|
body: PopScope(
|
||||||
canPop: false,
|
canPop: true, //能否向右滑动返回上一页
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
buildTopWidget(),
|
buildTopWidget(),
|
||||||
buildMiddleWidget(),
|
buildMiddleWidget(),
|
||||||
buildBottomWidget()
|
const MapWidget()
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue