tlserver / flutter_map_location_marker

A flutter map plugin for displaying device current location.
https://pub.dev/packages/flutter_map_location_marker
BSD 3-Clause "New" or "Revised" License
102 stars 93 forks source link

Access location data from stream #6

Closed bmason8 closed 3 years ago

bmason8 commented 3 years ago

I'm not sure if this is already possible and I just can't figure it out but is there a way to listen to the location stream or just get the location at a given time? I want to get able to pull the location from the marker regardless of where it is on the map (ie if the user scrolls the map so the marker is off center/offscreen, I want to be able to grab their location).

I'm using FlutterMap and currently the only way I can know the markers location is by assigning it to a variable when 'CenterOnLocationUpdate' is set to 'always' in 'onPositionChanged'.

Any help would be appreciated. Thank you.

onPositionChanged: (MapPosition mapPosition, bool hasGesture) {
        if (centerOnLocationUpdate == CenterOnLocationUpdate.always) {
          lastKnownLatLngPosition = LatLng(mapPosition.center!.latitude, mapPosition.center!.longitude);
          // ll('lastKnownLatLngPosition: $lastKnownLatLngPosition');
        }
        if (hasGesture) {
          if (centerOnLocationUpdate == CenterOnLocationUpdate.always) {
            centerOnLocationUpdate = CenterOnLocationUpdate.never;
            notifyListeners();
          }
        }
      },
tlserver commented 3 years ago

This plugin use an other package called geolocator to receive location updates. You may consider use that package directly, but not through this plugin, to receive updates in your application.