osm_flutter icon indicating copy to clipboard operation
osm_flutter copied to clipboard

enableStopFollow dont work

Open smiesnyrobert opened this issue 2 years ago • 35 comments

Hi, if i call await controller.enableTracking(enableStopFollow: true); map is still following my position

Iam using Android device

Can u please fix it? thank you

smiesnyrobert avatar May 13 '23 16:05 smiesnyrobert

it will only follow for first time or still map follow the user location changes?

liodali avatar May 14 '23 16:05 liodali

map following user position all the time, i can disable it only if i drag map

enableStopFollow parameter true/false it does not matter

smiesnyrobert avatar May 14 '23 17:05 smiesnyrobert

i will check the issue

liodali avatar May 14 '23 17:05 liodali

which version you're using ?

liodali avatar May 14 '23 19:05 liodali

v0.53.4+1

smiesnyrobert avatar May 15 '23 06:05 smiesnyrobert

i will fix the issue but i want to know is better to make one api for activate user location and tracking or keep it like this since in our plugin we have currentLocation and enableTracking

liodali avatar May 18 '23 09:05 liodali

second approach would be better (saperatelly activate show current position, and saparatelly enable/disable follow)

smiesnyrobert avatar May 18 '23 11:05 smiesnyrobert

check the new version 0.54.0

liodali avatar May 20 '23 17:05 liodali

still doesnt work

i have trackMyPosition: true, and then i have button and onclick await controller.enableTracking(enableStopFollow: true); but camera still following current position

smiesnyrobert avatar May 21 '23 08:05 smiesnyrobert

i made new adjustment for latest fix. check our new version 0.54.1

liodali avatar May 21 '23 09:05 liodali

stil not working, param enableStopFollow true/false seems wont change anything

smiesnyrobert avatar May 21 '23 14:05 smiesnyrobert

can you share part of your code ?

liodali avatar May 21 '23 14:05 liodali

MapController controller = MapController(
      initMapWithUserPosition: false,
      initPosition: GeoPoint(latitude: 48.578424, longitude: 19.131043));
OSMFlutter(
                    onMapIsReady: (ready) async {
                      if (ready) {
                        setState(() {
                          isMapReady = true;
                        });
                        setupScreen();
                      }
                    },
                    onLocationChanged: (point) { // THIS also dont work, only one time called 
                      onLocationChanged(point);
                    },
                    isPicker: false,
                    controller: controller,
                    userLocationMarker: UserLocationMaker(   // THIS also dont work, wrong anchor on icon
                      personMarker: MarkerIcon(
                        iconWidget: SvgPicture.asset(
                          "assets/graphics/my_position_icon.svg",
                          height: 36,
                        ),
                      ),
                      directionArrowMarker: MarkerIcon(
                        iconWidget: SvgPicture.asset(
                          "assets/graphics/my_position_icon.svg",
                          height: 36,
                        ),
                      ),
                    ),
                    trackMyPosition: true,
                    initZoom: 16,
                    minZoomLevel: 8,
                    maxZoomLevel: 19,
                    stepZoom: 1.0,
                    markerOption: MarkerOption(
                        advancedPickerMarker: MarkerIcon(
                          icon: Icon(
                            Icons.push_pin_sharp,
                            color: Colors.deepPurple,
                            size: 120,
                          ),
                        ),
                        defaultMarker: MarkerIcon(
                          icon: Icon(
                            Icons.person_pin_circle,
                            color: Colors.blueAccent,
                            size: 56,
                          ),
                        )),
                  ))),
