0

My App displays map and markers and it's working OK.

But, I would like that a specific marker (I choose programmatically) will be displayed above the others and it will be easy to find.

Is it the drawing order defined by the order in the markers Set -

              markers: Set.from(markers),

I changed the order by remove and add the specific marker and it doesn't affect

In the following example I see marker #6 and I would like to see marker #1 that is behind

enter image description here

What can I do ?

Kobi
  • 127
  • 1
  • 11

2 Answers2

1

My solution after more than 2 hours.

I think it is difficult but it is easy. :)

  1. Add a zIndex property to your model;
  2. Set default zIndex is 0.5;
  3. Set the zIndex of the marker you want to be above all the rest is 1.0.

enter image description here

Thang Tran
  • 171
  • 1
  • 5
0

I found a solution two options

  1. Create a new markers list.

All except specific one with visible=false. The specific one visible=true.

In this option App will display only the specific one

      Future<void> setVisible(String  _eMail, bool _visible) async {
      final Marker marker = markers.where((element) => element.markerId == MarkerId(_eMail)).first;
        if (_visible != marker.visible) {
          markersVisible.add(marker.copyWith(visibleParam: !marker.visible,));
        } else {
          markersVisible.add(marker.copyWith(visibleParam: marker.visible,));
        }
  }
  1. Using Alpha.

All except specific Alpha=0.1

The specific one Alpha=1

And add the specific one to markers list at the end.

  Future<void> setAlpha(String  _eMail, double _alpha) async {
     final Marker marker = markers.where((element) => element.markerId == MarkerId(_eMail)).first;
       markersVisible.add(marker.copyWith(alphaParam:_alpha ));

}

After creating the new markers list, update display

    setState(() {
       markers = markersVisible;
       markersVisible = [];})
Kobi
  • 127
  • 1
  • 11