osm_flutter
osm_flutter copied to clipboard
changeLocation function not removing old markers
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:
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'),
),
),
),
),
);
}