Positioned(
            child: new FloatingActionButton(
              child: new Icon(Icons.my_location, color: Colors.white),
              onPressed: () async {
                await controller.enableTracking(enableStopFollow: true);
              },
            ),

smiesnyrobert avatar May 21 '23 14:05 smiesnyrobert

i check the use case it should work fine can provide me your expection when enableStopFollow = true ? what exactly you use case ? because enableStopFollow = true will just disable the follow means that you can move the map freely

liodali avatar May 25 '23 16:05 liodali

hmm i need call some method to stop following my current position(but still showing it on map)

now i need to call await controller.enableTracking(enableStopFollow: true); and then click manually on map to stop follow

u said "enableStopFollow = true will just disable the follow means that you can move the map freely", so its just unlocking map moving gesture. But i need just stop centering mapp when my position changed

just stopMovingCameraToMyPosition()

smiesnyrobert avatar May 25 '23 16:05 smiesnyrobert

we have disableTracking also enableStopFollow = true will keep getting user location but will not disable the tracking

liodali avatar May 25 '23 16:05 liodali

disableTracking remove my position from map

smiesnyrobert avatar May 25 '23 16:05 smiesnyrobert

and you don't want that behavior ?

liodali avatar May 25 '23 17:05 liodali

maybe some new function: stop centering camera on my position but keep it on map

i tought enableStopFollow is this function, but it just enable/disable gestures to move map, maybe some other name for this param will be better, eg. lockedMap: true/false

controller.enableTracking(enableStopFollow: true); = STOP centering map on my location controller.enableTracking(enableStopFollow: false); = START centering map on my location

controller.enableTracking(lockedMap: true); = enableStopFollow: true at this moment controller.enableTracking(lockedMap: false); = enableStopFollow: false at this moment

OSMFlutter(
                    trackMyPosition: true,
                    followMyPosition: false,   // just center it on first fix then dont follow
                  )

smiesnyrobert avatar May 25 '23 17:05 smiesnyrobert

check new version 0.54.2

liodali avatar May 27 '23 10:05 liodali

sorry i dont know how to use it, can u add some example how to call something to stop following my position?

smiesnyrobert avatar May 29 '23 15:05 smiesnyrobert

check new version 0.55.0 we added UserTrackOption in MapController.withUserPosition try to put unFollowUser to false and told me the result in general we disable the follow of the user but the trcking still active

liodali avatar May 29 '23 16:05 liodali

seems worse than before.

controller = MapController(
          initMapWithUserPosition: UserTrackingOption(enableTracking: true,unFollowUser: false)

unFollowUser true or false doesnt matter, camera still moving to my position as i move.

and now i cant init map with this

initPosition: GeoPoint(latitude: 48.578424, longitude: 19.131043)

becouse now i must set initMapWithUserPosition, and if dont have permission to gps map is never get initialized.

before commit, i could put

initMapWithUserPosition:false 
initPosition: GeoPoint(latitude: 48.578424, longitude: 19.131043) 

trackMyPosition: true

can u just revert changes and make just one method eg. controller.followUser(true/false) to dynamically follow/unfollow user?

smiesnyrobert avatar May 29 '23 16:05 smiesnyrobert

sorry to hear that but in from 0.55+ you should use named constructor .withPosition or withUserPosition and i will add UserTrackOption to replace the removed attribute trackMyPosition

liodali avatar May 29 '23 17:05 liodali

for information that unFollowUser does the what you want I will record video to show you how its works

liodali avatar May 29 '23 17:05 liodali

controller = MapController.withUserPosition(trackUserLocation: UserTrackingOption(enableTracking: true,unFollowUser: true)

or

controller = MapController.withUserPosition(trackUserLocation: UserTrackingOption(enableTracking: true,unFollowUser: false)

both still animating camera to my current location when i move

and now onMapIsReady not trigered if i dont allow location permission

before, i could decline permission and onMapIsReady true was triggered

ok i will wait for video to check this

smiesnyrobert avatar May 29 '23 18:05 smiesnyrobert

I think I get your use case you want to init map with position and enable user location without changing map to the user location from the begninning Am I wrong ?

liodali avatar May 30 '23 14:05 liodali

init map with position was just workaround if u dont enable gps to trigger mapIsReady anyway.

before last commit it was good

  1. start app
  2. while mapIsReady false, show some logo
  3. popup to ask gps permission a. allow = mapIsReady true, move camera to my position b. decline = mapIsReady true, move camera to initial position
  4. what i want at beggining, stop follow but still show my position

so i want at the beggining change map to user location, but i want ability to dynamically turn it off/on (changing map to user location)

i had simple workaround programmatically drag map, that's all this does what i want

  disableFollowHack() async {
    GestureBinding.instance!.handlePointerEvent(PointerDownEvent(
      position: Offset(200, 300),
    ));
    await Future.delayed(Duration(milliseconds: 500));
    GestureBinding.instance!.handlePointerEvent(PointerUpEvent(
      position: Offset(200, 300),
    ));
  }

smiesnyrobert avatar May 30 '23 15:05 smiesnyrobert

https://drive.google.com/file/d/1diHkoCO_98MbGUX1wDwwbwxp9YAgBavP/view?usp=sharing

check the video, i click both methods and only difference is if i click TRUE then i can drag map, if i drag the map thats is the functionality that i want, just stop follow

smiesnyrobert avatar May 30 '23 15:05 smiesnyrobert

i will make update tonight or tomorrow at max It will contain replacement for trackMyPosition in OSMFlutter and fix when enableStopFollow : false

liodali avatar May 30 '23 17:05 liodali