-
-
Notifications
You must be signed in to change notification settings - Fork 893
Description
What is the bug?
Hi.
When setting useStrokeWidthInMeter = true on a Polyline, the stroke width does not reflect accurate real-world meter sizing. This appears to be due to a lack of correction for projection distortion, particularly with respect to latitude.
Circle elements do correctly account for projection distortion and render real-world dimensions accurately. For example, using identical size settings (e.g., radius or stroke width in meters), the rendered sizes only match near 0° longitude.
In the attached image:
Blue line: Polyline with useStrokeWidthInMeter = true
Black circle: Circle with radius in meters
Both were configured to the same dimension in meters, but only align visually near the equator or 0° longitude.
Expected Behavior:
The Polyline should account for projection distortion (like Circle does) so that stroke width in meters reflects consistent real-world size across different latitudes.
How can we reproduce it?
List<LatLng> line = [];
List<CircleMarker> circles = [];
...
//flutter map
onPointerHover: (event, point) {
line.add(point);
circles.add(
CircleMarker(point: point,color: Colors.black.withAlpha(50), useRadiusInMeter:true, radius: 10000, ),
);
setState(() {});
}
...
///layers
PolylineLayer( polylines: [Polyline(points: line, color: Colors.blue,useStrokeWidthInMeter: true, strokeWidth: 20000.0,)], ),
CircleLayer(circles: circles),Do you have a potential solution?
This isn’t a simple fix because a single lineWidth can’t represent a consistent real-world size across different latitudes — metres-per-pixel changes with latitude (due to projection distortion). If two points are added from -90 to +90, it would be fixed size line, so need to split it into segments and scale each segment to real world size. That could cause steps if segments are too long. So maybe need to make polyline out of vertices.