osm_flutter icon indicating copy to clipboard operation
osm_flutter copied to clipboard

changeLocation function not removing old markers  

Open rgtstha opened this issue 2 years ago • 0 comments

Calling _mapController.changeLocation(..) function is not removing the old markers. Is it intentional behavior or I have done some misconfigurations.

I want to change marker's position every time the GeoPoint changes.

Map Screenshot: Screen Shot 2022-07-05 at 10 50 45

Minimal Code

@override
  Widget build(BuildContext context) {
    return BlocListener<CurrentVehicleCubit, CurrentVehicleState>(
      listener: (context, state) async {
        if (state.positionEntity != null) {
          if (isMapready) {
            await _mapController.changeLocation(
              GeoPoint(
                latitude: state.positionEntity!.latitude,
                longitude: state.positionEntity!.longitude,
              ),
            );
          }
        } else {
          if (isMapready) {
            await _mapController
                .changeLocation(GeoPoint(latitude: 0, longitude: 0));
          }
        }
      },
      child: OSMFlutter(
        mapIsLoading: Center(
            child: Image.asset(
          'assets/images/loading.gif',
          height: 50,
        )),
        controller: _mapController,
        onMapIsReady: (ready) {
          setState(() {
            isMapready = ready;
          });
        },
        showZoomController: true,
        initZoom: 19,
        markerOption: MarkerOption(
          defaultMarker: MarkerIcon(
            assetMarker: AssetMarker(
              image: AssetImage('assets/icons/marker.png'),
            ),
          ),
        ),
      ),
    );
  }

rgtstha avatar Jul 05 '22 05:07 rgtstha