fivenine-zurich/UnifiedMaps

[Bug Android]Overlays sometimes are not drawn on the Map or not at the good Coordinates.

Opened this issue · 8 comments

Description

On Android, Overlays sometimes are not drawn on the Map or not at the good coordinates.
Maybe caused by the MoveToRegion when drawing at the same time.

Expected Behavior

The Overlays have to be at the correct coordinates with the good proportion.

Also I think Unified Map have to be refactored at some points
Separate Pin, Overlay, Polyline logics in different files to be more readable.
Let me know what to you expect?
regards,

OnMapReady on Android should draw Overlays & Polylines if some were added before.

MoveToRegion could be async or a new MoveToRegionAsync?
Then we will able to wait the camera animation and then draw the Overlay.

Should drawing the overlay not be on the map coordinates? It should have no impact if camera is moving or not, right?

It should, but on Android drawing an Overlay just before or after calling Map.MoveToRegion with animation true
is drawing the Overlay sometimes on wrong coordinates, sometimes it disappear, sometimes never saw it.

Map.MoveToRegion(new MapRegion(new Position(48.853401, 2.348779), 400)), true);
Overlays.Add(new CircleOverlay
  {
    Location = new Position(48.853401, 2.348779),
    Radius = 400,
     Color = Color.Navy.MultiplyAlpha(0.2),
     FillColor = Color.Blue.MultiplyAlpha(0.2)
});

Ok, i see.

Fixing this is making sure the overly drawing is not dependent on a camera move or current visual region. The question is, why does the camera movement have an effect on drawing overlays?

You're proposal of add a async MoveToRegion and wait before drawing a circle would still result in some weird visual behavior?

Haven't looked at the code yet, just thinking about how it should behave.

I do not really look at the problem closely.
But that's why I suggested placing the different logic in separate files
like they do on this repo

I tried that

Overlays.Add(new CircleOverlay
   {
     Location = new Position(48.853401, 2.348779),
      Radius = 400,
      Color = Color.Navy.MultiplyAlpha(0.2),
      FillColor = Color.Blue.MultiplyAlpha(0.2)
   });
await Task.Run(() => Task.Delay(5000));
Map.MoveToRegion(new MapRegion(new Position(48.853401, 2.348779), 400), true);

It's seems that the move to region is just removing the Overlay even if it was draw at good coordinates with good proportions.