Skip to content

Commit

Permalink
Upgrade example app to flutter_map v8
Browse files Browse the repository at this point in the history
  • Loading branch information
JaffaKetchup committed Jan 11, 2025
1 parent 8fa1f81 commit a0f1b8c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ class _DownloadProgressMaskerRenderer extends RenderProxyBox {

/// Project specified coordinates to a screen space [Rect]
Rect _calculateRectOfCoords(LatLng nwCoord, LatLng seCoord) {
final nwScreen = mapCamera.latLngToScreenPoint(nwCoord);
final seScreen = mapCamera.latLngToScreenPoint(seCoord);
return Rect.fromPoints(nwScreen.toOffset(), seScreen.toOffset());
final nwScreen = mapCamera.latLngToScreenOffset(nwCoord);
final seScreen = mapCamera.latLngToScreenOffset(seCoord);
return Rect.fromPoints(nwScreen, seScreen);
}

/// Handles incoming tiles from the input stream, modifying the [_tileMapping]
Expand Down Expand Up @@ -272,9 +272,20 @@ class _DownloadProgressMaskerRenderer extends RenderProxyBox {
} else {
final zoom = tile.z.toDouble();
_tileMapping[intermediateZoomTile] = tmv = _TileMappingValue.newTile(
nwCoord: mapCamera.crs.pointToLatLng(tile * tileSize, zoom),
seCoord: mapCamera.crs
.pointToLatLng((tile + const Point(1, 1)) * tileSize, zoom),
nwCoord: mapCamera.crs.offsetToLatLng(
Offset(
(tile.x * tileSize).toDouble(),
(tile.y * tileSize).toDouble(),
),
zoom,
),
seCoord: mapCamera.crs.offsetToLatLng(
Offset(
((tile.x + 1) * tileSize).toDouble(),
((tile.y + 1) * tileSize).toDouble(),
),
zoom,
),
);
_mostRecentTile =
() => _calculateRectOfCoords(tmv.nwCoord, tmv.seCoord);
Expand Down
9 changes: 3 additions & 6 deletions example/lib/src/screens/main/map_view/map_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ class _MapViewState extends State<MapView> with TickerProviderStateMixin {
final coords = provider.currentConstructingCoordinates;
if (coords.length > 1) {
final newPointPos = _mapController.mapController.camera
.latLngToScreenPoint(coords.first)
.toOffset();
.latLngToScreenOffset(coords.first);
provider.customPolygonSnap = coords.first != coords.last &&
sqrt(
pow(newPointPos.dx - evt.localPosition.dx, 2) +
Expand All @@ -196,11 +195,9 @@ class _MapViewState extends State<MapView> with TickerProviderStateMixin {
final coords = provider.currentConstructingCoordinates;
if (coords.length > 1) {
final newPointPos = _mapController.mapController.camera
.latLngToScreenPoint(coords.first)
.toOffset();
.latLngToScreenOffset(coords.first);
final centerPos = _mapController.mapController.camera
.latLngToScreenPoint(provider.currentNewPointPos!)
.toOffset();
.latLngToScreenOffset(provider.currentNewPointPos!);
provider.customPolygonSnap = coords.first != coords.last &&
sqrt(
pow(newPointPos.dx - centerPos.dx, 2) +
Expand Down
4 changes: 1 addition & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ dependencies:

dependency_overrides:
flutter_map:
git:
url: https://github.com/fleaflet/flutter_map.git
ref: d816b4d54f9245e260b125ea1adbf300b5c39843
git: https://github.com/fleaflet/flutter_map.git
flutter_map_tile_caching:
path: ../

Expand Down

0 comments on commit a0f1b8c

Please sign in to comment.