diff --git a/lib/src/layer/polygon_layer/polygon_layer.dart b/lib/src/layer/polygon_layer/polygon_layer.dart index 0bc3bff8b..867ed8840 100644 --- a/lib/src/layer/polygon_layer/polygon_layer.dart +++ b/lib/src/layer/polygon_layer/polygon_layer.dart @@ -95,9 +95,10 @@ class _PolygonLayerState extends State { ? projected : _cachedSimplifiedPolygons[camera.zoom.floor()] ??= _computeZoomLevelSimplification( + camera: camera, polygons: projected, pixelTolerance: widget.simplificationTolerance, - camera: camera, + devicePixelRatio: MediaQuery.of(context).devicePixelRatio, ); final culled = !widget.polygonCulling @@ -122,14 +123,16 @@ class _PolygonLayerState extends State { } static List<_ProjectedPolygon> _computeZoomLevelSimplification({ + required MapCamera camera, required List<_ProjectedPolygon> polygons, required double pixelTolerance, - required MapCamera camera, + required double devicePixelRatio, }) { final tolerance = getEffectiveSimplificationTolerance( crs: camera.crs, zoom: camera.zoom.floor(), pixelTolerance: pixelTolerance, + devicePixelRatio: devicePixelRatio, ); return List<_ProjectedPolygon>.generate( diff --git a/lib/src/layer/polyline_layer/polyline_layer.dart b/lib/src/layer/polyline_layer/polyline_layer.dart index cc89a2baf..0858cc396 100644 --- a/lib/src/layer/polyline_layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer/polyline_layer.dart @@ -109,9 +109,10 @@ class _PolylineLayerState extends State> { ? projected : _cachedSimplifiedPolylines[camera.zoom.floor()] ??= _computeZoomLevelSimplification( + camera: camera, polylines: projected, pixelTolerance: widget.simplificationTolerance, - camera: camera, + devicePixelRatio: MediaQuery.of(context).devicePixelRatio, ); final culled = widget.cullingMargin == null @@ -221,14 +222,16 @@ class _PolylineLayerState extends State> { } static List<_ProjectedPolyline> _computeZoomLevelSimplification({ + required MapCamera camera, required List<_ProjectedPolyline> polylines, required double pixelTolerance, - required MapCamera camera, + required double devicePixelRatio, }) { final tolerance = getEffectiveSimplificationTolerance( crs: camera.crs, zoom: camera.zoom.floor(), pixelTolerance: pixelTolerance, + devicePixelRatio: devicePixelRatio, ); return List<_ProjectedPolyline>.generate( diff --git a/lib/src/misc/simplify.dart b/lib/src/misc/simplify.dart index ea0828ec6..35c63cf3e 100644 --- a/lib/src/misc/simplify.dart +++ b/lib/src/misc/simplify.dart @@ -142,14 +142,16 @@ double getEffectiveSimplificationTolerance({ required Crs crs, required int zoom, required double pixelTolerance, + required double devicePixelRatio, }) { if (pixelTolerance <= 0) return 0; - final (x0, y0) = crs.untransform(0, 0, crs.scale(zoom.toDouble())); + final scale = crs.scale(zoom.toDouble()); + final (x0, y0) = crs.untransform(0, 0, scale); final (x1, y1) = crs.untransform( - pixelTolerance, - pixelTolerance, - crs.scale(zoom.toDouble()), + pixelTolerance * devicePixelRatio, + pixelTolerance * devicePixelRatio, + scale, ); final dx = x1 - x0;