map_helper.dart 661 B

1234567891011121314151617181920212223242526
  1. import 'package:flutter_map/flutter_map.dart';
  2. import '../../utils/atmob_log.dart';
  3. class MapHelper {
  4. static const String tag = "MapHelper";
  5. static MapLocation? _lastLocation;
  6. static late MapPlatform _mapPlatform;
  7. static Future<void> init() async {
  8. await FlutterMap.init();
  9. _mapPlatform = FlutterMap.getMapPlatform();
  10. initLocationClient();
  11. }
  12. static initLocationClient() {
  13. _mapPlatform.setLocationListener(
  14. interval: 5000,
  15. listener: (location) {
  16. AtmobLog.d(tag, "onLocationChanged: $location");
  17. if (location.errorCode == 0) {
  18. _lastLocation = location;
  19. }
  20. });
  21. }
  22. }