[BUG] Markers not displaying on first map display (map doesn't have a size on certain devices). #1334
Closed
5 tasks done
Labels
bug
This issue reports broken functionality or another error
What is the bug?
When you look at the example HomePage, there should be 3 markers. Only one displays until you move the map.
(This works fine on the web, but not on some devices, tested on Android Redmi Note 10).
What is the expected behaviour?
All 3 markers should appear.
How can we reproduce this issue?
Just run the example home page.
Do you have a potential solution?
This is the likely issue.
When we run the marker_layer code, we do the following, to try and eliminate drawing markers out of bounds.
However, if we look at the bounds, they are
Bounds(CustomPoint (4093.0, 2724.0), CustomPoint (4093.0, 2724.0))
, so one pixel wide. So the markers get rejected apart from the one placed in the middle coincidentally.The reason for that, is that in map.dart we call
getPixelBounds()
And here, on first run it has a size of
(0.0, 0.0)
So basically any code that calls things like
pixelBounds.containsPartialBounds()
won't work if it hasn't had chance to get a size (I think this is because the LayoutBuilder in flutter_map_state.dart context/constraints also has no size then, and even things likeWidgetsBinding.instance.window.physicalSize
returns 0,0).There's probably some other subtle bugs all around this on first display.
Not sure of the best solution on this, as we've been here before. Maybe we should force FlutterMap to run 2 passes first time around, but then will it draw something wrong on the first pass, then right on the 2nd. Not quite sure of an elegant solution to this one (but there is some possibly boiler plate code that could be removed if we did).
Or possibly something like place it in an Offstage widget that doesn't draw first pass, then move it into view (could actually be a feature to make FlutterMap visible or not ? Not sure, just thinking out loud).
Can you provide any other information?
No response
Platforms Affected
Android
Severity
Minimum: Allows normal functioning
Frequency
Consistently: Always occurs at the same time and location
Requirements
flutter doctor
finds no relevant issuesThe text was updated successfully, but these errors were encountered: