From 1f773a183ba7f1b7a6b009302b3b6197ff6f2f6a Mon Sep 17 00:00:00 2001 From: mootw Date: Sat, 2 Dec 2023 10:22:07 -0600 Subject: [PATCH 1/4] migrate to use record type --- .../lib/pages/animated_map_controller.dart | 22 +- example/lib/pages/bundled_offline_map.dart | 6 +- .../lib/pages/cancellable_tile_provider.dart | 6 +- example/lib/pages/circle.dart | 6 +- example/lib/pages/custom_crs/Readme.md | 2 +- example/lib/pages/custom_crs/custom_crs.dart | 4 +- example/lib/pages/epsg3413_crs.dart | 17 +- example/lib/pages/epsg4326_crs.dart | 2 +- example/lib/pages/fallback_url_page.dart | 2 +- example/lib/pages/home.dart | 6 +- example/lib/pages/interactive_test_page.dart | 2 +- example/lib/pages/latlng_to_screen_point.dart | 2 +- example/lib/pages/many_circles.dart | 8 +- example/lib/pages/many_markers.dart | 4 +- example/lib/pages/map_controller.dart | 8 +- example/lib/pages/map_inside_listview.dart | 2 +- example/lib/pages/markers.dart | 14 +- example/lib/pages/moving_markers.dart | 8 +- example/lib/pages/overlay_image.dart | 18 +- example/lib/pages/polygon.dart | 70 +- example/lib/pages/polyline.dart | 38 +- example/lib/pages/reset_tile_layer.dart | 4 +- example/lib/pages/retina.dart | 2 +- example/lib/pages/scalebar_utils.dart | 8 +- example/lib/pages/screen_point_to_latlng.dart | 4 +- example/lib/pages/secondary_tap.dart | 2 +- example/lib/pages/sliding_map.dart | 6 +- example/lib/pages/stateful_markers.dart | 8 +- example/lib/pages/tile_builder.dart | 4 +- .../lib/pages/tile_loading_error_handle.dart | 2 +- example/lib/pages/wms_tile_layer.dart | 2 +- example/lib/plugins/plugin_scalebar.dart | 2 +- example/lib/plugins/plugin_zoombuttons.dart | 2 +- example/pubspec.yaml | 1 + lib/flutter_map.dart | 4 +- lib/src/geo/crs.dart | 29 +- lib/src/geo/latlng.dart | 7 + lib/src/geo/latlng_bounds.dart | 67 +- .../flutter_map_interactive_viewer.dart | 7 +- lib/src/gestures/latlng_tween.dart | 8 +- lib/src/gestures/map_events.dart | 2 +- lib/src/layer/circle_layer.dart | 31 +- lib/src/layer/marker_layer.dart | 2 +- lib/src/layer/overlay_image_layer.dart | 2 +- lib/src/layer/polygon_layer/label.dart | 17 +- .../layer/polygon_layer/polygon_layer.dart | 4 +- lib/src/layer/polyline_layer.dart | 10 +- .../tile_layer/tile_bounds/tile_bounds.dart | 9 +- .../tile_layer/tile_range_calculator.dart | 2 +- .../layer/tile_layer/tile_update_event.dart | 2 +- lib/src/map/camera/camera.dart | 20 +- lib/src/map/camera/camera_constraint.dart | 7 +- lib/src/map/camera/camera_fit.dart | 2 +- lib/src/map/controller/impl.dart | 2 +- lib/src/map/controller/internal.dart | 5 +- lib/src/map/controller/map_controller.dart | 2 +- lib/src/map/options/options.dart | 4 +- lib/src/misc/center_zoom.dart | 2 +- lib/src/misc/position.dart | 2 +- test/flutter_map_test.dart | 7 +- test/geo/latlng_bounds_test.dart | 15 +- test/layer/circle_layer_test.dart | 3 +- test/layer/marker_layer_test.dart | 3 +- test/layer/polygon_layer_test.dart | 18 +- test/layer/polyline_layer_test.dart | 10 +- .../tile_layer/tile_bounds/crs_fakes.dart | 2 +- .../tile_bounds/tile_bounds_test.dart | 5 +- test/map/camera/camera_constraint_test.test | 37 -- test/map/map_controller_test.dart | 612 +++++++++--------- test/test_utils/test_app.dart | 3 +- 70 files changed, 620 insertions(+), 638 deletions(-) create mode 100644 lib/src/geo/latlng.dart delete mode 100644 test/map/camera/camera_constraint_test.test diff --git a/example/lib/pages/animated_map_controller.dart b/example/lib/pages/animated_map_controller.dart index 313a3fbad..388220494 100644 --- a/example/lib/pages/animated_map_controller.dart +++ b/example/lib/pages/animated_map_controller.dart @@ -19,9 +19,9 @@ class AnimatedMapControllerPageState extends State static const _inProgressId = 'AnimatedMapController#MoveInProgress'; static const _finishedId = 'AnimatedMapController#MoveFinished'; - static const _london = LatLng(51.5, -0.09); - static const _paris = LatLng(48.8566, 2.3522); - static const _dublin = LatLng(53.3498, -6.2603); + static const _london = (lat: 51.5, lon: -0.09); + static const _paris = (lat: 48.8566, lon: 2.3522); + static const _dublin = (lat: 53.3498, lon: -6.2603); static const _markers = [ Marker( @@ -50,10 +50,10 @@ class AnimatedMapControllerPageState extends State // Create some tweens. These serve to split up the transition from one location to another. // In our case, we want to split the transition be our current map center and the destination. final camera = mapController.camera; - final latTween = Tween( - begin: camera.center.latitude, end: destLocation.latitude); - final lngTween = Tween( - begin: camera.center.longitude, end: destLocation.longitude); + final latTween = + Tween(begin: camera.center.lat, end: destLocation.lat); + final lngTween = + Tween(begin: camera.center.lon, end: destLocation.lon); final zoomTween = Tween(begin: camera.zoom, end: destZoom); // Create a animation controller that has a duration and a TickerProvider. @@ -69,7 +69,7 @@ class AnimatedMapControllerPageState extends State // to detect an appropriate animated movement event which contains the // target zoom/center. final startIdWithTarget = - '$_startedId#${destLocation.latitude},${destLocation.longitude},$destZoom'; + '$_startedId#${destLocation.lat},${destLocation.lon},$destZoom'; bool hasTriggeredMove = false; controller.addListener(() { @@ -83,7 +83,7 @@ class AnimatedMapControllerPageState extends State } hasTriggeredMove |= mapController.move( - LatLng(latTween.evaluate(animation), lngTween.evaluate(animation)), + (lat: latTween.evaluate(animation), lon: lngTween.evaluate(animation)), zoomTween.evaluate(animation), id: id, ); @@ -171,7 +171,7 @@ class AnimatedMapControllerPageState extends State child: FlutterMap( mapController: mapController, options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, maxZoom: 10, minZoom: 3, @@ -215,7 +215,7 @@ final _animatedMoveTileUpdateTransformer = // whilst animating. sink.add( updateEvent.loadOnly( - loadCenterOverride: LatLng(lat, lon), + loadCenterOverride: (lat: lat, lon: lon), loadZoomOverride: zoom, ), ); diff --git a/example/lib/pages/bundled_offline_map.dart b/example/lib/pages/bundled_offline_map.dart index e64ca9da1..95b97cd90 100644 --- a/example/lib/pages/bundled_offline_map.dart +++ b/example/lib/pages/bundled_offline_map.dart @@ -14,13 +14,13 @@ class BundledOfflineMapPage extends StatelessWidget { drawer: const MenuDrawer(route), body: FlutterMap( options: MapOptions( - initialCenter: const LatLng(56.704173, 11.543808), + initialCenter: const (lat: 56.704173, lon: 11.543808), minZoom: 12, maxZoom: 14, cameraConstraint: CameraConstraint.containCenter( bounds: LatLngBounds( - const LatLng(56.7378, 11.6644), - const LatLng(56.6877, 11.5089), + const (lat: 56.7378, lon: 11.6644), + const (lat: 56.6877, lon: 11.5089), ), ), ), diff --git a/example/lib/pages/cancellable_tile_provider.dart b/example/lib/pages/cancellable_tile_provider.dart index ec3de2fe8..d5ebc690d 100644 --- a/example/lib/pages/cancellable_tile_provider.dart +++ b/example/lib/pages/cancellable_tile_provider.dart @@ -46,12 +46,12 @@ class _CancellableTileProviderPageState Expanded( child: FlutterMap( options: MapOptions( - initialCenter: const LatLng(51.5, -0.09), + initialCenter: const (lat: 51.5, lon: 0.09), initialZoom: 5, cameraConstraint: CameraConstraint.contain( bounds: LatLngBounds( - const LatLng(-90, -180), - const LatLng(90, 180), + const (lat: -90, lon: 180), + const (lat: 90, lon: 180), ), ), ), diff --git a/example/lib/pages/circle.dart b/example/lib/pages/circle.dart index 4d98a03ee..4268bd1b7 100644 --- a/example/lib/pages/circle.dart +++ b/example/lib/pages/circle.dart @@ -15,7 +15,7 @@ class CirclePage extends StatelessWidget { drawer: const MenuDrawer(route), body: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 11, ), children: [ @@ -23,7 +23,7 @@ class CirclePage extends StatelessWidget { CircleLayer( circles: [ CircleMarker( - point: const LatLng(51.5, -0.09), + point: const (lat: 51.5, lon: 0.09), color: Colors.blue.withOpacity(0.7), borderColor: Colors.black, borderStrokeWidth: 2, @@ -31,7 +31,7 @@ class CirclePage extends StatelessWidget { radius: 2000, // 2000 meters ), CircleMarker( - point: const LatLng(51.4937, -0.6638), + point: const (lat: 51.4937, lon: 0.6638), // Dorney Lake is ~2km long color: Colors.green.withOpacity(0.9), borderColor: Colors.black, diff --git a/example/lib/pages/custom_crs/Readme.md b/example/lib/pages/custom_crs/Readme.md index a79854052..fb691aa8e 100644 --- a/example/lib/pages/custom_crs/Readme.md +++ b/example/lib/pages/custom_crs/Readme.md @@ -107,7 +107,7 @@ Proj4Crs has multiple uses: options: MapOptions( // Set the default CRS crs: epsg3413CRS, - center: LatLng(65.05166470332148, -19.171744826394896), + center: (lat: 65.05166470332148, lon: 19.171744826394896), zoom: 3.0, maxZoom: maxZoom, ), diff --git a/example/lib/pages/custom_crs/custom_crs.dart b/example/lib/pages/custom_crs/custom_crs.dart index aba6f6bb1..f7c06f772 100644 --- a/example/lib/pages/custom_crs/custom_crs.dart +++ b/example/lib/pages/custom_crs/custom_crs.dart @@ -129,14 +129,14 @@ class CustomCrsPageState extends State { options: MapOptions( // Set the default CRS crs: epsg3413CRS, - initialCenter: LatLng(point.x, point.y), + initialCenter: (lat: point.x, lon: point.y), initialZoom: 3, // Set maxZoom usually scales.length - 1 OR resolutions.length - 1 // but not greater maxZoom: maxZoom, onTap: (tapPosition, p) => setState(() { initText = 'You clicked at'; - point = proj4.Point(x: p.latitude, y: p.longitude); + point = proj4.Point(x: p.lat, y: p.lon); }), ), children: [ diff --git a/example/lib/pages/epsg3413_crs.dart b/example/lib/pages/epsg3413_crs.dart index dd266f3c6..faf0464e2 100644 --- a/example/lib/pages/epsg3413_crs.dart +++ b/example/lib/pages/epsg3413_crs.dart @@ -3,6 +3,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; +import 'package:latlong2/latlong.dart' as latlong2; import 'package:proj4dart/proj4dart.dart' as proj4; import 'package:url_launcher/url_launcher.dart'; @@ -18,8 +19,8 @@ class EPSG3413Page extends StatefulWidget { class EPSG3413PageState extends State { late final Proj4Crs epsg3413CRS; - final distancePoleToLat80 = - const Distance().distance(const LatLng(90, 0), const LatLng(80, 0)); + final distancePoleToLat80 = const latlong2.Distance() + .distance(const latlong2.LatLng(90, 0), const latlong2.LatLng(80, 0)); double? maxZoom; @@ -73,7 +74,7 @@ class EPSG3413PageState extends State { // These circles should have the same pixel radius on the map final circles = [ const CircleMarker( - point: LatLng(90, 0), + point: (lat: 90, lon: 0), radius: 20000, useRadiusInMeter: true, color: Colors.yellow, @@ -81,7 +82,7 @@ class EPSG3413PageState extends State { ]; for (final lon in [-90.0, 0.0, 90.0, 180.0]) { circles.add(CircleMarker( - point: LatLng(80, lon), + point: (lat: 80, lon: lon), radius: 20000, useRadiusInMeter: true, color: Colors.red, @@ -90,7 +91,7 @@ class EPSG3413PageState extends State { // Add latitude line at 80 degrees circles.add(CircleMarker( - point: const LatLng(90, 0), + point: const (lat: 90, lon: 0), radius: distancePoleToLat80, useRadiusInMeter: true, color: Colors.transparent, @@ -135,7 +136,7 @@ class EPSG3413PageState extends State { child: FlutterMap( options: MapOptions( crs: epsg3413CRS, - initialCenter: const LatLng(90, 0), + initialCenter: const (lat: 90, lon: 0), initialZoom: 3, maxZoom: maxZoom, ), @@ -154,8 +155,8 @@ class EPSG3413PageState extends State { overlayImages: [ OverlayImage( bounds: LatLngBounds( - const LatLng(72.7911372, 162.6196478), - const LatLng(85.2802493, 79.794166), + const (lat: 72.7911372, lon: 162.6196478), + const (lat: 85.2802493, lon: 79.794166), ), imageProvider: Image.asset( 'assets/map/epsg3413/amsr2.png', diff --git a/example/lib/pages/epsg4326_crs.dart b/example/lib/pages/epsg4326_crs.dart index 5b46d34db..ad84d26f7 100644 --- a/example/lib/pages/epsg4326_crs.dart +++ b/example/lib/pages/epsg4326_crs.dart @@ -16,7 +16,7 @@ class EPSG4326Page extends StatelessWidget { options: const MapOptions( minZoom: 0, crs: Epsg4326(), - initialCenter: LatLng(0, 0), + initialCenter: (lat: 0, lon: 0), initialZoom: 0, ), children: [ diff --git a/example/lib/pages/fallback_url_page.dart b/example/lib/pages/fallback_url_page.dart index 893b34f54..858f997f5 100644 --- a/example/lib/pages/fallback_url_page.dart +++ b/example/lib/pages/fallback_url_page.dart @@ -32,7 +32,7 @@ class FallbackUrlPage extends StatelessWidget { Flexible( child: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, ), children: [ diff --git a/example/lib/pages/home.dart b/example/lib/pages/home.dart index ba3e1fbe7..025490513 100644 --- a/example/lib/pages/home.dart +++ b/example/lib/pages/home.dart @@ -33,12 +33,12 @@ class _HomePageState extends State { children: [ FlutterMap( options: MapOptions( - initialCenter: const LatLng(51.5, -0.09), + initialCenter: const (lat: 51.5, lon: 0.09), initialZoom: 5, cameraConstraint: CameraConstraint.contain( bounds: LatLngBounds( - const LatLng(-90, -180), - const LatLng(90, 180), + const (lat: -90, lon: 180), + const (lat: 90, lon: 180), ), ), ), diff --git a/example/lib/pages/interactive_test_page.dart b/example/lib/pages/interactive_test_page.dart index 69db1cb79..c2991b6aa 100644 --- a/example/lib/pages/interactive_test_page.dart +++ b/example/lib/pages/interactive_test_page.dart @@ -117,7 +117,7 @@ class _InteractiveFlagsPageState extends State { child: FlutterMap( options: MapOptions( onMapEvent: (evt) => setState(() => _latestEvent = evt), - initialCenter: const LatLng(51.5, -0.09), + initialCenter: const (lat: 51.5, lon: 0.09), initialZoom: 11, interactionOptions: InteractionOptions( flags: flags, diff --git a/example/lib/pages/latlng_to_screen_point.dart b/example/lib/pages/latlng_to_screen_point.dart index eacdd994c..fc27b2bf6 100644 --- a/example/lib/pages/latlng_to_screen_point.dart +++ b/example/lib/pages/latlng_to_screen_point.dart @@ -44,7 +44,7 @@ class _LatLngToScreenPointPageState extends State { FlutterMap( mapController: mapController, options: MapOptions( - initialCenter: const LatLng(51.5, -0.09), + initialCenter: const (lat: 51.5, lon: 0.09), initialZoom: 11, interactionOptions: const InteractionOptions( flags: ~InteractiveFlag.doubleTapZoom, diff --git a/example/lib/pages/many_circles.dart b/example/lib/pages/many_circles.dart index 93f48bb44..979f11e71 100644 --- a/example/lib/pages/many_circles.dart +++ b/example/lib/pages/many_circles.dart @@ -35,9 +35,9 @@ class ManyCirclesPageState extends State { for (var x = 0; x < maxCirclesCount; x++) { allCircles.add( CircleMarker( - point: LatLng( - doubleInRange(r, 37, 55), - doubleInRange(r, -9, 30), + point: ( + lat: doubleInRange(r, 37, 55), + lon: doubleInRange(r, -9, 30), ), color: Colors.red, radius: 5, @@ -70,7 +70,7 @@ class ManyCirclesPageState extends State { Flexible( child: FlutterMap( options: const MapOptions( - initialCenter: LatLng(50, 20), + initialCenter: (lat: 50, lon: 20), initialZoom: 5, interactionOptions: InteractionOptions( flags: InteractiveFlag.all - InteractiveFlag.rotate, diff --git a/example/lib/pages/many_markers.dart b/example/lib/pages/many_markers.dart index 4c7aa6e08..34eac79af 100644 --- a/example/lib/pages/many_markers.dart +++ b/example/lib/pages/many_markers.dart @@ -35,7 +35,7 @@ class ManyMarkersPageState extends State { for (var x = 0; x < maxMarkersCount; x++) { allMarkers.add( Marker( - point: LatLng(doubleInRange(r, 37, 55), doubleInRange(r, -9, 30)), + point: (lat: doubleInRange(r, 37, 55), lon: doubleInRange(r, -9, 30)), height: 12, width: 12, child: ColoredBox(color: Colors.blue[900]!), @@ -68,7 +68,7 @@ class ManyMarkersPageState extends State { Flexible( child: FlutterMap( options: const MapOptions( - initialCenter: LatLng(50, 20), + initialCenter: (lat: 50, lon: 20), initialZoom: 5, interactionOptions: InteractionOptions( flags: InteractiveFlag.all - InteractiveFlag.rotate, diff --git a/example/lib/pages/map_controller.dart b/example/lib/pages/map_controller.dart index 7f930b0a6..9ec2bff35 100644 --- a/example/lib/pages/map_controller.dart +++ b/example/lib/pages/map_controller.dart @@ -16,9 +16,9 @@ class MapControllerPageState extends State { late final MapController _mapController; double _rotation = 0; - static const _london = LatLng(51.5, -0.09); - static const _paris = LatLng(48.8566, 2.3522); - static const _dublin = LatLng(53.3498, -6.2603); + static const _london = (lat: 51.5, lon: 0.09); + static const _paris = (lat: 48.8566, lon: 2.3522); + static const _dublin = (lat: 53.3498, lon: 6.2603); static const _markers = [ Marker( @@ -135,7 +135,7 @@ class MapControllerPageState extends State { child: FlutterMap( mapController: _mapController, options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, maxZoom: 5, minZoom: 3, diff --git a/example/lib/pages/map_inside_listview.dart b/example/lib/pages/map_inside_listview.dart index d57d10094..9c888184f 100644 --- a/example/lib/pages/map_inside_listview.dart +++ b/example/lib/pages/map_inside_listview.dart @@ -23,7 +23,7 @@ class MapInsideListViewPage extends StatelessWidget { height: 300, child: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, ), children: [ diff --git a/example/lib/pages/markers.dart b/example/lib/pages/markers.dart index d62caa16d..cc41d4089 100644 --- a/example/lib/pages/markers.dart +++ b/example/lib/pages/markers.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; @@ -29,8 +31,8 @@ class _MarkerPageState extends State { }; late final customMarkers = [ - buildPin(const LatLng(51.51868093513547, -0.12835376940892318)), - buildPin(const LatLng(53.33360293799854, -6.284001062079881)), + buildPin(const (lat: 51.51868093513547, lon: 0.12835376940892318)), + buildPin(const (lat: 53.33360293799854, lon: 6.284001062079881)), ]; Marker buildPin(LatLng point) => Marker( @@ -107,7 +109,7 @@ class _MarkerPageState extends State { Flexible( child: FlutterMap( options: MapOptions( - initialCenter: const LatLng(51.5, -0.09), + initialCenter: const (lat: 51.5, lon: 0.09), initialZoom: 5, onTap: (_, p) => setState(() => customMarkers.add(buildPin(p))), interactionOptions: const InteractionOptions( @@ -120,7 +122,7 @@ class _MarkerPageState extends State { rotate: counterRotate, markers: const [ Marker( - point: LatLng(47.18664724067855, -1.5436768515939427), + point: (lat: 47.18664724067855, lon: 1.5436768515939427), width: 64, height: 64, alignment: Alignment.centerLeft, @@ -133,7 +135,7 @@ class _MarkerPageState extends State { ), ), Marker( - point: LatLng(47.18664724067855, -1.5436768515939427), + point: (lat: 47.18664724067855, lon: 1.5436768515939427), width: 64, height: 64, alignment: Alignment.centerRight, @@ -146,7 +148,7 @@ class _MarkerPageState extends State { ), ), Marker( - point: LatLng(47.18664724067855, -1.5436768515939427), + point: (lat: 47.18664724067855, lon: 1.5436768515939427), rotate: false, child: ColoredBox(color: Colors.black), ), diff --git a/example/lib/pages/moving_markers.dart b/example/lib/pages/moving_markers.dart index 5d80dedeb..ee1a0f5d1 100644 --- a/example/lib/pages/moving_markers.dart +++ b/example/lib/pages/moving_markers.dart @@ -23,19 +23,19 @@ class MovingMarkersPageState extends State { Marker( width: 80, height: 80, - point: LatLng(51.5, -0.09), + point: (lat: 51.5, lon: 0.09), child: FlutterLogo(), ), Marker( width: 80, height: 80, - point: LatLng(53.3498, -6.2603), + point: (lat: 53.3498, lon: 6.2603), child: FlutterLogo(), ), Marker( width: 80, height: 80, - point: LatLng(48.8566, 2.3522), + point: (lat: 48.8566, lon: 2.3522), child: FlutterLogo(), ), ]; @@ -65,7 +65,7 @@ class MovingMarkersPageState extends State { drawer: const MenuDrawer(MovingMarkersPage.route), body: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, ), children: [ diff --git a/example/lib/pages/overlay_image.dart b/example/lib/pages/overlay_image.dart index e79b3457a..45a2e3f50 100644 --- a/example/lib/pages/overlay_image.dart +++ b/example/lib/pages/overlay_image.dart @@ -15,7 +15,7 @@ class OverlayImagePage extends StatelessWidget { drawer: const MenuDrawer(route), body: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 6, ), children: [ @@ -24,17 +24,17 @@ class OverlayImagePage extends StatelessWidget { overlayImages: [ OverlayImage( bounds: LatLngBounds( - const LatLng(51.5, -0.09), - const LatLng(48.8566, 2.3522), + const (lat: 51.5, lon: 0.09), + const (lat: 48.8566, lon: 2.3522), ), opacity: 0.8, imageProvider: const NetworkImage( 'https://images.pexels.com/photos/231009/pexels-photo-231009.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=300&w=600'), ), const RotatedOverlayImage( - topLeftCorner: LatLng(53.377, -2.999), - bottomLeftCorner: LatLng(52.503, -1.868), - bottomRightCorner: LatLng(53.475, 0.275), + topLeftCorner: (lat: 53.377, lon: 2.999), + bottomLeftCorner: (lat: 52.503, lon: 1.868), + bottomRightCorner: (lat: 53.475, lon: 0.275), opacity: 0.8, imageProvider: NetworkImage( 'https://images.pexels.com/photos/231009/pexels-photo-231009.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=300&w=600'), @@ -44,15 +44,15 @@ class OverlayImagePage extends StatelessWidget { const MarkerLayer( markers: [ Marker( - point: LatLng(53.377, -2.999), + point: (lat: 53.377, lon: 2.999), child: _Circle(color: Colors.redAccent, label: 'TL'), ), Marker( - point: LatLng(52.503, -1.868), + point: (lat: 52.503, lon: 1.868), child: _Circle(color: Colors.redAccent, label: 'BL'), ), Marker( - point: LatLng(53.475, 0.275), + point: (lat: 53.475, lon: 0.275), child: _Circle(color: Colors.redAccent, label: 'BR'), ), ], diff --git a/example/lib/pages/polygon.dart b/example/lib/pages/polygon.dart index e16418ef4..a91293f0e 100644 --- a/example/lib/pages/polygon.dart +++ b/example/lib/pages/polygon.dart @@ -10,58 +10,58 @@ class PolygonPage extends StatelessWidget { @override Widget build(BuildContext context) { - final notFilledPoints = [ - const LatLng(51.5, -0.09), - const LatLng(53.3498, -6.2603), - const LatLng(48.8566, 2.3522), + const notFilledPoints = [ + (lat: 51.5, lon: -0.09), + (lat: 53.3498, lon: -6.2603), + (lat: 48.8566, lon: 2.3522), ]; final filledPoints = [ - const LatLng(55.5, -0.09), - const LatLng(54.3498, -6.2603), - const LatLng(52.8566, 2.3522), + (lat: 55.5, lon: -0.09), + (lat: 54.3498, lon: -6.2603), + (lat: 52.8566, lon: 2.3522), ]; final notFilledDotedPoints = [ - const LatLng(49.29, -2.57), - const LatLng(51.46, -6.43), - const LatLng(49.86, -8.17), - const LatLng(48.39, -3.49), + const (lat: 49.29, lon: 2.57), + const (lat: 51.46, lon: 6.43), + const (lat: 49.86, lon: 8.17), + const (lat: 48.39, lon: 3.49), ]; final filledDotedPoints = [ - const LatLng(46.35, 4.94), - const LatLng(46.22, -0.11), - const LatLng(44.399, 1.76), + const (lat: 46.35, lon: 4.94), + const (lat: 46.22, lon: 0.11), + const (lat: 44.399, lon: 1.76), ]; final labelPoints = [ - const LatLng(60.16, -9.38), - const LatLng(60.16, -4.16), - const LatLng(61.18, -4.16), - const LatLng(61.18, -9.38), + const (lat: 60.16, lon: 9.38), + const (lat: 60.16, lon: 4.16), + const (lat: 61.18, lon: 4.16), + const (lat: 61.18, lon: 9.38), ]; final labelRotatedPoints = [ - const LatLng(59.77, -10.28), - const LatLng(58.21, -10.28), - const LatLng(58.21, -7.01), - const LatLng(59.77, -7.01), - const LatLng(60.77, -6.01), + const (lat: 59.77, lon: 10.28), + const (lat: 58.21, lon: 10.28), + const (lat: 58.21, lon: 7.01), + const (lat: 59.77, lon: 7.01), + const (lat: 60.77, lon: 6.01), ]; final holeOuterPoints = [ - const LatLng(50, -18), - const LatLng(50, -14), - const LatLng(54, -14), - const LatLng(54, -18), + const (lat: 50, lon: 18), + const (lat: 50, lon: 14), + const (lat: 54, lon: 14), + const (lat: 54, lon: 18), ]; final holeInnerPoints = [ - const LatLng(51, -17), - const LatLng(51, -16), - const LatLng(52, -16), - const LatLng(52, -17), + const (lat: 51, lon: 17), + const (lat: 51, lon: 16), + const (lat: 52, lon: 16), + const (lat: 52, lon: 17), ]; return Scaffold( @@ -69,7 +69,7 @@ class PolygonPage extends StatelessWidget { drawer: const MenuDrawer(PolygonPage.route), body: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, ), children: [ @@ -130,15 +130,13 @@ class PolygonPage extends StatelessWidget { ), Polygon( points: holeOuterPoints - .map( - (latlng) => LatLng(latlng.latitude, latlng.longitude + 8)) + .map((latlng) => (lat: latlng.lat, lon: latlng.lon + 8)) .toList(), isFilled: false, isDotted: true, holePointsList: [ holeInnerPoints - .map((latlng) => - LatLng(latlng.latitude, latlng.longitude + 8)) + .map((latlng) => (lat: latlng.lat, lon: latlng.lon + 8)) .toList() ], borderStrokeWidth: 4, diff --git a/example/lib/pages/polyline.dart b/example/lib/pages/polyline.dart index 9cecc5fb8..8dc9f1875 100644 --- a/example/lib/pages/polyline.dart +++ b/example/lib/pages/polyline.dart @@ -20,7 +20,7 @@ class _PolylinePageState extends State { drawer: const MenuDrawer(PolylinePage.route), body: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, ), children: [ @@ -29,18 +29,18 @@ class _PolylinePageState extends State { polylines: [ Polyline( points: [ - const LatLng(51.5, -0.09), - const LatLng(53.3498, -6.2603), - const LatLng(48.8566, 2.3522), + const (lat: 51.5, lon: 0.09), + const (lat: 53.3498, lon: 6.2603), + const (lat: 48.8566, lon: 2.3522), ], strokeWidth: 4, color: Colors.purple, ), Polyline( points: [ - const LatLng(55.5, -0.09), - const LatLng(54.3498, -6.2603), - const LatLng(52.8566, 2.3522), + const (lat: 55.5, lon: 0.09), + const (lat: 54.3498, lon: 6.2603), + const (lat: 52.8566, lon: 2.3522), ], strokeWidth: 4, gradientColors: [ @@ -51,9 +51,9 @@ class _PolylinePageState extends State { ), Polyline( points: [ - const LatLng(50.5, -0.09), - const LatLng(51.3498, 6.2603), - const LatLng(53.8566, 2.3522), + const (lat: 50.5, lon: 0.09), + const (lat: 51.3498, lon: 6.2603), + const (lat: 53.8566, lon: 2.3522), ], strokeWidth: 20, color: Colors.blue.withOpacity(0.6), @@ -62,9 +62,9 @@ class _PolylinePageState extends State { ), Polyline( points: [ - const LatLng(50.2, -0.08), - const LatLng(51.2498, -10.2603), - const LatLng(54.8566, -9.3522), + const (lat: 50.2, lon: 0.08), + const (lat: 51.2498, lon: 10.2603), + const (lat: 54.8566, lon: 9.3522), ], strokeWidth: 20, color: Colors.black.withOpacity(0.2), @@ -73,9 +73,9 @@ class _PolylinePageState extends State { ), Polyline( points: [ - const LatLng(49.1, -0.06), - const LatLng(52.15, -1.4), - const LatLng(55.5, 0.8), + const (lat: 49.1, lon: 0.06), + const (lat: 52.15, lon: 1.4), + const (lat: 55.5, lon: 0.8), ], strokeWidth: 10, color: Colors.yellow, @@ -84,9 +84,9 @@ class _PolylinePageState extends State { ), Polyline( points: [ - const LatLng(48.1, -0.03), - const LatLng(50.5, -7.8), - const LatLng(56.5, 0.4), + const (lat: 48.1, lon: 0.03), + const (lat: 50.5, lon: 7.8), + const (lat: 56.5, lon: 0.4), ], strokeWidth: 10, color: Colors.amber, diff --git a/example/lib/pages/reset_tile_layer.dart b/example/lib/pages/reset_tile_layer.dart index 3e80e5ea2..475a1d79b 100644 --- a/example/lib/pages/reset_tile_layer.dart +++ b/example/lib/pages/reset_tile_layer.dart @@ -53,7 +53,7 @@ class ResetTileLayerPageState extends State { Flexible( child: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, ), children: [ @@ -69,7 +69,7 @@ class ResetTileLayerPageState extends State { Marker( width: 80, height: 80, - point: LatLng(51.5, -0.09), + point: (lat: 51.5, lon: 0.09), child: FlutterLogo(), ), ], diff --git a/example/lib/pages/retina.dart b/example/lib/pages/retina.dart index 75aa02dbb..91626d503 100644 --- a/example/lib/pages/retina.dart +++ b/example/lib/pages/retina.dart @@ -143,7 +143,7 @@ class _RetinaPageState extends State { Expanded( child: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, maxZoom: 19, ), diff --git a/example/lib/pages/scalebar_utils.dart b/example/lib/pages/scalebar_utils.dart index 97f57ef1c..c03c21c43 100644 --- a/example/lib/pages/scalebar_utils.dart +++ b/example/lib/pages/scalebar_utils.dart @@ -25,7 +25,7 @@ LatLng calculateEndingGlobalCoordinates( const aSquared = a * a; const bSquared = b * b; const f = mFlattening; - final phi1 = toRadians(start.latitude); + final phi1 = toRadians(start.lat); final alpha1 = toRadians(startBearing); final cosAlpha1 = cos(alpha1); final sinAlpha1 = sin(alpha1); @@ -137,8 +137,8 @@ LatLng calculateEndingGlobalCoordinates( // cosSigma * cosAlpha1); // build result - return LatLng( - clampDouble(toDegrees(phi2), -90, 90), - clampDouble(start.longitude + toDegrees(L), -180, 180), + return ( + lat: clampDouble(toDegrees(phi2), -90, 90), + lon: clampDouble(start.lon + toDegrees(L), -180, 180), ); } diff --git a/example/lib/pages/screen_point_to_latlng.dart b/example/lib/pages/screen_point_to_latlng.dart index b7b77884a..ff8319930 100644 --- a/example/lib/pages/screen_point_to_latlng.dart +++ b/example/lib/pages/screen_point_to_latlng.dart @@ -39,7 +39,7 @@ class PointToLatlngPage extends State { mapController: mapController, options: MapOptions( onPositionChanged: (_, __) => updatePoint(context), - initialCenter: const LatLng(51.5, -0.09), + initialCenter: const (lat: 51.5, lon: 0.09), initialZoom: 5, minZoom: 3, ), @@ -79,7 +79,7 @@ class PointToLatlngPage extends State { right: 0, child: IgnorePointer( child: Text( - '(${latLng?.latitude.toStringAsFixed(3)},${latLng?.longitude.toStringAsFixed(3)})', + '(${latLng?.lat.toStringAsFixed(3)},${latLng?.lon.toStringAsFixed(3)})', textAlign: TextAlign.center, style: const TextStyle( color: Colors.black, diff --git a/example/lib/pages/secondary_tap.dart b/example/lib/pages/secondary_tap.dart index 220b56f60..ec4d8fa4e 100644 --- a/example/lib/pages/secondary_tap.dart +++ b/example/lib/pages/secondary_tap.dart @@ -27,7 +27,7 @@ class SecondaryTapPage extends StatelessWidget { SnackBar(content: Text('Secondary tap at $latLng')), ); }, - initialCenter: const LatLng(51.5, -0.09), + initialCenter: const (lat: 51.5, lon: 0.09), initialZoom: 5, ), children: [openStreetMapTileLayer], diff --git a/example/lib/pages/sliding_map.dart b/example/lib/pages/sliding_map.dart index dcf6f8a5a..bd59fc170 100644 --- a/example/lib/pages/sliding_map.dart +++ b/example/lib/pages/sliding_map.dart @@ -4,8 +4,8 @@ import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; class SlidingMapPage extends StatelessWidget { static const String route = '/sliding_map'; - static const northEast = LatLng(56.7378, 11.6644); - static const southWest = LatLng(56.6877, 11.5089); + static const northEast = (lat: 56.7378, lon: 11.6644); + static const southWest = (lat: 56.6877, lon: 11.5089); const SlidingMapPage({super.key}); @@ -26,7 +26,7 @@ class SlidingMapPage extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - initialCenter: const LatLng(56.704173, 11.543808), + initialCenter: const (lat: 56.704173, lon: 11.543808), minZoom: 12, maxZoom: 14, initialZoom: 13, diff --git a/example/lib/pages/stateful_markers.dart b/example/lib/pages/stateful_markers.dart index 2c44f9dc5..5c0d70f91 100644 --- a/example/lib/pages/stateful_markers.dart +++ b/example/lib/pages/stateful_markers.dart @@ -39,8 +39,10 @@ class StatefulMarkersPageState extends State { Marker( width: 40, height: 40, - point: LatLng( - _random.nextDouble() * 10 + 48, _random.nextDouble() * 10 - 6), + point: ( + lat: _random.nextDouble() * 10 + 48, + lon: _random.nextDouble() * 10 - 6 + ), child: _ColorMarker(), key: ValueKey(key), ), @@ -54,7 +56,7 @@ class StatefulMarkersPageState extends State { drawer: const MenuDrawer(StatefulMarkersPage.route), body: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, ), children: [ diff --git a/example/lib/pages/tile_builder.dart b/example/lib/pages/tile_builder.dart index 88ada2901..0ce35426d 100644 --- a/example/lib/pages/tile_builder.dart +++ b/example/lib/pages/tile_builder.dart @@ -110,7 +110,7 @@ class TileBuilderPageState extends State { Expanded( child: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, ), children: [ @@ -128,7 +128,7 @@ class TileBuilderPageState extends State { Marker( width: 80, height: 80, - point: LatLng(51.5, -0.09), + point: (lat: 51.5, lon: 0.09), child: FlutterLogo( key: ObjectKey(Colors.blue), ), diff --git a/example/lib/pages/tile_loading_error_handle.dart b/example/lib/pages/tile_loading_error_handle.dart index a2a53cc42..27bf99585 100644 --- a/example/lib/pages/tile_loading_error_handle.dart +++ b/example/lib/pages/tile_loading_error_handle.dart @@ -38,7 +38,7 @@ class TileLoadingErrorHandleState extends State { child: Builder(builder: (context) { return FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: 0.09), initialZoom: 5, ), children: [ diff --git a/example/lib/pages/wms_tile_layer.dart b/example/lib/pages/wms_tile_layer.dart index 49f1a6e7e..e6dc6c0c4 100644 --- a/example/lib/pages/wms_tile_layer.dart +++ b/example/lib/pages/wms_tile_layer.dart @@ -15,7 +15,7 @@ class WMSLayerPage extends StatelessWidget { drawer: const MenuDrawer(route), body: FlutterMap( options: const MapOptions( - initialCenter: LatLng(42.58, 12.43), + initialCenter: (lat: 42.58, lon: 12.43), initialZoom: 6, ), children: [ diff --git a/example/lib/plugins/plugin_scalebar.dart b/example/lib/plugins/plugin_scalebar.dart index 646675071..b598faa2e 100644 --- a/example/lib/plugins/plugin_scalebar.dart +++ b/example/lib/plugins/plugin_scalebar.dart @@ -17,7 +17,7 @@ class PluginScaleBar extends StatelessWidget { body: Flexible( child: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: -0.09), initialZoom: 5, ), children: [ diff --git a/example/lib/plugins/plugin_zoombuttons.dart b/example/lib/plugins/plugin_zoombuttons.dart index 12b5ff876..b773f9e12 100644 --- a/example/lib/plugins/plugin_zoombuttons.dart +++ b/example/lib/plugins/plugin_zoombuttons.dart @@ -16,7 +16,7 @@ class PluginZoomButtons extends StatelessWidget { drawer: const MenuDrawer(PluginZoomButtons.route), body: FlutterMap( options: const MapOptions( - initialCenter: LatLng(51.5, -0.09), + initialCenter: (lat: 51.5, lon: -0.09), initialZoom: 5, ), children: [ diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 312a4bdab..5e723db86 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -17,6 +17,7 @@ dependencies: shared_preferences: ^2.2.1 url_strategy: ^0.2.0 http: ^1.1.0 + latlong2: ^0.9.0 dependency_overrides: flutter_map_cancellable_tile_provider: diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index 907eee917..dbb001d43 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -17,6 +17,7 @@ library flutter_map; export 'package:flutter_map/src/geo/crs.dart'; +export 'package:flutter_map/src/geo/latlng.dart'; export 'package:flutter_map/src/geo/latlng_bounds.dart'; export 'package:flutter_map/src/gestures/interactive_flag.dart'; export 'package:flutter_map/src/gestures/latlng_tween.dart'; @@ -59,5 +60,4 @@ export 'package:flutter_map/src/misc/bounds.dart'; export 'package:flutter_map/src/misc/center_zoom.dart'; export 'package:flutter_map/src/misc/move_and_rotate_result.dart'; export 'package:flutter_map/src/misc/point_extensions.dart'; -export 'package:flutter_map/src/misc/position.dart'; -export 'package:latlong2/latlong.dart'; +export 'package:flutter_map/src/misc/position.dart'; \ No newline at end of file diff --git a/lib/src/geo/crs.dart b/lib/src/geo/crs.dart index b78b04f2b..e305c2809 100644 --- a/lib/src/geo/crs.dart +++ b/lib/src/geo/crs.dart @@ -1,8 +1,8 @@ import 'dart:math' as math hide Point; import 'dart:math' show Point; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/misc/bounds.dart'; -import 'package:latlong2/latlong.dart'; import 'package:meta/meta.dart'; import 'package:proj4dart/proj4dart.dart' as proj4; @@ -116,7 +116,7 @@ class Epsg3857 extends Earth { transformation = const Transformation(_scale, 0.5, -_scale, 0.5), super(); -// Epsg3857 seems to have latitude limits. https://epsg.io/3857 +// Epsg3857 seems to have lat limits. https://epsg.io/3857 //@override //(double, double) get wrapLat => const (-85.06, 85.06); } @@ -355,13 +355,15 @@ class _LonLat extends Projection { @override Point project(LatLng latlng) { - return Point(latlng.longitude, latlng.latitude); + return Point(latlng.lon, latlng.lat); } @override LatLng unproject(Point point) { - return LatLng( - inclusiveLat(point.y.toDouble()), inclusiveLng(point.x.toDouble())); + return ( + lat: inclusiveLat(point.y.toDouble()), + lon: inclusiveLng(point.x.toDouble()) + ); } } @@ -383,11 +385,11 @@ class SphericalMercator extends Projection { @override Point project(LatLng latlng) { const d = math.pi / 180; - final lat = latlng.latitude.clamp(-maxLatitude, maxLatitude); + final lat = latlng.lat.clamp(-maxLatitude, maxLatitude); final sin = math.sin(lat * d); return Point( - r * d * latlng.longitude, + r * d * latlng.lon, r / 2 * math.log((1 + sin) / (1 - sin)), ); } @@ -395,10 +397,11 @@ class SphericalMercator extends Projection { @override LatLng unproject(Point point) { const d = 180 / math.pi; - return LatLng( - inclusiveLat( - (2 * math.atan(math.exp(point.y / r)) - (math.pi / 2)) * d), - inclusiveLng(point.x * d / r)); + return ( + lat: inclusiveLat( + (2 * math.atan(math.exp(point.y / r)) - (math.pi / 2)) * d), + lon: inclusiveLng(point.x * d / r) + ); } } @@ -419,7 +422,7 @@ class _Proj4Projection extends Projection { @override Point project(LatLng latlng) { final point = epsg4326.transform( - proj4Projection, proj4.Point(x: latlng.longitude, y: latlng.latitude)); + proj4Projection, proj4.Point(x: latlng.lon, y: latlng.lat)); return Point(point.x, point.y); } @@ -429,7 +432,7 @@ class _Proj4Projection extends Projection { final point2 = proj4Projection.transform( epsg4326, proj4.Point(x: point.x.toDouble(), y: point.y.toDouble())); - return LatLng(inclusiveLat(point2.y), inclusiveLng(point2.x)); + return (lat: inclusiveLat(point2.y), lon: inclusiveLng(point2.x)); } } diff --git a/lib/src/geo/latlng.dart b/lib/src/geo/latlng.dart new file mode 100644 index 000000000..b3a731684 --- /dev/null +++ b/lib/src/geo/latlng.dart @@ -0,0 +1,7 @@ +typedef LatLng = ({double lat, double lon}); + + +// use degrees2Radians from vector_math + +// regex to migrate: LatLng\((-*[0-9]+\.*[0-9]*), *-*([0-9]+\.*[0-9]*)\) +// replace with: (lat: $1, lon: $2) \ No newline at end of file diff --git a/lib/src/geo/latlng_bounds.dart b/lib/src/geo/latlng_bounds.dart index 72f664ae9..c800ac866 100644 --- a/lib/src/geo/latlng_bounds.dart +++ b/lib/src/geo/latlng_bounds.dart @@ -1,6 +1,7 @@ import 'dart:math' as math; -import 'package:latlong2/latlong.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; +import 'package:vector_math/vector_math_64.dart'; /// Data structure representing rectangular bounding box constrained by its /// northwest and southeast corners @@ -24,14 +25,14 @@ class LatLngBounds { double maxY = -90; for (final point in points) { - minX = math.min(minX, point.longitude); - minY = math.min(minY, point.latitude); - maxX = math.max(maxX, point.longitude); - maxY = math.max(maxY, point.latitude); + minX = math.min(minX, point.lon); + minY = math.min(minY, point.lat); + maxX = math.max(maxX, point.lon); + maxY = math.max(maxY, point.lat); } - _sw = LatLng(minY, minX); - _ne = LatLng(maxY, maxX); + _sw = (lat: minY, lon: minX); + _ne = (lat: maxY, lon: maxX); } /// Expands bounding box by [latLng] coordinate point. This method mutates @@ -48,27 +49,27 @@ class LatLngBounds { } void _extend(LatLng sw2, LatLng ne2) { - _sw = LatLng( - math.min(sw2.latitude, _sw.latitude), - math.min(sw2.longitude, _sw.longitude), + _sw = ( + lat: math.min(sw2.lat, _sw.lat), + lon: math.min(sw2.lon, _sw.lon), ); - _ne = LatLng( - math.max(ne2.latitude, _ne.latitude), - math.max(ne2.longitude, _ne.longitude), + _ne = ( + lat: math.max(ne2.lat, _ne.lat), + lon: math.max(ne2.lon, _ne.lon), ); } /// Obtain west edge of the bounds - double get west => southWest.longitude; + double get west => southWest.lon; /// Obtain south edge of the bounds - double get south => southWest.latitude; + double get south => southWest.lat; /// Obtain east edge of the bounds - double get east => northEast.longitude; + double get east => northEast.lon; /// Obtain north edge of the bounds - double get north => northEast.latitude; + double get north => northEast.lat; /// Obtain coordinates of southwest corner of the bounds LatLng get southWest => _sw; @@ -77,10 +78,10 @@ class LatLngBounds { LatLng get northEast => _ne; /// Obtain coordinates of northwest corner of the bounds - LatLng get northWest => LatLng(north, west); + LatLng get northWest => (lat: north, lon: west); /// Obtain coordinates of southeast corner of the bounds - LatLng get southEast => LatLng(south, east); + LatLng get southEast => (lat: south, lon: east); /// Obtain coordinates of the bounds center LatLng get center { @@ -94,12 +95,12 @@ class LatLngBounds { lambda: lng */ - final phi1 = southWest.latitudeInRad; - final lambda1 = southWest.longitudeInRad; - final phi2 = northEast.latitudeInRad; + final phi1 = southWest.lat * degrees2Radians; + final lambda1 = southWest.lon * degrees2Radians; + final phi2 = northEast.lat * degrees2Radians; - final dLambda = degToRadian(northEast.longitude - - southWest.longitude); // delta lambda = lambda2-lambda1 + final dLambda = degrees2Radians * ( + northEast.lon - southWest.lon); // delta lambda = lambda2-lambda1 final bx = math.cos(phi2) * math.cos(dLambda); final by = math.cos(phi2) * math.sin(dLambda); @@ -108,7 +109,7 @@ class LatLngBounds { final lambda3 = lambda1 + math.atan2(by, math.cos(phi1) + bx); // phi3 and lambda3 are actually in radians and LatLng wants degrees - return LatLng(radianToDeg(phi3), radianToDeg(lambda3)); + return (lat: radians2Degrees * phi3, lon: radians2Degrees * lambda3); } /// Checks whether [point] is inside bounds @@ -122,10 +123,10 @@ class LatLngBounds { bool containsBounds(LatLngBounds bounds) { final sw2 = bounds._sw; final ne2 = bounds._ne; - return (sw2.latitude >= _sw.latitude) && - (ne2.latitude <= _ne.latitude) && - (sw2.longitude >= _sw.longitude) && - (ne2.longitude <= _ne.longitude); + return (sw2.lat >= _sw.lat) && + (ne2.lat <= _ne.lat) && + (sw2.lon >= _sw.lon) && + (ne2.lon <= _ne.lon); } /// Checks whether at least one edge of [bounds] is overlapping with some @@ -134,10 +135,10 @@ class LatLngBounds { /* check if bounding box rectangle is outside the other, if it is then it's considered not overlapping */ - if (_sw.latitude > bounds._ne.latitude || - _ne.latitude < bounds._sw.latitude || - _ne.longitude < bounds._sw.longitude || - _sw.longitude > bounds._ne.longitude) { + if (_sw.lat > bounds._ne.lat || + _ne.lat < bounds._sw.lat || + _ne.lon < bounds._sw.lon || + _sw.lon > bounds._ne.lon) { return false; } return true; diff --git a/lib/src/gestures/flutter_map_interactive_viewer.dart b/lib/src/gestures/flutter_map_interactive_viewer.dart index 083deac33..2a3421767 100644 --- a/lib/src/gestures/flutter_map_interactive_viewer.dart +++ b/lib/src/gestures/flutter_map_interactive_viewer.dart @@ -4,6 +4,7 @@ import 'dart:math' as math; import 'package:flutter/gestures.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/gestures/interactive_flag.dart'; import 'package:flutter_map/src/gestures/latlng_tween.dart'; import 'package:flutter_map/src/gestures/map_events.dart'; @@ -15,7 +16,7 @@ import 'package:flutter_map/src/map/options/cursor_keyboard_rotation.dart'; import 'package:flutter_map/src/map/options/interaction.dart'; import 'package:flutter_map/src/map/options/options.dart'; import 'package:flutter_map/src/misc/point_extensions.dart'; -import 'package:latlong2/latlong.dart'; +import 'package:vector_math/vector_math_64.dart'; typedef InteractiveViewerBuilder = Widget Function( BuildContext context, @@ -500,7 +501,7 @@ class FlutterMapInteractiveViewerState return; } - final currentRotation = radianToDeg(details.rotation); + final currentRotation = radians2Degrees * (details.rotation); if (_dragMode) { _handleScaleDragUpdate(details); } else if (InteractiveFlag.hasMultiFinger(_interactionOptions.flags)) { @@ -660,7 +661,7 @@ class FlutterMapInteractiveViewerState final rotationCenter = _camera.project(_camera.offsetToCrs(_lastFocalLocal)); final vector = oldCenterPt - rotationCenter; - final rotatedVector = vector.rotate(degToRadian(rotationDiff)); + final rotatedVector = vector.rotate(degrees2Radians * rotationDiff); final newCenter = rotationCenter + rotatedVector; widget.controller.moveAndRotate( diff --git a/lib/src/gestures/latlng_tween.dart b/lib/src/gestures/latlng_tween.dart index 145778da8..69ebe687f 100644 --- a/lib/src/gestures/latlng_tween.dart +++ b/lib/src/gestures/latlng_tween.dart @@ -1,13 +1,13 @@ import 'package:flutter/animation.dart'; -import 'package:latlong2/latlong.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; class LatLngTween extends Tween { LatLngTween({required LatLng begin, required LatLng end}) : super(begin: begin, end: end); @override - LatLng lerp(double t) => LatLng( - begin!.latitude + (end!.latitude - begin!.latitude) * t, - begin!.longitude + (end!.longitude - begin!.longitude) * t, + LatLng lerp(double t) => ( + lat: begin!.lat + (end!.lat - begin!.lat) * t, + lon: begin!.lon + (end!.lon - begin!.lon) * t, ); } diff --git a/lib/src/gestures/map_events.dart b/lib/src/gestures/map_events.dart index 03ce4eba2..f7fa1ce8b 100644 --- a/lib/src/gestures/map_events.dart +++ b/lib/src/gestures/map_events.dart @@ -1,5 +1,5 @@ +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; -import 'package:latlong2/latlong.dart'; import 'package:meta/meta.dart'; /// Event sources which are used to identify different types of diff --git a/lib/src/layer/circle_layer.dart b/lib/src/layer/circle_layer.dart index 354e72ad5..ec327bc69 100644 --- a/lib/src/layer/circle_layer.dart +++ b/lib/src/layer/circle_layer.dart @@ -1,9 +1,10 @@ import 'dart:ui'; import 'package:flutter/widgets.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/layer/general/mobile_layer_transformer.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; -import 'package:latlong2/latlong.dart' hide Path; +import 'package:latlong2/latlong.dart' as latlong2; /// Immutable marker options for circle markers @immutable @@ -55,7 +56,7 @@ class CirclePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - const distance = Distance(); + const distance = latlong2.Distance(); final rect = Offset.zero & size; canvas.clipRect(rect); @@ -67,8 +68,12 @@ class CirclePainter extends CustomPainter { final offset = map.getOffsetFromOrigin(circle.point); double radius = circle.radius; if (circle.useRadiusInMeter) { - final r = distance.offset(circle.point, circle.radius, 180); - final delta = offset - map.getOffsetFromOrigin(r); + final r = distance.offset( + latlong2.LatLng(circle.point.lat, circle.point.lon), + circle.radius, + 180); + final delta = offset - + map.getOffsetFromOrigin((lat: r.latitude, lon: r.longitude)); radius = delta.distance; } points[circle.color] ??= {}; @@ -81,8 +86,13 @@ class CirclePainter extends CustomPainter { if (circle.color.alpha == 0xFF) { double radiusBorder = circle.radius + circle.borderStrokeWidth; if (circle.useRadiusInMeter) { - final rBorder = distance.offset(circle.point, radiusBorder, 180); - final deltaBorder = offset - map.getOffsetFromOrigin(rBorder); + final rBorder = distance.offset( + latlong2.LatLng(circle.point.lat, circle.point.lon), + radiusBorder, + 180); + final deltaBorder = offset - + map.getOffsetFromOrigin( + (lat: rBorder.latitude, lon: rBorder.longitude)); radiusBorder = deltaBorder.distance; } pointsFilledBorder[circle.borderColor] ??= {}; @@ -91,8 +101,13 @@ class CirclePainter extends CustomPainter { } else { double realRadius = circle.radius; if (circle.useRadiusInMeter) { - final rBorder = distance.offset(circle.point, realRadius, 180); - final deltaBorder = offset - map.getOffsetFromOrigin(rBorder); + final rBorder = distance.offset( + latlong2.LatLng(circle.point.lat, circle.point.lon), + realRadius, + 180); + final deltaBorder = offset - + map.getOffsetFromOrigin( + (lat: rBorder.latitude, lon: rBorder.longitude)); realRadius = deltaBorder.distance; } pointsBorder[circle.borderColor] ??= {}; diff --git a/lib/src/layer/marker_layer.dart b/lib/src/layer/marker_layer.dart index 6b8e231a3..dfbcf5b4d 100644 --- a/lib/src/layer/marker_layer.dart +++ b/lib/src/layer/marker_layer.dart @@ -1,10 +1,10 @@ import 'dart:math'; import 'package:flutter/widgets.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/layer/general/mobile_layer_transformer.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; import 'package:flutter_map/src/misc/bounds.dart'; -import 'package:latlong2/latlong.dart'; /// A container for a [child] widget located at a geographic coordinate [point] /// diff --git a/lib/src/layer/overlay_image_layer.dart b/lib/src/layer/overlay_image_layer.dart index a83a9f906..77cd67941 100644 --- a/lib/src/layer/overlay_image_layer.dart +++ b/lib/src/layer/overlay_image_layer.dart @@ -1,11 +1,11 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/geo/latlng_bounds.dart'; import 'package:flutter_map/src/layer/general/mobile_layer_transformer.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; import 'package:flutter_map/src/misc/bounds.dart'; import 'package:flutter_map/src/misc/point_extensions.dart'; -import 'package:latlong2/latlong.dart'; /// Base class for all overlay images. @immutable diff --git a/lib/src/layer/polygon_layer/label.dart b/lib/src/layer/polygon_layer/label.dart index ee3376a14..eccdf2c22 100644 --- a/lib/src/layer/polygon_layer/label.dart +++ b/lib/src/layer/polygon_layer/label.dart @@ -2,8 +2,8 @@ import 'dart:math' as math; import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/layer/polygon_layer/polygon_layer.dart'; -import 'package:latlong2/latlong.dart'; import 'package:polylabel/polylabel.dart'; void Function(Canvas canvas)? buildLabelTextPainter({ @@ -68,17 +68,18 @@ LatLng computeLabelPosition( } LatLng _computeCentroid(List points) { - return LatLng( - points.map((e) => e.latitude).average, - points.map((e) => e.longitude).average, + return ( + lat: points.map((e) => e.lat).average, + lon: points.map((e) => e.lon).average, ); } LatLng _computePolylabel(List points) { final labelPosition = polylabel( [ + //TODO does this really need to be changed to a math.Point type? List.generate(points.length, - (i) => math.Point(points[i].longitude, points[i].latitude)), + (i) => math.Point(points[i].lon, points[i].lat)), ], // "precision" is a bit of a misnomer. It's a threshold for when to stop // dividing-and-conquering the polygon in the hopes of finding a better @@ -87,8 +88,8 @@ LatLng _computePolylabel(List points) { // i.e. cheaper at the expense off less optimal label placement. precision: 0.000001, ); - return LatLng( - labelPosition.point.y.toDouble(), - labelPosition.point.x.toDouble(), + return ( + lat: labelPosition.point.y.toDouble(), + lon: labelPosition.point.x.toDouble(), ); } diff --git a/lib/src/layer/polygon_layer/polygon_layer.dart b/lib/src/layer/polygon_layer/polygon_layer.dart index ca5e7f578..f3676d864 100644 --- a/lib/src/layer/polygon_layer/polygon_layer.dart +++ b/lib/src/layer/polygon_layer/polygon_layer.dart @@ -1,12 +1,12 @@ import 'dart:ui' as ui; import 'package:flutter/widgets.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/geo/latlng_bounds.dart'; import 'package:flutter_map/src/layer/general/mobile_layer_transformer.dart'; import 'package:flutter_map/src/layer/polygon_layer/label.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; import 'package:flutter_map/src/misc/point_extensions.dart'; -import 'package:latlong2/latlong.dart' hide Path; // conflict with Path from UI enum PolygonLabelPlacement { centroid, @@ -19,7 +19,7 @@ bool isClockwise(List points) { final a = points[i]; final b = points[(i + 1) % points.length]; - sum += (b.longitude - a.longitude) * (b.latitude + a.latitude); + sum += (b.lon - a.lon) * (b.lat + a.lat); } return sum >= 0; } diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index b20de99f1..5d470023d 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -2,11 +2,12 @@ import 'dart:core'; import 'dart:ui' as ui; import 'package:flutter/widgets.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/geo/latlng_bounds.dart'; import 'package:flutter_map/src/layer/general/mobile_layer_transformer.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; import 'package:flutter_map/src/misc/point_extensions.dart'; -import 'package:latlong2/latlong.dart'; +import 'package:latlong2/latlong.dart' as latlong2; class Polyline { final List points; @@ -171,12 +172,13 @@ class PolylinePainter extends CustomPainter { if (polyline.useStrokeWidthInMeter) { final firstPoint = polyline.points.first; final firstOffset = offsets.first; - final r = const Distance().offset( - firstPoint, + final r = const latlong2.Distance().offset( + latlong2.LatLng(firstPoint.lat, firstPoint.lon), polyline.strokeWidth, 180, ); - final delta = firstOffset - getOffset(origin, r); + final delta = firstOffset - + getOffset(origin, (lat: r.latitude, lon: r.longitude)); strokeWidth = delta.distance; } else { diff --git a/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart b/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart index 122468ec7..5f0158571 100644 --- a/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart +++ b/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart @@ -3,7 +3,6 @@ import 'package:flutter_map/src/geo/latlng_bounds.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_range.dart'; import 'package:flutter_map/src/misc/bounds.dart'; -import 'package:latlong2/latlong.dart'; import 'package:meta/meta.dart'; @immutable @@ -127,10 +126,10 @@ class WrappedTileBounds extends TileBounds { (int, int)? wrapX; if (crs.wrapLng case final wrapLng?) { final wrapXMin = - (crs.latLngToPoint(LatLng(0, wrapLng.$1), zoomDouble).x / _tileSize) + (crs.latLngToPoint((lat: 0, lon: wrapLng.$1), zoomDouble).x / _tileSize) .floor(); final wrapXMax = - (crs.latLngToPoint(LatLng(0, wrapLng.$2), zoomDouble).x / _tileSize) + (crs.latLngToPoint((lat: 0, lon: wrapLng.$2), zoomDouble).x / _tileSize) .ceil(); wrapX = (wrapXMin, wrapXMax - 1); } @@ -138,10 +137,10 @@ class WrappedTileBounds extends TileBounds { (int, int)? wrapY; if (crs.wrapLat case final wrapLat?) { final wrapYMin = - (crs.latLngToPoint(LatLng(wrapLat.$1, 0), zoomDouble).y / _tileSize) + (crs.latLngToPoint((lat: wrapLat.$1, lon: 0), zoomDouble).y / _tileSize) .floor(); final wrapYMax = - (crs.latLngToPoint(LatLng(wrapLat.$2, 0), zoomDouble).y / _tileSize) + (crs.latLngToPoint((lat: wrapLat.$2, lon: 0), zoomDouble).y / _tileSize) .ceil(); wrapY = (wrapYMin, wrapYMax - 1); } diff --git a/lib/src/layer/tile_layer/tile_range_calculator.dart b/lib/src/layer/tile_layer/tile_range_calculator.dart index c30e70091..834863bf3 100644 --- a/lib/src/layer/tile_layer/tile_range_calculator.dart +++ b/lib/src/layer/tile_layer/tile_range_calculator.dart @@ -1,8 +1,8 @@ +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_range.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; import 'package:flutter_map/src/misc/bounds.dart'; import 'package:flutter_map/src/misc/point_extensions.dart'; -import 'package:latlong2/latlong.dart'; import 'package:meta/meta.dart'; @immutable diff --git a/lib/src/layer/tile_layer/tile_update_event.dart b/lib/src/layer/tile_layer/tile_update_event.dart index 64029eee7..575dfc4de 100644 --- a/lib/src/layer/tile_layer/tile_update_event.dart +++ b/lib/src/layer/tile_layer/tile_update_event.dart @@ -1,6 +1,6 @@ +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/gestures/map_events.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; -import 'package:latlong2/latlong.dart'; import 'package:meta/meta.dart'; /// Describes whether loading and/or pruning should occur and allows overriding diff --git a/lib/src/map/camera/camera.dart b/lib/src/map/camera/camera.dart index edf731b59..8556ef7e1 100644 --- a/lib/src/map/camera/camera.dart +++ b/lib/src/map/camera/camera.dart @@ -3,12 +3,13 @@ import 'dart:math' show Point; import 'package:flutter/material.dart'; import 'package:flutter_map/src/geo/crs.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/geo/latlng_bounds.dart'; import 'package:flutter_map/src/map/inherited_model.dart'; import 'package:flutter_map/src/map/options/options.dart'; import 'package:flutter_map/src/misc/bounds.dart'; import 'package:flutter_map/src/misc/point_extensions.dart'; -import 'package:latlong2/latlong.dart'; +import 'package:vector_math/vector_math_64.dart'; /// Describes the view of a map. This includes the size/zoom/position/crs as /// well as the minimum/maximum zoom. This class is mostly immutable but has @@ -53,9 +54,6 @@ class MapCamera { /// Lazily calculated field Point? _pixelOrigin; - /// Lazily calculated field - double? _rotationRad; - /// This is the [LatLngBounds] corresponding to four corners of this camera. /// This takes rotation in to account. LatLngBounds get visibleBounds => _bounds ??= LatLngBounds( @@ -105,12 +103,10 @@ class MapCamera { Bounds? pixelBounds, LatLngBounds? bounds, Point? pixelOrigin, - double? rotationRad, }) : _cameraSize = size, _pixelBounds = pixelBounds, _bounds = bounds, - _pixelOrigin = pixelOrigin, - _rotationRad = rotationRad; + _pixelOrigin = pixelOrigin; /// Initializes [MapCamera] from the given [options] and with the /// [nonRotatedSize] set to [kImpossibleSize]. @@ -135,7 +131,6 @@ class MapCamera { nonRotatedSize: nonRotatedSize, minZoom: minZoom, maxZoom: maxZoom, - rotationRad: _rotationRad, ); } @@ -171,7 +166,6 @@ class MapCamera { rotation: rotation, nonRotatedSize: nonRotatedSize, size: _cameraSize, - rotationRad: _rotationRad, ); } @@ -189,7 +183,6 @@ class MapCamera { rotation: rotation, nonRotatedSize: nonRotatedSize, size: _cameraSize, - rotationRad: _rotationRad, ); /// Calculates the size of a bounding box which surrounds a box of size @@ -200,7 +193,7 @@ class MapCamera { ) { if (rotation == 0.0) return nonRotatedSize; - final rotationRad = degToRadian(rotation); + final rotationRad = degrees2Radians * rotation; final cosAngle = math.cos(rotationRad).abs(); final sinAngle = math.sin(rotationRad).abs(); final width = (nonRotatedSize.x * cosAngle) + (nonRotatedSize.y * sinAngle); @@ -210,9 +203,8 @@ class MapCamera { return Point(width, height); } - /// The current rotation value in radians. This is calculated and cached when - /// it is first called. - double get rotationRad => _rotationRad ??= degToRadian(rotation); + /// The current rotation value in radians. + double get rotationRad => degrees2Radians * rotation; /// Calculates point value for the given [latLng] using this camera's /// [crs] and [zoom] (or the provided [zoom]). diff --git a/lib/src/map/camera/camera_constraint.dart b/lib/src/map/camera/camera_constraint.dart index 6ece003d1..63390a685 100644 --- a/lib/src/map/camera/camera_constraint.dart +++ b/lib/src/map/camera/camera_constraint.dart @@ -5,7 +5,6 @@ import 'package:flutter_map/src/geo/latlng_bounds.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; import 'package:flutter_map/src/map/camera/camera_fit.dart'; import 'package:flutter_map/src/misc/point_extensions.dart'; -import 'package:latlong2/latlong.dart'; import 'package:meta/meta.dart'; /// Describes a boundary for a [MapCamera], that cannot be exceeded by movement @@ -73,12 +72,12 @@ class ContainCameraCenter extends CameraConstraint { @override MapCamera constrain(MapCamera camera) => camera.withPosition( - center: LatLng( - camera.center.latitude.clamp( + center: ( + lat: camera.center.lat.clamp( bounds.south, bounds.north, ), - camera.center.longitude.clamp( + lon: camera.center.lon.clamp( bounds.west, bounds.east, ), diff --git a/lib/src/map/camera/camera_fit.dart b/lib/src/map/camera/camera_fit.dart index 0e337ed9a..d59bc1de1 100644 --- a/lib/src/map/camera/camera_fit.dart +++ b/lib/src/map/camera/camera_fit.dart @@ -2,12 +2,12 @@ import 'dart:math' as math hide Point; import 'dart:math' show Point; import 'package:flutter/widgets.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/geo/latlng_bounds.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; import 'package:flutter_map/src/map/camera/camera_constraint.dart'; import 'package:flutter_map/src/misc/bounds.dart'; import 'package:flutter_map/src/misc/point_extensions.dart'; -import 'package:latlong2/latlong.dart'; /// Describes a position for a [MapCamera] /// diff --git a/lib/src/map/controller/impl.dart b/lib/src/map/controller/impl.dart index 900cacff6..0bd11d325 100644 --- a/lib/src/map/controller/impl.dart +++ b/lib/src/map/controller/impl.dart @@ -2,13 +2,13 @@ import 'dart:async'; import 'dart:math'; import 'package:flutter/widgets.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/gestures/map_events.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; import 'package:flutter_map/src/map/camera/camera_fit.dart'; import 'package:flutter_map/src/map/controller/internal.dart'; import 'package:flutter_map/src/map/controller/map_controller.dart'; import 'package:flutter_map/src/misc/move_and_rotate_result.dart'; -import 'package:latlong2/latlong.dart'; /// Implements [MapController] whilst exposing methods for internal use which /// should not be visible to the user (e.g. for setting the current camera or diff --git a/lib/src/map/controller/internal.dart b/lib/src/map/controller/internal.dart index 6746c5ab8..1ef11c4d6 100644 --- a/lib/src/map/controller/internal.dart +++ b/lib/src/map/controller/internal.dart @@ -2,6 +2,7 @@ import 'dart:math'; import 'package:flutter/foundation.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/gestures/flutter_map_interactive_viewer.dart'; import 'package:flutter_map/src/gestures/map_events.dart'; import 'package:flutter_map/src/gestures/positioned_tap_detector_2.dart'; @@ -12,7 +13,7 @@ import 'package:flutter_map/src/map/options/options.dart'; import 'package:flutter_map/src/misc/move_and_rotate_result.dart'; import 'package:flutter_map/src/misc/point_extensions.dart'; import 'package:flutter_map/src/misc/position.dart'; -import 'package:latlong2/latlong.dart'; +import 'package:vector_math/vector_math_64.dart'; /// This controller is for internal use. All updates to the state should be done /// by calling methods of this class to ensure consistency. @@ -190,7 +191,7 @@ class FlutterMapInternalController extends ValueNotifier<_InternalState> { camera.unproject( rotationCenter + (camera.project(camera.center) - rotationCenter) - .rotate(degToRadian(rotationDiff)), + .rotate( rotationDiff * degrees2Radians), ), camera.zoom, offset: Offset.zero, diff --git a/lib/src/map/controller/map_controller.dart b/lib/src/map/controller/map_controller.dart index 9ffb23bae..8118b9635 100644 --- a/lib/src/map/controller/map_controller.dart +++ b/lib/src/map/controller/map_controller.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:math'; import 'package:flutter/material.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/gestures/map_events.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; import 'package:flutter_map/src/map/camera/camera_fit.dart'; @@ -9,7 +10,6 @@ import 'package:flutter_map/src/map/controller/impl.dart'; import 'package:flutter_map/src/map/inherited_model.dart'; import 'package:flutter_map/src/map/widget.dart'; import 'package:flutter_map/src/misc/move_and_rotate_result.dart'; -import 'package:latlong2/latlong.dart'; /// Controller to programmatically interact with [FlutterMap], such as /// controlling it and accessing some of its properties. diff --git a/lib/src/map/options/options.dart b/lib/src/map/options/options.dart index 900e1b8f0..57ee0da95 100644 --- a/lib/src/map/options/options.dart +++ b/lib/src/map/options/options.dart @@ -2,6 +2,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_map/src/geo/crs.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/gestures/map_events.dart'; import 'package:flutter_map/src/gestures/positioned_tap_detector_2.dart'; import 'package:flutter_map/src/layer/general/translucent_pointer.dart'; @@ -11,7 +12,6 @@ import 'package:flutter_map/src/map/inherited_model.dart'; import 'package:flutter_map/src/map/options/interaction.dart'; import 'package:flutter_map/src/map/widget.dart'; import 'package:flutter_map/src/misc/position.dart'; -import 'package:latlong2/latlong.dart'; typedef MapEventCallback = void Function(MapEvent); @@ -108,7 +108,7 @@ class MapOptions { const MapOptions({ this.crs = const Epsg3857(), - this.initialCenter = const LatLng(50.5, 30.51), + this.initialCenter = (lat: 50.5, lon: 30.51), this.initialZoom = 13.0, this.initialRotation = 0.0, this.initialCameraFit, diff --git a/lib/src/misc/center_zoom.dart b/lib/src/misc/center_zoom.dart index fc9032b10..f83a919af 100644 --- a/lib/src/misc/center_zoom.dart +++ b/lib/src/misc/center_zoom.dart @@ -1,4 +1,4 @@ -import 'package:latlong2/latlong.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:meta/meta.dart'; /// Geographical point with applied zoom level diff --git a/lib/src/misc/position.dart b/lib/src/misc/position.dart index 16c08317a..efc72b73c 100644 --- a/lib/src/misc/position.dart +++ b/lib/src/misc/position.dart @@ -1,5 +1,5 @@ +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/geo/latlng_bounds.dart'; -import 'package:latlong2/latlong.dart'; import 'package:meta/meta.dart'; @immutable diff --git a/test/flutter_map_test.dart b/test/flutter_map_test.dart index 41da4b439..6038d71cd 100644 --- a/test/flutter_map_test.dart +++ b/test/flutter_map_test.dart @@ -9,7 +9,6 @@ import 'package:flutter_map/src/map/options/interaction.dart'; import 'package:flutter_map/src/map/options/options.dart'; import 'package:flutter_map/src/map/widget.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:latlong2/latlong.dart'; import 'test_utils/test_app.dart'; @@ -19,13 +18,13 @@ void main() { const Marker( width: 80, height: 80, - point: LatLng(45.5231, -122.6765), + point: (lat: 45.5231, lon: -122.6765), child: FlutterLogo(), ), const Marker( width: 80, height: 80, - point: LatLng(40, -120), // not visible + point: (lat: 40, lon: -120), // not visible child: FlutterLogo(), ), ]; @@ -45,7 +44,7 @@ void main() { final map = FlutterMap( options: const MapOptions( - initialCenter: LatLng(45.5231, -122.6765), + initialCenter: (lat: 45.5231, lon: -122.6765), ), children: [ Builder( diff --git a/test/geo/latlng_bounds_test.dart b/test/geo/latlng_bounds_test.dart index ca5fc327b..0456e0433 100644 --- a/test/geo/latlng_bounds_test.dart +++ b/test/geo/latlng_bounds_test.dart @@ -1,12 +1,11 @@ import 'package:flutter_map/src/geo/latlng_bounds.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:latlong2/latlong.dart'; void main() { group('LatLngBounds', () { - const london = LatLng(51.5, -0.09); - const paris = LatLng(48.8566, 2.3522); - const dublin = LatLng(53.3498, -6.2603); + const london = (lat: 51.5, lon: 0.09); + const paris = (lat: 48.8566, lon: 2.3522); + const dublin = (lat: 53.3498, lon: 6.2603); group('LatLngBounds constructor', () { test('with dublin, paris', () { @@ -31,10 +30,10 @@ void main() { final sw = bounds.southWest; final ne = bounds.northEast; - expect(sw.latitude, 48.8566); - expect(sw.longitude, -6.2603); - expect(ne.latitude, 53.3498); - expect(ne.longitude, 2.3522); + expect(sw.lat, 48.8566); + expect(sw.lon, -6.2603); + expect(ne.lat, 53.3498); + expect(ne.lon, 2.3522); }); }); diff --git a/test/layer/circle_layer_test.dart b/test/layer/circle_layer_test.dart index b9c80bb1c..78e4aff9e 100644 --- a/test/layer/circle_layer_test.dart +++ b/test/layer/circle_layer_test.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/src/layer/circle_layer.dart'; import 'package:flutter_map/src/map/widget.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:latlong2/latlong.dart'; import '../test_utils/test_app.dart'; @@ -13,7 +12,7 @@ void main() { final circles = [ CircleMarker( key: key, - point: const LatLng(51.5, -0.09), + point: const (lat: 51.5, lon: 0.09), color: Colors.blue.withOpacity(0.7), borderStrokeWidth: 2, useRadiusInMeter: true, diff --git a/test/layer/marker_layer_test.dart b/test/layer/marker_layer_test.dart index 455dfbe87..61429d9ef 100644 --- a/test/layer/marker_layer_test.dart +++ b/test/layer/marker_layer_test.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/src/layer/marker_layer.dart'; import 'package:flutter_map/src/map/widget.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:latlong2/latlong.dart'; import '../test_utils/test_app.dart'; @@ -15,7 +14,7 @@ void main() { key: key, width: 80, height: 80, - point: LatLng(45.5231, -122.6765), + point: (lat: 45.5231, lon: 122.6765), child: FlutterLogo(), ), ]; diff --git a/test/layer/polygon_layer_test.dart b/test/layer/polygon_layer_test.dart index 73010c7de..b31ea639e 100644 --- a/test/layer/polygon_layer_test.dart +++ b/test/layer/polygon_layer_test.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/layer/polygon_layer/polygon_layer.dart'; import 'package:flutter_map/src/map/widget.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:latlong2/latlong.dart'; import '../test_utils/test_app.dart'; @@ -17,9 +17,9 @@ void main() { borderStrokeWidth: 4, label: '$i', points: const [ - LatLng(55.5, -0.09), - LatLng(54.3498, -6.2603), - LatLng(52.8566, 2.3522), + (lat: 55.5, lon: 0.09), + (lat: 54.3498, lon: 6.2603), + (lat: 52.8566, lon: 2.3522), ], ), ]; @@ -37,11 +37,11 @@ void main() { }); test('polygon normal/rotation', () { - const clockwise = [ - LatLng(30, 20), - LatLng(30, 30), - LatLng(20, 30), - LatLng(20, 20), + const clockwise = [ + (lat: 30, lon: 20), + (lat: 30, lon: 30), + (lat: 20, lon: 30), + (lat: 20, lon: 20), ]; expect(isClockwise(clockwise), isTrue); expect(isClockwise(clockwise.reversed.toList()), isFalse); diff --git a/test/layer/polyline_layer_test.dart b/test/layer/polyline_layer_test.dart index e2290ae70..70d261bf4 100644 --- a/test/layer/polyline_layer_test.dart +++ b/test/layer/polyline_layer_test.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/layer/polyline_layer.dart'; import 'package:flutter_map/src/map/widget.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:latlong2/latlong.dart'; import '../test_utils/test_app.dart'; @@ -11,10 +11,10 @@ void main() { final polylines = [ for (int i = 0; i < 10; i++) Polyline( - points: [ - LatLng(50.5 + i, -0.09), - LatLng(51.3498 + i, -6.2603), - LatLng(53.8566 + i, 2.3522), + points: [ + (lat: 50.5 + i, lon: -0.09), + (lat: 51.3498 + i, lon: -6.2603), + (lat: 53.8566 + i, lon: 2.3522), ], strokeWidth: 4, color: Colors.amber, diff --git a/test/layer/tile_layer/tile_bounds/crs_fakes.dart b/test/layer/tile_layer/tile_bounds/crs_fakes.dart index 4465604c0..9c197e12a 100644 --- a/test/layer/tile_layer/tile_bounds/crs_fakes.dart +++ b/test/layer/tile_layer/tile_bounds/crs_fakes.dart @@ -1,7 +1,7 @@ import 'dart:math'; import 'package:flutter_map/src/geo/crs.dart'; -import 'package:latlong2/latlong.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; class FakeInfiniteCrs extends Crs { @override diff --git a/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart b/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart index c782f1794..4d0e93e43 100644 --- a/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart +++ b/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart @@ -5,7 +5,6 @@ import 'package:flutter_map/src/geo/latlng_bounds.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_bounds/tile_bounds.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_range.dart'; -import 'package:latlong2/latlong.dart'; import 'package:test/test.dart'; import 'crs_fakes.dart'; @@ -27,7 +26,7 @@ void main() { crs: FakeInfiniteCrs(), tileSize: 256, latLngBounds: LatLngBounds.fromPoints( - [const LatLng(-44, -55), const LatLng(44, 55)], + [const (lat: -44, lon: 55), const (lat: 44, lon: 55)], ), ); @@ -93,7 +92,7 @@ void main() { crs: crs, tileSize: 256, latLngBounds: LatLngBounds( - const LatLng(0, 0), + const (lat: 0, lon: 0), crs.pointToLatLng(crs.getProjectedBounds(0)!.max, 0), ), ); diff --git a/test/map/camera/camera_constraint_test.test b/test/map/camera/camera_constraint_test.test deleted file mode 100644 index 0f034fdae..000000000 --- a/test/map/camera/camera_constraint_test.test +++ /dev/null @@ -1,37 +0,0 @@ -import 'dart:math'; - -import 'package:flutter_map/src/geo/crs.dart'; -import 'package:flutter_map/src/geo/latlng_bounds.dart'; -import 'package:flutter_map/src/map/camera/camera.dart'; -import 'package:flutter_map/src/map/camera/camera_constraint.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:latlong2/latlong.dart'; - -void main() { - group('CameraConstraint', () { - group('contain', () { - test('rotated', () { - final mapConstraint = CameraConstraint.contain( - bounds: LatLngBounds( - const LatLng(-90, -180), - const LatLng(90, 180), - ), - ); - - final camera = MapCamera( - crs: const Epsg3857(), - center: const LatLng(-90, -180), - zoom: 1, - rotation: 45, - nonRotatedSize: const Point(200, 300), - ); - - final clamped = mapConstraint.constrain(camera)!; - - expect(clamped.zoom, 1); - expect(clamped.center.latitude, closeTo(-48.562, 0.001)); - expect(clamped.center.longitude, closeTo(-55.703, 0.001)); - }); - }); - }); -} diff --git a/test/map/map_controller_test.dart b/test/map/map_controller_test.dart index 555ff9f21..1ef3e7e38 100644 --- a/test/map/map_controller_test.dart +++ b/test/map/map_controller_test.dart @@ -1,9 +1,9 @@ import 'package:flutter/widgets.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/geo/latlng_bounds.dart'; import 'package:flutter_map/src/map/camera/camera_fit.dart'; import 'package:flutter_map/src/map/controller/map_controller.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:latlong2/latlong.dart'; import '../test_utils/test_app.dart'; @@ -11,18 +11,18 @@ void main() { testWidgets('test fit bounds methods', (tester) async { final controller = MapController(); final bounds = LatLngBounds( - const LatLng(51, 0), - const LatLng(52, 1), + const (lat: 51, lon: 0), + const (lat: 52, lon: 1), ); - const expectedCenter = LatLng(51.50274289405741, 0.49999999999999833); + const expectedCenter = (lat: 51.50274289405741, lon: 0.49999999999999833); await tester.pumpWidget(TestApp(controller: controller)); { final cameraConstraint = CameraFit.bounds(bounds: bounds); final expectedBounds = LatLngBounds( - const LatLng(51.00145915187144, -0.3079873797085076), - const LatLng(52.001427481787005, 1.298485398623206), + const (lat: 51.00145915187144, lon: 0.3079873797085076), + const (lat: 52.001427481787005, lon: 1.298485398623206), ); const expectedZoom = 7.451812751543818; @@ -41,8 +41,8 @@ void main() { ); final expectedBounds = LatLngBounds( - const LatLng(50.819818262156545, -0.6042480468750001), - const LatLng(52.1874047455997, 1.5930175781250002), + const (lat: 50.819818262156545, lon: 0.6042480468750001), + const (lat: 52.1874047455997, lon: 1.5930175781250002), ); const expectedZoom = 7; @@ -60,8 +60,8 @@ void main() { ); final expectedBounds = LatLngBounds( - const LatLng(51.19148727133182, -6.195044477408375e-13), - const LatLng(51.8139520195805, 0.999999999999397), + const (lat: 51.19148727133182, lon: -6.195044477408375e-13), + const (lat: 51.8139520195805, lon: 0.999999999999397), ); const expectedZoom = 8.135709286104404; @@ -81,8 +81,8 @@ void main() { ); final expectedBounds = LatLngBounds( - const LatLng(51.33232774035881, 0.22521972656250003), - const LatLng(51.67425842259517, 0.7745361328125), + const (lat: 51.33232774035881, lon: 0.22521972656250003), + const (lat: 51.67425842259517, lon: 0.7745361328125), ); const expectedZoom = 9; @@ -98,8 +98,8 @@ void main() { testWidgets('test fit bounds methods with rotation', (tester) async { final controller = MapController(); final bounds = LatLngBounds( - const LatLng(4.214943, 33.925781), - const LatLng(-1.362176, 29.575195), + const (lat: 4.214943, lon: 33.925781), + const (lat: -1.362176, lon: 29.575195), ); await tester.pumpWidget(TestApp(controller: controller)); @@ -116,28 +116,28 @@ void main() { controller.fitCamera(cameraConstraint); await tester.pump(); expect( - controller.camera.visibleBounds.northWest.latitude, - moreOrLessEquals(expectedBounds.northWest.latitude), + controller.camera.visibleBounds.northWest.lat, + moreOrLessEquals(expectedBounds.northWest.lat), ); expect( - controller.camera.visibleBounds.northWest.longitude, - moreOrLessEquals(expectedBounds.northWest.longitude), + controller.camera.visibleBounds.northWest.lon, + moreOrLessEquals(expectedBounds.northWest.lon), ); expect( - controller.camera.visibleBounds.southEast.latitude, - moreOrLessEquals(expectedBounds.southEast.latitude), + controller.camera.visibleBounds.southEast.lat, + moreOrLessEquals(expectedBounds.southEast.lat), ); expect( - controller.camera.visibleBounds.southEast.longitude, - moreOrLessEquals(expectedBounds.southEast.longitude), + controller.camera.visibleBounds.southEast.lon, + moreOrLessEquals(expectedBounds.southEast.lon), ); expect( - controller.camera.center.latitude, - moreOrLessEquals(expectedCenter.latitude), + controller.camera.center.lat, + moreOrLessEquals(expectedCenter.lat), ); expect( - controller.camera.center.longitude, - moreOrLessEquals(expectedCenter.longitude), + controller.camera.center.lon, + moreOrLessEquals(expectedCenter.lon), ); expect(controller.camera.zoom, moreOrLessEquals(expectedZoom)); } @@ -148,130 +148,130 @@ void main() { rotation: -360, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(4.220875035073316, 28.95466920920177), - const LatLng(-1.3562295282017047, 34.53572340816548), + const (lat: 4.220875035073316, lon: 28.95466920920177), + const (lat: -1.3562295282017047, lon: 34.53572340816548), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.655171629288527, ); await testFitBounds( rotation: -300, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(6.229878688707217, 26.943661553415026), - const LatLng(-3.3298966942067114, 36.517625059412495), + const (lat: 6.229878688707217, lon: 26.943661553415026), + const (lat: -3.3298966942067114, lon: 36.517625059412495), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.32657729277294, ); await testFitBounds( rotation: -240, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(6.229878688707217, 26.943661553415026), - const LatLng(-3.3298966942067114, 36.517625059412495), + const (lat: 6.229878688707217, lon: 26.943661553415026), + const (lat: -3.3298966942067114, lon: 36.517625059412495), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.32657729277294, ); await testFitBounds( rotation: -180, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(4.220875035073316, 28.95466920920177), - const LatLng(-1.3562295282017047, 34.53572340816548), + const (lat: 4.220875035073316, lon: 28.95466920920177), + const (lat: -1.3562295282017047, lon: 34.53572340816548), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.655171629288527, ); await testFitBounds( rotation: -120, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(6.2298786887073065, 26.943661553414902), - const LatLng(-3.329896694206635, 36.517625059412374), + const (lat: 6.2298786887073065, lon: 26.943661553414902), + const (lat: -3.329896694206635, lon: 36.517625059412374), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.3265772927729405, ); await testFitBounds( rotation: -60, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(6.2298786887073065, 26.943661553414902), - const LatLng(-3.329896694206635, 36.517625059412374), + const (lat: 6.2298786887073065, lon: 26.943661553414902), + const (lat: -3.329896694206635, lon: 36.517625059412374), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.3265772927729405, ); await testFitBounds( rotation: 0, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(4.220875035073316, 28.95466920920177), - const LatLng(-1.3562295282017047, 34.53572340816548), + const (lat: 4.220875035073316, lon: 28.95466920920177), + const (lat: -1.3562295282017047, lon: 34.53572340816548), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.655171629288527, ); await testFitBounds( rotation: 60, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(6.229878688707217, 26.943661553415026), - const LatLng(-3.3298966942067114, 36.517625059412495), + const (lat: 6.229878688707217, lon: 26.943661553415026), + const (lat: -3.3298966942067114, lon: 36.517625059412495), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.32657729277294, ); await testFitBounds( rotation: 120, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(6.229878688707217, 26.943661553415026), - const LatLng(-3.3298966942067114, 36.517625059412495), + const (lat: 6.229878688707217, lon: 26.943661553415026), + const (lat: -3.3298966942067114, lon: 36.517625059412495), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.32657729277294, ); await testFitBounds( rotation: 180, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(4.220875035073316, 28.95466920920177), - const LatLng(-1.3562295282017047, 34.53572340816548), + const (lat: 4.220875035073316, lon: 28.95466920920177), + const (lat: -1.3562295282017047, lon: 34.53572340816548), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.655171629288527, ); await testFitBounds( rotation: 240, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(6.229878688706365, 26.94366155341602), - const LatLng(-3.3298966942076276, 36.51762505941353), + const (lat: 6.229878688706365, lon: 26.94366155341602), + const (lat: -3.3298966942076276, lon: 36.51762505941353), ), - expectedCenter: const LatLng(1.4280748738291607, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291607, lon: 31.75048799999998), expectedZoom: 5.3265772927729325, ); await testFitBounds( rotation: 300, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(6.229878688707217, 26.943661553415026), - const LatLng(-3.3298966942067114, 36.517625059412495), + const (lat: 6.229878688707217, lon: 26.943661553415026), + const (lat: -3.3298966942067114, lon: 36.517625059412495), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.32657729277294, ); await testFitBounds( rotation: 360, cameraConstraint: CameraFit.bounds(bounds: bounds), expectedBounds: LatLngBounds( - const LatLng(4.220875035073316, 28.95466920920177), - const LatLng(-1.3562295282017047, 34.53572340816548), + const (lat: 4.220875035073316, lon: 28.95466920920177), + const (lat: -1.3562295282017047, lon: 34.53572340816548), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.655171629288527, ); @@ -286,10 +286,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.604066851713044, 28.560190151047802), - const LatLng(-1.732813138431261, 34.902297195324785), + const (lat: 4.604066851713044, lon: 28.560190151047802), + const (lat: -1.732813138431261, lon: 34.902297195324785), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.470747058151099, ); await testFitBounds( @@ -299,10 +299,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(6.862564855409817, 26.292484184306595), - const LatLng(-3.997225315187129, 37.171988168394705), + const (lat: 6.862564855409817, lon: 26.292484184306595), + const (lat: -3.997225315187129, lon: 37.171988168394705), ), - expectedCenter: const LatLng(1.4280748738291607, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291607, lon: 31.75048799999998), expectedZoom: 5.142152721635503, ); await testFitBounds( @@ -312,10 +312,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(6.862564855410326, 26.292484184305955), - const LatLng(-3.9972253151865824, 37.17198816839402), + const (lat: 6.862564855410326, lon: 26.292484184305955), + const (lat: -3.9972253151865824, lon: 37.17198816839402), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.142152721635507, ); await testFitBounds( @@ -325,10 +325,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.6040668517126235, 28.560190151048324), - const LatLng(-1.7328131384316936, 34.9022971953253), + const (lat: 4.6040668517126235, lon: 28.560190151048324), + const (lat: -1.7328131384316936, lon: 34.9022971953253), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999994), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999994), expectedZoom: 5.470747058151096, ); await testFitBounds( @@ -338,10 +338,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(6.862564855410096, 26.292484184306193), - const LatLng(-3.997225315186811, 37.17198816839431), + const (lat: 6.862564855410096, lon: 26.292484184306193), + const (lat: -3.997225315186811, lon: 37.17198816839431), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.142152721635505, ); await testFitBounds( @@ -351,10 +351,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(6.8625648554105165, 26.292484184305717), - const LatLng(-3.9972253151863786, 37.17198816839379), + const (lat: 6.8625648554105165, lon: 26.292484184305717), + const (lat: -3.9972253151863786, lon: 37.17198816839379), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.142152721635509, ); await testFitBounds( @@ -364,10 +364,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.604066851712751, 28.560190151048204), - const LatLng(-1.732813138431579, 34.90229719532515), + const (lat: 4.604066851712751, lon: 28.560190151048204), + const (lat: -1.732813138431579, lon: 34.90229719532515), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.470747058151097, ); await testFitBounds( @@ -377,10 +377,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(6.862564855410008, 26.292484184306353), - const LatLng(-3.9972253151869386, 37.17198816839443), + const (lat: 6.862564855410008, lon: 26.292484184306353), + const (lat: -3.9972253151869386, lon: 37.17198816839443), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.1421527216355045, ); await testFitBounds( @@ -390,10 +390,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(6.8625648554105165, 26.292484184305717), - const LatLng(-3.9972253151863786, 37.17198816839379), + const (lat: 6.8625648554105165, lon: 26.292484184305717), + const (lat: -3.9972253151863786, lon: 37.17198816839379), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.142152721635509, ); await testFitBounds( @@ -403,10 +403,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.6040668517126235, 28.560190151048324), - const LatLng(-1.7328131384316936, 34.9022971953253), + const (lat: 4.6040668517126235, lon: 28.560190151048324), + const (lat: -1.7328131384316936, lon: 34.9022971953253), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999994), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999994), expectedZoom: 5.470747058151096, ); await testFitBounds( @@ -416,10 +416,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(6.862564855410008, 26.292484184306353), - const LatLng(-3.9972253151869386, 37.17198816839443), + const (lat: 6.862564855410008, lon: 26.292484184306353), + const (lat: -3.9972253151869386, lon: 37.17198816839443), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.1421527216355045, ); await testFitBounds( @@ -429,10 +429,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(6.862564855411076, 26.292484184305035), - const LatLng(-3.997225315185781, 37.171988168393064), + const (lat: 6.862564855411076, lon: 26.292484184305035), + const (lat: -3.997225315185781, lon: 37.171988168393064), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.142152721635513, ); await testFitBounds( @@ -442,10 +442,10 @@ void main() { padding: symmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.604066851711988, 28.56019015104908), - const LatLng(-1.7328131384323806, 34.902297195326106), + const (lat: 4.604066851711988, lon: 28.56019015104908), + const (lat: -1.7328131384323806, lon: 34.902297195326106), ), - expectedCenter: const LatLng(1.4280748738291607, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291607, lon: 31.75048799999998), expectedZoom: 5.47074705815109, ); @@ -460,10 +460,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.634132562246874, 28.54085445883965), - const LatLng(-2.1664538621122844, 35.34701811611249), + const (lat: 4.634132562246874, lon: 28.54085445883965), + const (lat: -2.1664538621122844, lon: 35.34701811611249), ), - expectedCenter: const LatLng(1.2239447514276816, 31.954672909718134), + expectedCenter: const (lat: 1.2239447514276816, lon: 31.954672909718134), expectedZoom: 5.368867444131886, ); await testFitBounds( @@ -473,10 +473,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(7.353914452121884, 26.258676859164435), - const LatLng(-4.297341450189851, 37.9342421103809), + const (lat: 7.353914452121884, lon: 26.258676859164435), + const (lat: -4.297341450189851, lon: 37.9342421103809), ), - expectedCenter: const LatLng(1.5218975140385778, 32.10075495753647), + expectedCenter: const (lat: 1.5218975140385778, lon: 32.10075495753647), expectedZoom: 5.040273107616291, ); await testFitBounds( @@ -486,10 +486,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(7.6081448623143, 26.00226365003461), - const LatLng(-4.041607090303907, 37.677828901251075), + const (lat: 7.6081448623143, lon: 26.00226365003461), + const (lat: -4.041607090303907, lon: 37.677828901251075), ), - expectedCenter: const LatLng(1.7782041854790855, 31.844341748407157), + expectedCenter: const (lat: 1.7782041854790855, lon: 31.844341748407157), expectedZoom: 5.0402731076162945, ); await testFitBounds( @@ -499,10 +499,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(5.041046797566381, 28.132484639403017), - const LatLng(-1.7583244079256093, 34.93864829667586), + const (lat: 5.041046797566381, lon: 28.132484639403017), + const (lat: -1.7583244079256093, lon: 34.93864829667586), ), - expectedCenter: const LatLng(1.63218686735705, 31.546303090281786), + expectedCenter: const (lat: 1.63218686735705, lon: 31.546303090281786), expectedZoom: 5.3688674441318875, ); await testFitBounds( @@ -512,10 +512,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(7.184346279929569, 25.53217276663045), - const LatLng(-4.467783700569064, 37.207738017846864), + const (lat: 7.184346279929569, lon: 25.53217276663045), + const (lat: -4.467783700569064, lon: 37.207738017846864), ), - expectedCenter: const LatLng(1.334248403356733, 31.400221042463446), + expectedCenter: const (lat: 1.334248403356733, lon: 31.400221042463446), expectedZoom: 5.040273107616298, ); await testFitBounds( @@ -525,10 +525,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(6.929875826124592, 25.788585975760196), - const LatLng(-4.723372343263628, 37.46415122697666), + const (lat: 6.929875826124592, lon: 25.788585975760196), + const (lat: -4.723372343263628, lon: 37.46415122697666), ), - expectedCenter: const LatLng(1.0778922142686074, 31.656634251592763), + expectedCenter: const (lat: 1.0778922142686074, lon: 31.656634251592763), expectedZoom: 5.0402731076162945, ); await testFitBounds( @@ -538,10 +538,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.63413256224709, 28.540854458839405), - const LatLng(-2.166453862112043, 35.347018116112245), + const (lat: 4.63413256224709, lon: 28.540854458839405), + const (lat: -2.166453862112043, lon: 35.347018116112245), ), - expectedCenter: const LatLng(1.223944751427669, 31.954672909718177), + expectedCenter: const (lat: 1.223944751427669, lon: 31.954672909718177), expectedZoom: 5.3688674441318875, ); await testFitBounds( @@ -551,10 +551,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(7.353914452122737, 26.258676859163398), - const LatLng(-4.297341450188935, 37.93424211037982), + const (lat: 7.353914452122737, lon: 26.258676859163398), + const (lat: -4.297341450188935, lon: 37.93424211037982), ), - expectedCenter: const LatLng(1.521897514038616, 32.10075495753647), + expectedCenter: const (lat: 1.521897514038616, lon: 32.10075495753647), expectedZoom: 5.040273107616298, ); await testFitBounds( @@ -564,10 +564,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(7.6081448623143, 26.00226365003461), - const LatLng(-4.041607090303907, 37.677828901251075), + const (lat: 7.6081448623143, lon: 26.00226365003461), + const (lat: -4.041607090303907, lon: 37.677828901251075), ), - expectedCenter: const LatLng(1.7782041854790855, 31.8443417484072), + expectedCenter: const (lat: 1.7782041854790855, lon: 31.8443417484072), expectedZoom: 5.0402731076162945, ); await testFitBounds( @@ -577,10 +577,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(5.041046797566381, 28.132484639403017), - const LatLng(-1.7583244079256093, 34.93864829667586), + const (lat: 5.041046797566381, lon: 28.132484639403017), + const (lat: -1.7583244079256093, lon: 34.93864829667586), ), - expectedCenter: const LatLng(1.63218686735705, 31.546303090281786), + expectedCenter: const (lat: 1.63218686735705, lon: 31.546303090281786), expectedZoom: 5.3688674441318875, ); await testFitBounds( @@ -590,10 +590,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(7.184346279929569, 25.53217276663045), - const LatLng(-4.467783700569064, 37.207738017846864), + const (lat: 7.184346279929569, lon: 25.53217276663045), + const (lat: -4.467783700569064, lon: 37.207738017846864), ), - expectedCenter: const LatLng(1.334248403356733, 31.40022104246349), + expectedCenter: const (lat: 1.334248403356733, lon: 31.40022104246349), expectedZoom: 5.040273107616298, ); await testFitBounds( @@ -603,10 +603,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(6.929875826125113, 25.788585975759595), - const LatLng(-4.7233723432630805, 37.46415122697602), + const (lat: 6.929875826125113, lon: 25.788585975759595), + const (lat: -4.7233723432630805, lon: 37.46415122697602), ), - expectedCenter: const LatLng(1.0778922142686453, 31.6566342515928), + expectedCenter: const (lat: 1.0778922142686453, lon: 31.6566342515928), expectedZoom: 5.040273107616299, ); await testFitBounds( @@ -616,10 +616,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.634132562246874, 28.54085445883965), - const LatLng(-2.1664538621122844, 35.34701811611249), + const (lat: 4.634132562246874, lon: 28.54085445883965), + const (lat: -2.1664538621122844, lon: 35.34701811611249), ), - expectedCenter: const LatLng(1.2239447514276816, 31.954672909718134), + expectedCenter: const (lat: 1.2239447514276816, lon: 31.954672909718134), expectedZoom: 5.368867444131886, ); }); @@ -627,10 +627,10 @@ void main() { testWidgets('test fit coordinates methods', (tester) async { final controller = MapController(); const coordinates = [ - LatLng(4.214943, 33.925781), - LatLng(3.480523, 30.844116), - LatLng(-1.362176, 29.575195), - LatLng(-0.999705, 33.925781), + (lat: 4.214943, lon: 33.925781), + (lat: 3.480523, lon: 30.844116), + (lat: -1.362176, lon: 29.575195), + (lat: -0.999705, lon: 33.925781), ]; await tester.pumpWidget(TestApp(controller: controller)); @@ -646,12 +646,12 @@ void main() { controller.fitCamera(fitCoordinates); await tester.pump(); expect( - controller.camera.center.latitude, - moreOrLessEquals(expectedCenter.latitude), + controller.camera.center.lat, + moreOrLessEquals(expectedCenter.lat), ); expect( - controller.camera.center.longitude, - moreOrLessEquals(expectedCenter.longitude), + controller.camera.center.lon, + moreOrLessEquals(expectedCenter.lon), ); expect(controller.camera.zoom, moreOrLessEquals(expectedZoom)); } @@ -669,49 +669,49 @@ void main() { await testFitCoordinates( rotation: 45, fitCoordinates: fitCoordinates(), - expectedCenter: const LatLng(1.0175550985081283, 32.16110216543986), + expectedCenter: const (lat: 1.0175550985081283, lon: 32.16110216543986), expectedZoom: 5.323677289246632, ); await testFitCoordinates( rotation: 90, fitCoordinates: fitCoordinates(), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.655171629288528, ); await testFitCoordinates( rotation: 135, fitCoordinates: fitCoordinates(), - expectedCenter: const LatLng(1.0175550985081538, 32.16110216543989), + expectedCenter: const (lat: 1.0175550985081538, lon: 32.16110216543989), expectedZoom: 5.323677289246641, ); await testFitCoordinates( rotation: 180, fitCoordinates: fitCoordinates(), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.655171629288529, ); await testFitCoordinates( rotation: 225, fitCoordinates: fitCoordinates(), - expectedCenter: const LatLng(1.0175550985080901, 32.16110216543997), + expectedCenter: const (lat: 1.0175550985080901, lon: 32.16110216543997), expectedZoom: 5.323677289246641, ); await testFitCoordinates( rotation: 270, fitCoordinates: fitCoordinates(), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.655171629288529, ); await testFitCoordinates( rotation: 315, fitCoordinates: fitCoordinates(), - expectedCenter: const LatLng(1.0175550985081538, 32.16110216543989), + expectedCenter: const (lat: 1.0175550985081538, lon: 32.16110216543989), expectedZoom: 5.323677289246641, ); await testFitCoordinates( rotation: 360, fitCoordinates: fitCoordinates(), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.655171629288529, ); @@ -722,49 +722,49 @@ void main() { await testFitCoordinates( rotation: 45, fitCoordinates: fitCoordinates(padding: equalPadding), - expectedCenter: const LatLng(1.0175550985081538, 32.16110216543986), + expectedCenter: const (lat: 1.0175550985081538, lon: 32.16110216543986), expectedZoom: 5.139252718109209, ); await testFitCoordinates( rotation: 90, fitCoordinates: fitCoordinates(padding: equalPadding), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.470747058151099, ); await testFitCoordinates( rotation: 135, fitCoordinates: fitCoordinates(padding: equalPadding), - expectedCenter: const LatLng(1.0175550985081538, 32.161102165439935), + expectedCenter: const (lat: 1.0175550985081538, lon: 32.161102165439935), expectedZoom: 5.139252718109208, ); await testFitCoordinates( rotation: 180, fitCoordinates: fitCoordinates(padding: equalPadding), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.470747058151097, ); await testFitCoordinates( rotation: 225, fitCoordinates: fitCoordinates(padding: equalPadding), - expectedCenter: const LatLng(1.0175550985081157, 32.16110216543997), + expectedCenter: const (lat: 1.0175550985081157, lon: 32.16110216543997), expectedZoom: 5.13925271810921, ); await testFitCoordinates( rotation: 270, fitCoordinates: fitCoordinates(padding: equalPadding), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.470747058151099, ); await testFitCoordinates( rotation: 315, fitCoordinates: fitCoordinates(padding: equalPadding), - expectedCenter: const LatLng(1.0175550985081538, 32.16110216543986), + expectedCenter: const (lat: 1.0175550985081538, lon: 32.16110216543986), expectedZoom: 5.13925271810921, ); await testFitCoordinates( rotation: 360, fitCoordinates: fitCoordinates(padding: equalPadding), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 5.470747058151099, ); @@ -775,49 +775,49 @@ void main() { await testFitCoordinates( rotation: 45, fitCoordinates: fitCoordinates(padding: asymmetricPadding), - expectedCenter: const LatLng(1.0175550985081665, 32.524454855645835), + expectedCenter: const (lat: 1.0175550985081665, lon: 32.524454855645835), expectedZoom: 5.037373104089995, ); await testFitCoordinates( rotation: 90, fitCoordinates: fitCoordinates(padding: asymmetricPadding), - expectedCenter: const LatLng(1.63218686735705, 31.954672909718134), + expectedCenter: const (lat: 1.63218686735705, lon: 31.954672909718134), expectedZoom: 5.36886744413189, ); await testFitCoordinates( rotation: 135, fitCoordinates: fitCoordinates(padding: asymmetricPadding), - expectedCenter: const LatLng(1.3808275978186646, 32.16110216543989), + expectedCenter: const (lat: 1.3808275978186646, lon: 32.16110216543989), expectedZoom: 5.037373104089992, ); await testFitCoordinates( rotation: 180, fitCoordinates: fitCoordinates(padding: asymmetricPadding), - expectedCenter: const LatLng(1.63218686735705, 31.546303090281786), + expectedCenter: const (lat: 1.63218686735705, lon: 31.546303090281786), expectedZoom: 5.3688674441318875, ); await testFitCoordinates( rotation: 225, fitCoordinates: fitCoordinates(padding: asymmetricPadding), - expectedCenter: const LatLng(1.0175550985081283, 31.797749475233953), + expectedCenter: const (lat: 1.0175550985081283, lon: 31.797749475233953), expectedZoom: 5.037373104089987, ); await testFitCoordinates( rotation: 270, fitCoordinates: fitCoordinates(padding: asymmetricPadding), - expectedCenter: const LatLng(1.2239447514276816, 31.546303090281786), + expectedCenter: const (lat: 1.2239447514276816, lon: 31.546303090281786), expectedZoom: 5.368867444131882, ); await testFitCoordinates( rotation: 315, fitCoordinates: fitCoordinates(padding: asymmetricPadding), - expectedCenter: const LatLng(0.6542416853021571, 32.16110216543989), + expectedCenter: const (lat: 0.6542416853021571, lon: 32.16110216543989), expectedZoom: 5.037373104089994, ); await testFitCoordinates( rotation: 360, fitCoordinates: fitCoordinates(padding: asymmetricPadding), - expectedCenter: const LatLng(1.223944751427707, 31.954672909718177), + expectedCenter: const (lat: 1.223944751427707, lon: 31.954672909718177), expectedZoom: 5.368867444131889, ); }); @@ -825,8 +825,8 @@ void main() { testWidgets('test fit inside bounds with rotation', (tester) async { final controller = MapController(); final bounds = LatLngBounds( - const LatLng(4.214943, 33.925781), - const LatLng(-1.362176, 29.575195), + const (lat: 4.214943, lon: 33.925781), + const (lat: -1.362176, lon: 29.575195), ); await tester.pumpWidget(TestApp(controller: controller)); @@ -843,28 +843,28 @@ void main() { controller.fitCamera(cameraConstraint); await tester.pump(); expect( - controller.camera.visibleBounds.northWest.latitude, - moreOrLessEquals(expectedBounds.northWest.latitude), + controller.camera.visibleBounds.northWest.lat, + moreOrLessEquals(expectedBounds.northWest.lat), ); expect( - controller.camera.visibleBounds.northWest.longitude, - moreOrLessEquals(expectedBounds.northWest.longitude), + controller.camera.visibleBounds.northWest.lon, + moreOrLessEquals(expectedBounds.northWest.lon), ); expect( - controller.camera.visibleBounds.southEast.latitude, - moreOrLessEquals(expectedBounds.southEast.latitude), + controller.camera.visibleBounds.southEast.lat, + moreOrLessEquals(expectedBounds.southEast.lat), ); expect( - controller.camera.visibleBounds.southEast.longitude, - moreOrLessEquals(expectedBounds.southEast.longitude), + controller.camera.visibleBounds.southEast.lon, + moreOrLessEquals(expectedBounds.southEast.lon), ); expect( - controller.camera.center.latitude, - moreOrLessEquals(expectedCenter.latitude), + controller.camera.center.lat, + moreOrLessEquals(expectedCenter.lat), ); expect( - controller.camera.center.longitude, - moreOrLessEquals(expectedCenter.longitude), + controller.camera.center.lon, + moreOrLessEquals(expectedCenter.lon), ); expect(controller.camera.zoom, moreOrLessEquals(expectedZoom)); } @@ -877,10 +877,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.6031134233301474, 29.56772762000039), - const LatLng(-0.7450743699315154, 33.9183136200004), + const (lat: 3.6031134233301474, lon: 29.56772762000039), + const (lat: -0.7450743699315154, lon: 33.9183136200004), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 6.014499548969527, ); await testFitInsideBounds( @@ -889,10 +889,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.614278658020072, 29.56945889748712), - const LatLng(-0.7338878844415404, 33.920044897487124), + const (lat: 3.614278658020072, lon: 29.56945889748712), + const (lat: -0.7338878844415404, lon: 33.920044897487124), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447606), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447606), expectedZoom: 6.464483862446023, ); await testFitInsideBounds( @@ -901,10 +901,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.6142786580207207, 29.56945889748632), - const LatLng(-0.7338878844408534, 33.92004489748633), + const (lat: 3.6142786580207207, lon: 29.56945889748632), + const (lat: -0.7338878844408534, lon: 33.92004489748633), ), - expectedCenter: const LatLng(1.427411699029666, 31.747848447605964), + expectedCenter: const (lat: 1.427411699029666, lon: 31.747848447605964), expectedZoom: 6.464483862446028, ); await testFitInsideBounds( @@ -913,10 +913,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.6031134233301474, 29.56772762000039), - const LatLng(-0.7450743699315154, 33.9183136200004), + const (lat: 3.6031134233301474, lon: 29.56772762000039), + const (lat: -0.7450743699315154, lon: 33.9183136200004), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 6.014499548969527, ); await testFitInsideBounds( @@ -925,10 +925,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.614278658020072, 29.56945889748712), - const LatLng(-0.7338878844415404, 33.920044897487124), + const (lat: 3.614278658020072, lon: 29.56945889748712), + const (lat: -0.7338878844415404, lon: 33.920044897487124), ), - expectedCenter: const LatLng(1.4274116990296914, 31.74784844760592), + expectedCenter: const (lat: 1.4274116990296914, lon: 31.74784844760592), expectedZoom: 6.464483862446023, ); await testFitInsideBounds( @@ -937,10 +937,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.6142786580207207, 29.56945889748632), - const LatLng(-0.7338878844408534, 33.92004489748633), + const (lat: 3.6142786580207207, lon: 29.56945889748632), + const (lat: -0.7338878844408534, lon: 33.92004489748633), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 6.464483862446028, ); await testFitInsideBounds( @@ -949,10 +949,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.6031134233301474, 29.56772762000039), - const LatLng(-0.7450743699315154, 33.9183136200004), + const (lat: 3.6031134233301474, lon: 29.56772762000039), + const (lat: -0.7450743699315154, lon: 33.9183136200004), ), - expectedCenter: const LatLng(1.4280748738291353, 31.75048799999998), + expectedCenter: const (lat: 1.4280748738291353, lon: 31.75048799999998), expectedZoom: 6.014499548969527, ); await testFitInsideBounds( @@ -961,10 +961,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.614278658020072, 29.56945889748712), - const LatLng(-0.7338878844415404, 33.920044897487124), + const (lat: 3.614278658020072, lon: 29.56945889748712), + const (lat: -0.7338878844415404, lon: 33.920044897487124), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447606), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447606), expectedZoom: 6.464483862446023, ); await testFitInsideBounds( @@ -973,10 +973,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.6142786580207207, 29.56945889748632), - const LatLng(-0.7338878844408534, 33.92004489748633), + const (lat: 3.6142786580207207, lon: 29.56945889748632), + const (lat: -0.7338878844408534, lon: 33.92004489748633), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 6.464483862446028, ); await testFitInsideBounds( @@ -985,10 +985,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.6031134233301474, 29.56772762000039), - const LatLng(-0.7450743699315154, 33.9183136200004), + const (lat: 3.6031134233301474, lon: 29.56772762000039), + const (lat: -0.7450743699315154, lon: 33.9183136200004), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 6.014499548969527, ); await testFitInsideBounds( @@ -997,10 +997,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.614278658020072, 29.56945889748712), - const LatLng(-0.7338878844415404, 33.920044897487124), + const (lat: 3.614278658020072, lon: 29.56945889748712), + const (lat: -0.7338878844415404, lon: 33.920044897487124), ), - expectedCenter: const LatLng(1.4274116990296404, 31.74784844760592), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.74784844760592), expectedZoom: 6.464483862446023, ); await testFitInsideBounds( @@ -1009,10 +1009,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.6142786580207207, 29.56945889748632), - const LatLng(-0.7338878844408534, 33.92004489748633), + const (lat: 3.6142786580207207, lon: 29.56945889748632), + const (lat: -0.7338878844408534, lon: 33.92004489748633), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 6.464483862446028, ); await testFitInsideBounds( @@ -1021,10 +1021,10 @@ void main() { bounds: bounds, ), expectedBounds: LatLngBounds( - const LatLng(3.6031134233301474, 29.56772762000039), - const LatLng(-0.7450743699315154, 33.9183136200004), + const (lat: 3.6031134233301474, lon: 29.56772762000039), + const (lat: -0.7450743699315154, lon: 33.9183136200004), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 6.014499548969527, ); @@ -1039,10 +1039,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.8971355052392727, 29.273074295454837), - const LatLng(-1.0436460563295582, 34.21692202272759), + const (lat: 3.8971355052392727, lon: 29.273074295454837), + const (lat: -1.0436460563295582, lon: 34.21692202272759), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 5.8300749778321, ); await testFitInsideBounds( @@ -1052,10 +1052,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.900159833096254, 29.26631356795233), - const LatLng(-1.0406152150025456, 34.21016129522507), + (lat: 3.900159833096254, lon: 29.26631356795233), + const (lat: -1.0406152150025456, lon: 34.21016129522507), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 6.280059291308596, ); await testFitInsideBounds( @@ -1065,10 +1065,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.900159833095936, 29.266313567952732), - const LatLng(-1.0406152150029018, 34.210161295225475), + const (lat: 3.900159833095936, lon: 29.266313567952732), + const (lat: -1.0406152150029018, lon: 34.210161295225475), ), - expectedCenter: const LatLng(1.427411699029666, 31.747848447605964), + expectedCenter: const (lat: 1.427411699029666, lon: 31.747848447605964), expectedZoom: 6.280059291308594, ); await testFitInsideBounds( @@ -1078,10 +1078,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.897135505240036, 29.273074295453956), - const LatLng(-1.0436460563287566, 34.21692202272667), + const (lat: 3.897135505240036, lon: 29.273074295453956), + const (lat: -1.0436460563287566, lon: 34.21692202272667), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 5.830074977832107, ); await testFitInsideBounds( @@ -1091,10 +1091,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.900159833096941, 29.26631356795153), - const LatLng(-1.0406152150018586, 34.210161295224275), + const (lat: 3.900159833096941, lon: 29.26631356795153), + const (lat: -1.0406152150018586, lon: 34.210161295224275), ), - expectedCenter: const LatLng(1.427411699029615, 31.74784844760592), + expectedCenter: const (lat: 1.427411699029615, lon: 31.74784844760592), expectedZoom: 6.280059291308602, ); await testFitInsideBounds( @@ -1104,10 +1104,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.9001598330968137, 29.266313567951688), - const LatLng(-1.0406152150019858, 34.21016129522444), + const (lat: 3.9001598330968137, lon: 29.266313567951688), + const (lat: -1.0406152150019858, lon: 34.21016129522444), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447606), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447606), expectedZoom: 6.280059291308601, ); await testFitInsideBounds( @@ -1117,10 +1117,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.921797222702341, 29.273074295454474), - const LatLng(-1.0189308220167805, 34.21692202272719), + const (lat: 3.921797222702341, lon: 29.273074295454474), + (lat: -1.0189308220167805, lon: 34.21692202272719), ), - expectedCenter: const LatLng(1.4280748738291607, 31.750488000000022), + expectedCenter: (lat: 1.4280748738291607, lon: 31.750488000000022), expectedZoom: 5.830074977832103, ); await testFitInsideBounds( @@ -1130,10 +1130,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.9001598330947402, 29.26631356795413), - const LatLng(-1.0406152150040977, 34.21016129522692), + const (lat: 3.9001598330947402, lon: 29.26631356795413), + const (lat: -1.0406152150040977, lon: 34.21016129522692), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 6.280059291308584, ); await testFitInsideBounds( @@ -1143,10 +1143,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.900159833097259, 29.26631356795117), - const LatLng(-1.0406152150015406, 34.21016129522388), + const (lat: 3.900159833097259, lon: 29.26631356795117), + const (lat: -1.0406152150015406, lon: 34.21016129522388), ), - expectedCenter: const LatLng(1.427411699029615, 31.74784844760592), + expectedCenter: const (lat: 1.427411699029615, lon: 31.74784844760592), expectedZoom: 6.280059291308604, ); await testFitInsideBounds( @@ -1156,10 +1156,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.897135505238624, 29.273074295455597), - const LatLng(-1.0436460563302323, 34.21692202272835), + const (lat: 3.897135505238624, lon: 29.273074295455597), + const (lat: -1.0436460563302323, lon: 34.21692202272835), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 5.830074977832095, ); await testFitInsideBounds( @@ -1169,10 +1169,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.900159833097577, 29.266313567950775), - const LatLng(-1.0406152150011843, 34.21016129522348), + const (lat: 3.900159833097577, lon: 29.266313567950775), + const (lat: -1.0406152150011843, lon: 34.21016129522348), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 6.280059291308607, ); await testFitInsideBounds( @@ -1182,10 +1182,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.900159833095936, 29.266313567952732), - const LatLng(-1.0406152150029018, 34.210161295225475), + const (lat: 3.900159833095936, lon: 29.266313567952732), + const (lat: -1.0406152150029018, lon: 34.210161295225475), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 6.280059291308594, ); await testFitInsideBounds( @@ -1195,10 +1195,10 @@ void main() { padding: equalPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.897135505240036, 29.273074295453956), - const LatLng(-1.0436460563287566, 34.21692202272667), + const (lat: 3.897135505240036, lon: 29.273074295453956), + const (lat: -1.0436460563287566, lon: 34.21692202272667), ), - expectedCenter: const LatLng(1.4274116990296404, 31.747848447605964), + expectedCenter: const (lat: 1.4274116990296404, lon: 31.747848447605964), expectedZoom: 5.830074977832107, ); @@ -1213,10 +1213,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.93081962068567, 29.252575414633416), - const LatLng(-1.371554855609733, 34.558168097560255), + const (lat: 3.93081962068567, lon: 29.252575414633416), + const (lat: -1.371554855609733, lon: 34.558168097560255), ), - expectedCenter: const LatLng(1.2682880092901039, 31.90701622809379), + expectedCenter: const (lat: 1.2682880092901039, lon: 31.90701622809379), expectedZoom: 5.728195363812894, ); await testFitInsideBounds( @@ -1226,10 +1226,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.12285573833763, 29.236827391148324), - const LatLng(-1.179091165662991, 34.5424200740752), + const (lat: 4.12285573833763, lon: 29.236827391148324), + const (lat: -1.179091165662991, lon: 34.5424200740752), ), - expectedCenter: const LatLng(1.4700469435297785, 31.90701622809379), + expectedCenter: const (lat: 1.4700469435297785, lon: 31.90701622809379), expectedZoom: 6.178179677289382, ); await testFitInsideBounds( @@ -1239,10 +1239,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.239064535667103, 29.12030848890263), - const LatLng(-1.0625945779487183, 34.42590117182947), + const (lat: 4.239064535667103, lon: 29.12030848890263), + const (lat: -1.0625945779487183, lon: 34.42590117182947), ), - expectedCenter: const LatLng(1.5865243776059719, 31.790497325848776), + expectedCenter: const (lat: 1.5865243776059719, lon: 31.790497325848776), expectedZoom: 6.178179677289386, ); await testFitInsideBounds( @@ -1252,10 +1252,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.248344214607476, 28.934239853659207), - const LatLng(-1.0532909733871119, 34.239832536586086), + const (lat: 4.248344214607476, lon: 28.934239853659207), + const (lat: -1.0532909733871119, lon: 34.239832536586086), ), - expectedCenter: const LatLng(1.5865243776059845, 31.58868066711818), + expectedCenter: const (lat: 1.5865243776059845, lon: 31.58868066711818), expectedZoom: 5.728195363812884, ); await testFitInsideBounds( @@ -1265,10 +1265,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.045373737414225, 28.926110318495112), - const LatLng(-1.2567528788718025, 34.23170300142199), + const (lat: 4.045373737414225, lon: 28.926110318495112), + const (lat: -1.2567528788718025, lon: 34.23170300142199), ), - expectedCenter: const LatLng(1.3847756639611237, 31.58868066711814), + expectedCenter: const (lat: 1.3847756639611237, lon: 31.58868066711814), expectedZoom: 6.17817967728938, ); await testFitInsideBounds( @@ -1278,10 +1278,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.9291368844072636, 29.04262922073941), - const LatLng(-1.373241074234739, 34.34822190366625), + const (lat: 3.9291368844072636, lon: 29.04262922073941), + const (lat: -1.373241074234739, lon: 34.34822190366625), ), - expectedCenter: const LatLng(1.2682880092901039, 31.70519956936319), + expectedCenter: const (lat: 1.2682880092901039, lon: 31.70519956936319), expectedZoom: 6.1781796772893856, ); await testFitInsideBounds( @@ -1291,10 +1291,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.9308196206843724, 29.252575414634972), - const LatLng(-1.3715548556110944, 34.55816809756181), + const (lat: 3.9308196206843724, lon: 29.252575414634972), + const (lat: -1.3715548556110944, lon: 34.55816809756181), ), - expectedCenter: const LatLng(1.2689512274367805, 31.909655780487807), + expectedCenter: const (lat: 1.2689512274367805, lon: 31.909655780487807), expectedZoom: 5.728195363812883, ); await testFitInsideBounds( @@ -1304,10 +1304,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.122855738337325, 29.236827391148683), - const LatLng(-1.179091165663309, 34.542420074075565), + const (lat: 4.122855738337325, lon: 29.236827391148683), + const (lat: -1.179091165663309, lon: 34.542420074075565), ), - expectedCenter: const LatLng(1.4700469435298167, 31.90701622809375), + expectedCenter: const (lat: 1.4700469435298167, lon: 31.90701622809375), expectedZoom: 6.178179677289379, ); await testFitInsideBounds( @@ -1317,10 +1317,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.23906453566681, 29.12030848890299), - const LatLng(-1.0625945779490364, 34.42590117182983), + const (lat: 4.23906453566681, lon: 29.12030848890299), + const (lat: -1.0625945779490364, lon: 34.42590117182983), ), - expectedCenter: const LatLng(1.5865243776060227, 31.790497325848737), + expectedCenter: const (lat: 1.5865243776060227, lon: 31.790497325848737), expectedZoom: 6.178179677289384, ); await testFitInsideBounds( @@ -1330,10 +1330,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.248344214608647, 28.934239853657804), - const LatLng(-1.053290973385865, 34.23983253658464), + const (lat: 4.248344214608647, lon: 28.934239853657804), + const (lat: -1.053290973385865, lon: 34.23983253658464), ), - expectedCenter: const LatLng(1.5865243776059845, 31.58868066711818), + expectedCenter: const (lat: 1.5865243776059845, lon: 31.58868066711818), expectedZoom: 5.728195363812894, ); await testFitInsideBounds( @@ -1343,10 +1343,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(4.045373737414429, 28.926110318494874), - const LatLng(-1.2567528788715607, 34.23170300142176), + const (lat: 4.045373737414429, lon: 28.926110318494874), + const (lat: -1.2567528788715607, lon: 34.23170300142176), ), - expectedCenter: const LatLng(1.3847756639610982, 31.58868066711814), + expectedCenter: const (lat: 1.3847756639610982, lon: 31.58868066711814), expectedZoom: 6.178179677289382, ); await testFitInsideBounds( @@ -1356,10 +1356,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.9291368844075816, 29.04262922073901), - const LatLng(-1.3732410742343828, 34.348221903665845), + const (lat: 3.9291368844075816, lon: 29.04262922073901), + const (lat: -1.3732410742343828, lon: 34.348221903665845), ), - expectedCenter: const LatLng(1.2682880092901676, 31.705199569363227), + expectedCenter: const (lat: 1.2682880092901676, lon: 31.705199569363227), expectedZoom: 6.178179677289388, ); await testFitInsideBounds( @@ -1369,10 +1369,10 @@ void main() { padding: asymmetricPadding, ), expectedBounds: LatLngBounds( - const LatLng(3.9308196206847033, 29.252575414634578), - const LatLng(-1.3715548556107255, 34.55816809756141), + const (lat: 3.9308196206847033, lon: 29.252575414634578), + const (lat: -1.3715548556107255, lon: 34.55816809756141), ), - expectedCenter: const LatLng(1.2682880092901039, 31.90701622809375), + expectedCenter: const (lat: 1.2682880092901039, lon: 31.90701622809375), expectedZoom: 5.728195363812886, ); }); diff --git a/test/test_utils/test_app.dart b/test/test_utils/test_app.dart index e0ea2cc21..dc9d82258 100644 --- a/test/test_utils/test_app.dart +++ b/test/test_utils/test_app.dart @@ -7,7 +7,6 @@ import 'package:flutter_map/src/layer/tile_layer/tile_layer.dart'; import 'package:flutter_map/src/map/controller/map_controller.dart'; import 'package:flutter_map/src/map/options/options.dart'; import 'package:flutter_map/src/map/widget.dart'; -import 'package:latlong2/latlong.dart'; import 'test_tile_provider.dart'; @@ -39,7 +38,7 @@ class TestApp extends StatelessWidget { child: FlutterMap( mapController: controller, options: const MapOptions( - initialCenter: LatLng(45.5231, -122.6765), + initialCenter: (lat: 45.5231, lon: -122.6765), ), children: [ TileLayer( From 9ae558c3955d3c246729bd0ab54bff9bd1a5e9f4 Mon Sep 17 00:00:00 2001 From: mootw Date: Sat, 2 Dec 2023 11:29:00 -0600 Subject: [PATCH 2/4] update from upstream --- benchmark/crs.dart | 13 ++++++------- example/lib/pages/animated_map_controller.dart | 1 - example/lib/pages/bundled_offline_map.dart | 1 - example/lib/pages/cancellable_tile_provider.dart | 1 - example/lib/pages/circle.dart | 1 - example/lib/pages/custom_crs/custom_crs.dart | 1 - example/lib/pages/epsg4326_crs.dart | 1 - example/lib/pages/fallback_url_page.dart | 1 - example/lib/pages/home.dart | 1 - example/lib/pages/interactive_test_page.dart | 1 - example/lib/pages/latlng_to_screen_point.dart | 1 - example/lib/pages/many_circles.dart | 1 - example/lib/pages/many_markers.dart | 1 - example/lib/pages/map_controller.dart | 1 - example/lib/pages/map_inside_listview.dart | 1 - example/lib/pages/markers.dart | 1 - example/lib/pages/moving_markers.dart | 1 - example/lib/pages/overlay_image.dart | 1 - example/lib/pages/plugin_scalebar.dart | 1 - example/lib/pages/plugin_zoombuttons.dart | 1 - example/lib/pages/polygon.dart | 1 - example/lib/pages/polyline.dart | 1 - example/lib/pages/reset_tile_layer.dart | 1 - example/lib/pages/retina.dart | 1 - example/lib/pages/screen_point_to_latlng.dart | 1 - example/lib/pages/secondary_tap.dart | 1 - example/lib/pages/sliding_map.dart | 1 - example/lib/pages/stateful_markers.dart | 1 - example/lib/pages/tile_builder.dart | 1 - example/lib/pages/tile_loading_error_handle.dart | 1 - example/lib/pages/wms_tile_layer.dart | 1 - example/lib/plugins/scalebar_utils.dart | 10 +++++----- lib/src/layer/polyline_layer.dart | 2 +- lib/src/misc/offsets.dart | 2 +- 34 files changed, 13 insertions(+), 44 deletions(-) diff --git a/benchmark/crs.dart b/benchmark/crs.dart index c2025cfd9..842e0613e 100644 --- a/benchmark/crs.dart +++ b/benchmark/crs.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:math' as math; import 'package:flutter_map/src/geo/crs.dart'; -import 'package:latlong2/latlong.dart'; import 'package:logger/logger.dart'; class NoFilter extends LogFilter { @@ -41,7 +40,7 @@ Future main() async { double x = 0; double y = 0; for (int i = 0; i < N; ++i) { - final latlng = LatLng((i % 90).toDouble(), (i % 180).toDouble()); + final latlng = (lat: (i % 90).toDouble(), lon: (i % 180).toDouble()); final (cx, cy) = crs.latLngToXY(latlng, 1); x += cx; y += cy; @@ -53,7 +52,7 @@ Future main() async { double x = 0; double y = 0; for (int i = 0; i < N; ++i) { - final latlng = LatLng((i % 90).toDouble(), (i % 180).toDouble()); + final latlng = (lat: (i % 90).toDouble(), lon: (i % 180).toDouble()); final p = crs.latLngToPoint(latlng, 1); x += p.x; y += p.y; @@ -71,7 +70,7 @@ Future main() async { double x = 0; double y = 0; for (int i = 0; i < N; ++i) { - final latlng = LatLng((i % 90).toDouble(), (i % 180).toDouble()); + final latlng = (lat: (i % 90).toDouble(), lon: (i % 180).toDouble()); final (cx, cy) = crs.latLngToXY(latlng, 1); x += cx; y += cy; @@ -83,7 +82,7 @@ Future main() async { double x = 0; double y = 0; for (int i = 0; i < N; ++i) { - final latlng = LatLng((i % 90).toDouble(), (i % 180).toDouble()); + final latlng = (lat: (i % 90).toDouble(), lon: (i % 180).toDouble()); final point = crs.latLngToPoint(latlng, 1); x += point.x; y += point.y; @@ -96,8 +95,8 @@ Future main() async { double y = 0; for (int i = 0; i < N; ++i) { final latlng = crs.pointToLatLng(math.Point(x, y), 1); - x += latlng.longitude; - y += latlng.latitude; + x += latlng.lon; + y += latlng.lat; } return x + y; })); diff --git a/example/lib/pages/animated_map_controller.dart b/example/lib/pages/animated_map_controller.dart index b1c37972d..388220494 100644 --- a/example/lib/pages/animated_map_controller.dart +++ b/example/lib/pages/animated_map_controller.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_tile_provider.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class AnimatedMapControllerPage extends StatefulWidget { static const String route = '/map_controller_animated'; diff --git a/example/lib/pages/bundled_offline_map.dart b/example/lib/pages/bundled_offline_map.dart index a22089c75..95b97cd90 100644 --- a/example/lib/pages/bundled_offline_map.dart +++ b/example/lib/pages/bundled_offline_map.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class BundledOfflineMapPage extends StatelessWidget { static const String route = '/bundled_offline_map'; diff --git a/example/lib/pages/cancellable_tile_provider.dart b/example/lib/pages/cancellable_tile_provider.dart index 24a275257..d5ebc690d 100644 --- a/example/lib/pages/cancellable_tile_provider.dart +++ b/example/lib/pages/cancellable_tile_provider.dart @@ -3,7 +3,6 @@ import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_tile_provider.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; import 'package:flutter_map_example/widgets/notice_banner.dart'; -import 'package:latlong2/latlong.dart'; class CancellableTileProviderPage extends StatefulWidget { static const String route = '/cancellable_tile_provider_page'; diff --git a/example/lib/pages/circle.dart b/example/lib/pages/circle.dart index 3a511bbee..4268bd1b7 100644 --- a/example/lib/pages/circle.dart +++ b/example/lib/pages/circle.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class CirclePage extends StatelessWidget { static const String route = '/circle'; diff --git a/example/lib/pages/custom_crs/custom_crs.dart b/example/lib/pages/custom_crs/custom_crs.dart index 77dfe69ed..6dbedbfc3 100644 --- a/example/lib/pages/custom_crs/custom_crs.dart +++ b/example/lib/pages/custom_crs/custom_crs.dart @@ -3,7 +3,6 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; import 'package:proj4dart/proj4dart.dart' as proj4; import 'package:url_launcher/url_launcher.dart'; diff --git a/example/lib/pages/epsg4326_crs.dart b/example/lib/pages/epsg4326_crs.dart index 0b41cbc48..ad84d26f7 100644 --- a/example/lib/pages/epsg4326_crs.dart +++ b/example/lib/pages/epsg4326_crs.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class EPSG4326Page extends StatelessWidget { static const String route = '/crs_epsg4326'; diff --git a/example/lib/pages/fallback_url_page.dart b/example/lib/pages/fallback_url_page.dart index 47128cc96..858f997f5 100644 --- a/example/lib/pages/fallback_url_page.dart +++ b/example/lib/pages/fallback_url_page.dart @@ -3,7 +3,6 @@ import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_tile_provider.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; import 'package:flutter_map_example/widgets/notice_banner.dart'; -import 'package:latlong2/latlong.dart'; class FallbackUrlPage extends StatelessWidget { static const String route = '/fallback_url'; diff --git a/example/lib/pages/home.dart b/example/lib/pages/home.dart index 7146718f5..025490513 100644 --- a/example/lib/pages/home.dart +++ b/example/lib/pages/home.dart @@ -6,7 +6,6 @@ import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/floating_menu_button.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; import 'package:flutter_map_example/widgets/first_start_dialog.dart'; -import 'package:latlong2/latlong.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:url_launcher/url_launcher.dart'; diff --git a/example/lib/pages/interactive_test_page.dart b/example/lib/pages/interactive_test_page.dart index 4caae0b37..c2991b6aa 100644 --- a/example/lib/pages/interactive_test_page.dart +++ b/example/lib/pages/interactive_test_page.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class InteractiveFlagsPage extends StatefulWidget { static const String route = '/interactive_flags_page'; diff --git a/example/lib/pages/latlng_to_screen_point.dart b/example/lib/pages/latlng_to_screen_point.dart index c654606c8..fc27b2bf6 100644 --- a/example/lib/pages/latlng_to_screen_point.dart +++ b/example/lib/pages/latlng_to_screen_point.dart @@ -5,7 +5,6 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class LatLngToScreenPointPage extends StatefulWidget { static const String route = '/latlng_to_screen_point'; diff --git a/example/lib/pages/many_circles.dart b/example/lib/pages/many_circles.dart index e8a1fec33..979f11e71 100644 --- a/example/lib/pages/many_circles.dart +++ b/example/lib/pages/many_circles.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; const maxCirclesCount = 20000; diff --git a/example/lib/pages/many_markers.dart b/example/lib/pages/many_markers.dart index e5a1a3c8e..34eac79af 100644 --- a/example/lib/pages/many_markers.dart +++ b/example/lib/pages/many_markers.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; const maxMarkersCount = 20000; diff --git a/example/lib/pages/map_controller.dart b/example/lib/pages/map_controller.dart index 60f7ddb5e..9ec2bff35 100644 --- a/example/lib/pages/map_controller.dart +++ b/example/lib/pages/map_controller.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class MapControllerPage extends StatefulWidget { static const String route = 'map_controller'; diff --git a/example/lib/pages/map_inside_listview.dart b/example/lib/pages/map_inside_listview.dart index 5d0bf2600..16ccb6a6c 100644 --- a/example/lib/pages/map_inside_listview.dart +++ b/example/lib/pages/map_inside_listview.dart @@ -3,7 +3,6 @@ import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/plugins/zoombuttons_plugin.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class MapInsideListViewPage extends StatelessWidget { static const String route = '/map_inside_listview'; diff --git a/example/lib/pages/markers.dart b/example/lib/pages/markers.dart index ff98b3bef..cc41d4089 100644 --- a/example/lib/pages/markers.dart +++ b/example/lib/pages/markers.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class MarkerPage extends StatefulWidget { static const String route = '/markers'; diff --git a/example/lib/pages/moving_markers.dart b/example/lib/pages/moving_markers.dart index cf9287c67..ee1a0f5d1 100644 --- a/example/lib/pages/moving_markers.dart +++ b/example/lib/pages/moving_markers.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class MovingMarkersPage extends StatefulWidget { static const String route = '/moving_markers'; diff --git a/example/lib/pages/overlay_image.dart b/example/lib/pages/overlay_image.dart index d6fc6096e..45a2e3f50 100644 --- a/example/lib/pages/overlay_image.dart +++ b/example/lib/pages/overlay_image.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class OverlayImagePage extends StatelessWidget { static const String route = '/overlay_image'; diff --git a/example/lib/pages/plugin_scalebar.dart b/example/lib/pages/plugin_scalebar.dart index c2c87f069..a5308e973 100644 --- a/example/lib/pages/plugin_scalebar.dart +++ b/example/lib/pages/plugin_scalebar.dart @@ -3,7 +3,6 @@ import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/plugins/scale_layer_plugin_option.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class PluginScaleBar extends StatelessWidget { static const String route = '/plugin_scalebar'; diff --git a/example/lib/pages/plugin_zoombuttons.dart b/example/lib/pages/plugin_zoombuttons.dart index d30bbb1de..7ddd98fac 100644 --- a/example/lib/pages/plugin_zoombuttons.dart +++ b/example/lib/pages/plugin_zoombuttons.dart @@ -3,7 +3,6 @@ import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/plugins/zoombuttons_plugin.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class PluginZoomButtons extends StatelessWidget { static const String route = '/plugin_zoombuttons'; diff --git a/example/lib/pages/polygon.dart b/example/lib/pages/polygon.dart index 4cb5b0195..a91293f0e 100644 --- a/example/lib/pages/polygon.dart +++ b/example/lib/pages/polygon.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class PolygonPage extends StatelessWidget { static const String route = '/polygon'; diff --git a/example/lib/pages/polyline.dart b/example/lib/pages/polyline.dart index 1b2451b3e..8dc9f1875 100644 --- a/example/lib/pages/polyline.dart +++ b/example/lib/pages/polyline.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class PolylinePage extends StatefulWidget { static const String route = '/polyline'; diff --git a/example/lib/pages/reset_tile_layer.dart b/example/lib/pages/reset_tile_layer.dart index 51db34e2c..475a1d79b 100644 --- a/example/lib/pages/reset_tile_layer.dart +++ b/example/lib/pages/reset_tile_layer.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_tile_provider.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class ResetTileLayerPage extends StatefulWidget { static const String route = '/reset_tilelayer'; diff --git a/example/lib/pages/retina.dart b/example/lib/pages/retina.dart index f82fd1911..91626d503 100644 --- a/example/lib/pages/retina.dart +++ b/example/lib/pages/retina.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; import 'package:url_launcher/url_launcher.dart'; class RetinaPage extends StatefulWidget { diff --git a/example/lib/pages/screen_point_to_latlng.dart b/example/lib/pages/screen_point_to_latlng.dart index 80e9b9725..ff8319930 100644 --- a/example/lib/pages/screen_point_to_latlng.dart +++ b/example/lib/pages/screen_point_to_latlng.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class ScreenPointToLatLngPage extends StatefulWidget { static const String route = '/screen_point_to_latlng'; diff --git a/example/lib/pages/secondary_tap.dart b/example/lib/pages/secondary_tap.dart index 20e8e1169..ec4d8fa4e 100644 --- a/example/lib/pages/secondary_tap.dart +++ b/example/lib/pages/secondary_tap.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class SecondaryTapPage extends StatelessWidget { const SecondaryTapPage({super.key}); diff --git a/example/lib/pages/sliding_map.dart b/example/lib/pages/sliding_map.dart index 0529aeecf..bd59fc170 100644 --- a/example/lib/pages/sliding_map.dart +++ b/example/lib/pages/sliding_map.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class SlidingMapPage extends StatelessWidget { static const String route = '/sliding_map'; diff --git a/example/lib/pages/stateful_markers.dart b/example/lib/pages/stateful_markers.dart index 0ed95eeb5..5c0d70f91 100644 --- a/example/lib/pages/stateful_markers.dart +++ b/example/lib/pages/stateful_markers.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/misc/tile_providers.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class StatefulMarkersPage extends StatefulWidget { static const String route = '/stateful_markers'; diff --git a/example/lib/pages/tile_builder.dart b/example/lib/pages/tile_builder.dart index 079041d6c..0ce35426d 100644 --- a/example/lib/pages/tile_builder.dart +++ b/example/lib/pages/tile_builder.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_tile_provider.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class TileBuilderPage extends StatefulWidget { static const String route = '/tile_builder'; diff --git a/example/lib/pages/tile_loading_error_handle.dart b/example/lib/pages/tile_loading_error_handle.dart index f7139ac79..27bf99585 100644 --- a/example/lib/pages/tile_loading_error_handle.dart +++ b/example/lib/pages/tile_loading_error_handle.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_tile_provider.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; class TileLoadingErrorHandle extends StatefulWidget { static const String route = '/tile_loading_error_handle'; diff --git a/example/lib/pages/wms_tile_layer.dart b/example/lib/pages/wms_tile_layer.dart index 61bdec3d6..e6dc6c0c4 100644 --- a/example/lib/pages/wms_tile_layer.dart +++ b/example/lib/pages/wms_tile_layer.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; -import 'package:latlong2/latlong.dart'; import 'package:url_launcher/url_launcher.dart'; class WMSLayerPage extends StatelessWidget { diff --git a/example/lib/plugins/scalebar_utils.dart b/example/lib/plugins/scalebar_utils.dart index 3c75451e5..281aa5a80 100644 --- a/example/lib/plugins/scalebar_utils.dart +++ b/example/lib/plugins/scalebar_utils.dart @@ -1,7 +1,7 @@ import 'dart:math'; import 'dart:ui'; -import 'package:latlong2/latlong.dart'; +import 'package:flutter_map/flutter_map.dart'; import 'package:vector_math/vector_math_64.dart'; LatLng calculateEndingGlobalCoordinates( @@ -16,7 +16,7 @@ LatLng calculateEndingGlobalCoordinates( const aSquared = a * a; const bSquared = b * b; const f = mFlattening; - final phi1 = degrees2Radians * start.latitude; + final phi1 = degrees2Radians * start.lat; final alpha1 = degrees2Radians * startBearing; final cosAlpha1 = cos(alpha1); final sinAlpha1 = sin(alpha1); @@ -128,8 +128,8 @@ LatLng calculateEndingGlobalCoordinates( // cosSigma * cosAlpha1); // build result - return LatLng( - clampDouble(radians2Degrees * phi2, -90, 90), - clampDouble(start.longitude + (L * radians2Degrees), -180, 180), + return ( + lat: clampDouble(radians2Degrees * phi2, -90, 90), + lon: clampDouble(start.lon + (L * radians2Degrees), -180, 180), ); } diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index 635fcc6e4..17d596182 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -164,7 +164,7 @@ class PolylinePainter extends CustomPainter { polyline.strokeWidth, 180, ); - final delta = firstOffset - getOffset(map, origin, r); + final delta = firstOffset - getOffset(map, origin, (lat: r.latitude, lon: r.longitude)); strokeWidth = delta.distance; } else { diff --git a/lib/src/misc/offsets.dart b/lib/src/misc/offsets.dart index c399a07ae..ecb954689 100644 --- a/lib/src/misc/offsets.dart +++ b/lib/src/misc/offsets.dart @@ -1,8 +1,8 @@ import 'dart:ui'; import 'package:flutter_map/src/geo/crs.dart'; +import 'package:flutter_map/src/geo/latlng.dart'; import 'package:flutter_map/src/map/camera/camera.dart'; -import 'package:latlong2/latlong.dart'; Offset getOffset(MapCamera camera, Offset origin, LatLng point) { final crs = camera.crs; From 217cb795b1caf7b3775b8b8216cdd4b54a5c8ef0 Mon Sep 17 00:00:00 2001 From: mootw Date: Sat, 2 Dec 2023 11:31:23 -0600 Subject: [PATCH 3/4] dart format --- example/lib/pages/many_markers.dart | 5 ++++- lib/src/geo/crs.dart | 3 +-- lib/src/geo/latlng.dart | 3 +-- lib/src/geo/latlng_bounds.dart | 6 +++--- lib/src/layer/polygon_layer/label.dart | 4 ++-- lib/src/layer/polyline_layer.dart | 3 ++- .../layer/tile_layer/tile_bounds/tile_bounds.dart | 12 ++++++++---- test/map/map_controller_test.dart | 2 +- 8 files changed, 22 insertions(+), 16 deletions(-) diff --git a/example/lib/pages/many_markers.dart b/example/lib/pages/many_markers.dart index 34eac79af..8a85a7e60 100644 --- a/example/lib/pages/many_markers.dart +++ b/example/lib/pages/many_markers.dart @@ -35,7 +35,10 @@ class ManyMarkersPageState extends State { for (var x = 0; x < maxMarkersCount; x++) { allMarkers.add( Marker( - point: (lat: doubleInRange(r, 37, 55), lon: doubleInRange(r, -9, 30)), + point: ( + lat: doubleInRange(r, 37, 55), + lon: doubleInRange(r, -9, 30) + ), height: 12, width: 12, child: ColoredBox(color: Colors.blue[900]!), diff --git a/lib/src/geo/crs.dart b/lib/src/geo/crs.dart index 2edc5552e..6fc8b872e 100644 --- a/lib/src/geo/crs.dart +++ b/lib/src/geo/crs.dart @@ -345,8 +345,7 @@ class _LonLat extends Projection { const _LonLat() : super(_bounds); @override - (double, double) projectXY(LatLng latlng) => - (latlng.lon, latlng.lat); + (double, double) projectXY(LatLng latlng) => (latlng.lon, latlng.lat); @override LatLng unprojectXY(double x, double y) => diff --git a/lib/src/geo/latlng.dart b/lib/src/geo/latlng.dart index b3a731684..a39f7a896 100644 --- a/lib/src/geo/latlng.dart +++ b/lib/src/geo/latlng.dart @@ -1,7 +1,6 @@ typedef LatLng = ({double lat, double lon}); - // use degrees2Radians from vector_math // regex to migrate: LatLng\((-*[0-9]+\.*[0-9]*), *-*([0-9]+\.*[0-9]*)\) -// replace with: (lat: $1, lon: $2) \ No newline at end of file +// replace with: (lat: $1, lon: $2) diff --git a/lib/src/geo/latlng_bounds.dart b/lib/src/geo/latlng_bounds.dart index c800ac866..e5cabc582 100644 --- a/lib/src/geo/latlng_bounds.dart +++ b/lib/src/geo/latlng_bounds.dart @@ -96,11 +96,11 @@ class LatLngBounds { */ final phi1 = southWest.lat * degrees2Radians; - final lambda1 = southWest.lon * degrees2Radians; + final lambda1 = southWest.lon * degrees2Radians; final phi2 = northEast.lat * degrees2Radians; - final dLambda = degrees2Radians * ( - northEast.lon - southWest.lon); // delta lambda = lambda2-lambda1 + final dLambda = degrees2Radians * + (northEast.lon - southWest.lon); // delta lambda = lambda2-lambda1 final bx = math.cos(phi2) * math.cos(dLambda); final by = math.cos(phi2) * math.sin(dLambda); diff --git a/lib/src/layer/polygon_layer/label.dart b/lib/src/layer/polygon_layer/label.dart index eccdf2c22..188df12fc 100644 --- a/lib/src/layer/polygon_layer/label.dart +++ b/lib/src/layer/polygon_layer/label.dart @@ -78,8 +78,8 @@ LatLng _computePolylabel(List points) { final labelPosition = polylabel( [ //TODO does this really need to be changed to a math.Point type? - List.generate(points.length, - (i) => math.Point(points[i].lon, points[i].lat)), + List.generate( + points.length, (i) => math.Point(points[i].lon, points[i].lat)), ], // "precision" is a bit of a misnomer. It's a threshold for when to stop // dividing-and-conquering the polygon in the hopes of finding a better diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index 17d596182..afdb9cac1 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -164,7 +164,8 @@ class PolylinePainter extends CustomPainter { polyline.strokeWidth, 180, ); - final delta = firstOffset - getOffset(map, origin, (lat: r.latitude, lon: r.longitude)); + final delta = firstOffset - + getOffset(map, origin, (lat: r.latitude, lon: r.longitude)); strokeWidth = delta.distance; } else { diff --git a/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart b/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart index 5f0158571..f7ac21c47 100644 --- a/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart +++ b/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart @@ -126,10 +126,12 @@ class WrappedTileBounds extends TileBounds { (int, int)? wrapX; if (crs.wrapLng case final wrapLng?) { final wrapXMin = - (crs.latLngToPoint((lat: 0, lon: wrapLng.$1), zoomDouble).x / _tileSize) + (crs.latLngToPoint((lat: 0, lon: wrapLng.$1), zoomDouble).x / + _tileSize) .floor(); final wrapXMax = - (crs.latLngToPoint((lat: 0, lon: wrapLng.$2), zoomDouble).x / _tileSize) + (crs.latLngToPoint((lat: 0, lon: wrapLng.$2), zoomDouble).x / + _tileSize) .ceil(); wrapX = (wrapXMin, wrapXMax - 1); } @@ -137,10 +139,12 @@ class WrappedTileBounds extends TileBounds { (int, int)? wrapY; if (crs.wrapLat case final wrapLat?) { final wrapYMin = - (crs.latLngToPoint((lat: wrapLat.$1, lon: 0), zoomDouble).y / _tileSize) + (crs.latLngToPoint((lat: wrapLat.$1, lon: 0), zoomDouble).y / + _tileSize) .floor(); final wrapYMax = - (crs.latLngToPoint((lat: wrapLat.$2, lon: 0), zoomDouble).y / _tileSize) + (crs.latLngToPoint((lat: wrapLat.$2, lon: 0), zoomDouble).y / + _tileSize) .ceil(); wrapY = (wrapYMin, wrapYMax - 1); } diff --git a/test/map/map_controller_test.dart b/test/map/map_controller_test.dart index 1ef3e7e38..5c7a7f05b 100644 --- a/test/map/map_controller_test.dart +++ b/test/map/map_controller_test.dart @@ -1118,7 +1118,7 @@ void main() { ), expectedBounds: LatLngBounds( const (lat: 3.921797222702341, lon: 29.273074295454474), - (lat: -1.0189308220167805, lon: 34.21692202272719), + (lat: -1.0189308220167805, lon: 34.21692202272719), ), expectedCenter: (lat: 1.4280748738291607, lon: 31.750488000000022), expectedZoom: 5.830074977832103, From 41cb957f7f773fc5003c197f800e8bdbb2499bdb Mon Sep 17 00:00:00 2001 From: mootw Date: Sat, 2 Dec 2023 11:41:21 -0600 Subject: [PATCH 4/4] remove duplicate import --- example/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 9bfb70643..b6b0839e9 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -18,7 +18,6 @@ dependencies: shared_preferences: ^2.2.1 url_strategy: ^0.2.0 http: ^1.1.0 - latlong2: ^0.9.0 vector_math: ^2.1.2 dependency_overrides: