run_map.dart 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import 'package:amap_flutter_base/amap_flutter_base.dart';
  2. import 'package:amap_flutter_map/amap_flutter_map.dart';
  3. import 'package:flutter/foundation.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter/rendering.dart';
  6. import 'package:flutter/services.dart';
  7. import 'package:sport/pages/run/run_page.dart';
  8. import 'package:sport/pages/run/setting_page.dart';
  9. import 'package:sport/router/navigator_util.dart';
  10. import 'package:sport/services/app_lifecycle_state.dart';
  11. import 'package:sport/widgets/appbar.dart';
  12. class RunMapPage extends StatefulWidget {
  13. final int id;
  14. final bool post;
  15. final bool share;
  16. const RunMapPage({Key? key, this.id = 0, this.post = false, this.share = false}) : super(key: key);
  17. @override
  18. State<StatefulWidget> createState() => _PageState();
  19. }
  20. class _PageState extends LifecycleState<RunMapPage> with RunSetting {
  21. AMapController? _mapController;
  22. @override
  23. void initState() {
  24. super.initState();
  25. }
  26. void _onMapCreated(AMapController controller) {
  27. _mapController = controller;
  28. _mapController?.moveCamera(CameraUpdate.newCameraPosition(CameraPosition(tilt: 45.0, zoom: 18, bearing: -15, target: LatLng(23.13170770743485, 113.36392327684825))), animated: true, duration: 2000);
  29. }
  30. @override
  31. Widget build(BuildContext context) {
  32. return Scaffold(
  33. backgroundColor: Colors.white,
  34. appBar: buildAppBar(context, actions: [
  35. GestureDetector(
  36. onTap: () async {
  37. await NavigatorUtil.goPage(context, (context) => SettingPage());
  38. refreshSetting();
  39. },
  40. child: Container(
  41. width: 44.0,
  42. height: 44.0,
  43. decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(50.0)),
  44. child: Image.asset("lib/assets/img/setgoals_icon_set.png")),
  45. ),
  46. ]),
  47. body: AMapWidget(
  48. apiKey: AMapApiKey(androidKey: KEY_ANDROID, iosKey: KEY_IOS),
  49. mapType: selectMapType(this.runMapType),
  50. buildingsEnabled: true,
  51. onMapCreated: _onMapCreated,
  52. initialCameraPosition: CameraPosition(target: LatLng(23.13170770743485, 113.36392327684825), zoom: 16, bearing: -270 ),
  53. customStyleOptions: customStyleOptions,
  54. // tiltGesturesEnabled: true,
  55. // rotateGesturesEnabled: false,
  56. touchPoiEnabled: false,
  57. labelsEnabled: false,
  58. ));
  59. }
  60. }