flutter_animarker icon indicating copy to clipboard operation
flutter_animarker copied to clipboard

How remove Markers from the map?

Open zs-dima opened this issue 3 years ago • 19 comments

Thanks for the nice library. For the clustering and filtering markers could be useful to remove unneeded markers from the map on rebuild widget with new markers set. It works for GoogleMap(markers:{}) itself but do not work for the Animarker(markers:{})

zs-dima avatar May 13 '21 15:05 zs-dima

did you find any solutions for this !

X-SLAYER avatar May 26 '21 09:05 X-SLAYER

Nothing yet, I also encountered the same problem.

WagnerMagnus1 avatar Jun 05 '21 12:06 WagnerMagnus1

Same Here. when I trying to remove marker from Animarker(markers:{}) it's not working and showing all markers but when I use GoogleMap(markers:{}) it works properly. But I found one solution for hiding markers on the map. I use visible:false property in Marker() to hide some marker on map and it work for me.

narendra-vaniya avatar Jun 21 '21 09:06 narendra-vaniya

I encountered the same problem

fateh491989 avatar Jun 28 '21 15:06 fateh491989

I post a new beta update with this bug fixed. Please try it, and let know if working correctly.

gauris26 avatar Jul 06 '21 03:07 gauris26

I managed to remove the marker by using visible: false on it.

marcusvpais avatar Jul 07 '21 02:07 marcusvpais

I managed to remove the marker by using visible: false on it.

It is not good workaround it does not fit most cases

zs-dima avatar Jul 07 '21 08:07 zs-dima

I post a new beta update with this bug fixed. Please try it, and let know if working correctly.

I had the same issue and tried your new update but it doesn't help much. Nothing happens when I add or remove markers from the set. It only works if I remove all markers with markers.clear().

I have many markers moving on a map and need an option to filter them. I tried clearing the markers and then showing them filtered but after they are cleared I cannot make them appear again.

EDIT: I managed to solve my problem by changing this code: https://github.com/gauris26/flutter_animarker/blob/171c708ca71f2b2331fb5e4b7b71ee8ed5c15dd7/lib/widgets/animarker.dart#L365-L368

To this:

if (widget.markers.length < oldWidget.markers.length) {
        widget.updateMarkers(oldWidget.markers, widget.markers);
        return;
      }
      if (widget.markers.length > oldWidget.markers.length) {
        _markers.clear();
      }

ivangr1 avatar Jul 07 '21 18:07 ivangr1

@gauris26 thanks a lot for looking into I could not see Ripple effect after the new beta update

image

I tested on Android emulator

Flutter 2.4.0-0.0.pre • channel dev Framework • revision 96bbcd006f (8 days ago) • 2021-06-30 03:43:41 -0400 Engine • revision c633b2a6a0 Tools • Dart 2.14.0 (build 2.14.0-258.0.dev)

google_maps_flutter: ^2.0.6 flutter_animarker: ^3.3.1-beta.4

Animarker(
 ...
	curve: Curves.bounceInOut,
	duration: Duration(milliseconds: 2000),
	markers: <Marker>{
		RippleMarker(
			markerId: MarkerId('MarkerId2'),
			position: LatLng(0, 0),
			ripple: true,
	 ),
	},
	child: GoogleMap(
		...
		onMapCreated: (gController) => controller.complete(gController), //Complete the future GoogleMapController
		...
	),
)

zs-dima avatar Jul 08 '21 18:07 zs-dima

@ivangr1 solution worked for me , could you please merge his solution into master branch. It will be very helpful for everyone, I think.

manpreetAulakh avatar Aug 23 '21 12:08 manpreetAulakh

I post a new beta update with this bug fixed. Please try it, and let know if working correctly.

I had the same issue and tried your new update but it doesn't help much. Nothing happens when I add or remove markers from the set. It only works if I remove all markers with markers.clear().

I have many markers moving on a map and need an option to filter them. I tried clearing the markers and then showing them filtered but after they are cleared I cannot make them appear again.

EDIT: I managed to solve my problem by changing this code: https://github.com/gauris26/flutter_animarker/blob/171c708ca71f2b2331fb5e4b7b71ee8ed5c15dd7/lib/widgets/animarker.dart#L365-L368

To this:

if (widget.markers.length < oldWidget.markers.length) {
        widget.updateMarkers(oldWidget.markers, widget.markers);
        return;
      }
      if (widget.markers.length > oldWidget.markers.length) {
        _markers.clear();
      }

If it worked, please PR it.

gauris26 avatar Aug 23 '21 12:08 gauris26

@ivangr1 @gauris26 if (widget.markers.length < oldWidget.markers.length) ! different length check will not help it could be the same length but one of markers could be changed

zs-dima avatar Aug 23 '21 13:08 zs-dima

@ivangr1 @gauris26 if (widget.markers.length < oldWidget.markers.length) ! different length check will not help it could be the same length but one of markers could be changed

Yes, you are right. I tried every other combination and this is the only thing that solves at least one problem. I cannot manage to find a complete solution. Can you help us @gauris26?

ivangr1 avatar Aug 24 '21 16:08 ivangr1

How to remove previous markers from map??

DSMalaviya avatar Dec 28 '21 09:12 DSMalaviya

Hi guys,

Please try the latest prerelease beta version I submitted in pub.dev, waiting for your feedback.

gauris26 avatar Jul 24 '22 00:07 gauris26

Hi guys,

Please try the latest prerelease beta version I submitted in pub.dev, waiting for your feedback.

flutter_animarker: ^3.4.0-beta.1 this one?

justsaagar avatar Sep 18 '22 08:09 justsaagar

In flutter_animarker: ^3.2.0 when i update the markers like remove one marker and add two markers it is not reflecting, newly added markers are showing but deleted markers also showing

in flutter_animarker: ^3.4.0-beta.1 this version when i update the marker all markers are removed but newly added markers doesn't shown up

Anybody have solution?

Hackoak avatar Nov 04 '22 06:11 Hackoak

ould not see Ripple effect after the new beta up

same

yncodes avatar Dec 31 '23 06:12 yncodes

I post a new beta update with this bug fixed. Please try it, and let know if working correctly.

I had the same issue and tried your new update but it doesn't help much. Nothing happens when I add or remove markers from the set. It only works if I remove all markers with markers.clear().

I have many markers moving on a map and need an option to filter them. I tried clearing the markers and then showing them filtered but after they are cleared I cannot make them appear again.

EDIT: I managed to solve my problem by changing this code:

https://github.com/gauris26/flutter_animarker/blob/171c708ca71f2b2331fb5e4b7b71ee8ed5c15dd7/lib/widgets/animarker.dart#L365-L368

To this:

if (widget.markers.length < oldWidget.markers.length) {
        widget.updateMarkers(oldWidget.markers, widget.markers);
        return;
      }
      if (widget.markers.length > oldWidget.markers.length) {
        _markers.clear();
      }

I tried this package out today and encountered this issue. if I change the visibility or remove a marker the marker remains on the map regardless.

I want to believe that it is safe to do this to fix the issue;

if (widget.markers != oldWidget.markers) {
      widget.updateMarkers(oldWidget.markers, widget.markers);
      return;
}

EDIT

After trying it out, it works just fine for me

binemmanuel avatar Aug 31 '24 23:08 binemmanuel