Skip to content

Commit a0f1b8c

Browse files
committed
Upgrade example app to flutter_map v8
1 parent 8fa1f81 commit a0f1b8c

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

example/lib/src/screens/main/map_view/components/download_progress/components/render_object.dart

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ class _DownloadProgressMaskerRenderer extends RenderProxyBox {
230230

231231
/// Project specified coordinates to a screen space [Rect]
232232
Rect _calculateRectOfCoords(LatLng nwCoord, LatLng seCoord) {
233-
final nwScreen = mapCamera.latLngToScreenPoint(nwCoord);
234-
final seScreen = mapCamera.latLngToScreenPoint(seCoord);
235-
return Rect.fromPoints(nwScreen.toOffset(), seScreen.toOffset());
233+
final nwScreen = mapCamera.latLngToScreenOffset(nwCoord);
234+
final seScreen = mapCamera.latLngToScreenOffset(seCoord);
235+
return Rect.fromPoints(nwScreen, seScreen);
236236
}
237237

238238
/// Handles incoming tiles from the input stream, modifying the [_tileMapping]
@@ -272,9 +272,20 @@ class _DownloadProgressMaskerRenderer extends RenderProxyBox {
272272
} else {
273273
final zoom = tile.z.toDouble();
274274
_tileMapping[intermediateZoomTile] = tmv = _TileMappingValue.newTile(
275-
nwCoord: mapCamera.crs.pointToLatLng(tile * tileSize, zoom),
276-
seCoord: mapCamera.crs
277-
.pointToLatLng((tile + const Point(1, 1)) * tileSize, zoom),
275+
nwCoord: mapCamera.crs.offsetToLatLng(
276+
Offset(
277+
(tile.x * tileSize).toDouble(),
278+
(tile.y * tileSize).toDouble(),
279+
),
280+
zoom,
281+
),
282+
seCoord: mapCamera.crs.offsetToLatLng(
283+
Offset(
284+
((tile.x + 1) * tileSize).toDouble(),
285+
((tile.y + 1) * tileSize).toDouble(),
286+
),
287+
zoom,
288+
),
278289
);
279290
_mostRecentTile =
280291
() => _calculateRectOfCoords(tmv.nwCoord, tmv.seCoord);

example/lib/src/screens/main/map_view/map_view.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ class _MapViewState extends State<MapView> with TickerProviderStateMixin {
171171
final coords = provider.currentConstructingCoordinates;
172172
if (coords.length > 1) {
173173
final newPointPos = _mapController.mapController.camera
174-
.latLngToScreenPoint(coords.first)
175-
.toOffset();
174+
.latLngToScreenOffset(coords.first);
176175
provider.customPolygonSnap = coords.first != coords.last &&
177176
sqrt(
178177
pow(newPointPos.dx - evt.localPosition.dx, 2) +
@@ -196,11 +195,9 @@ class _MapViewState extends State<MapView> with TickerProviderStateMixin {
196195
final coords = provider.currentConstructingCoordinates;
197196
if (coords.length > 1) {
198197
final newPointPos = _mapController.mapController.camera
199-
.latLngToScreenPoint(coords.first)
200-
.toOffset();
198+
.latLngToScreenOffset(coords.first);
201199
final centerPos = _mapController.mapController.camera
202-
.latLngToScreenPoint(provider.currentNewPointPos!)
203-
.toOffset();
200+
.latLngToScreenOffset(provider.currentNewPointPos!);
204201
provider.customPolygonSnap = coords.first != coords.last &&
205202
sqrt(
206203
pow(newPointPos.dx - centerPos.dx, 2) +

example/pubspec.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ dependencies:
3333

3434
dependency_overrides:
3535
flutter_map:
36-
git:
37-
url: https://github.com/fleaflet/flutter_map.git
38-
ref: d816b4d54f9245e260b125ea1adbf300b5c39843
36+
git: https://github.com/fleaflet/flutter_map.git
3937
flutter_map_tile_caching:
4038
path: ../
4139

0 commit comments

Comments
 (0)