From c4df50e69b7018cc3ba21ddf685775e23480cfc7 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:07:41 +0100 Subject: [PATCH] Squashed commit of the following: commit ec81782c50ebc9191885f48d886f2e9e0fdead80 Author: Luka S Date: Sat Dec 2 20:48:08 2023 +0000 chore: v6.1.0 release preparation (#1749) commit df40d8c49eedf9b861beedc46fa0fb2eec75388f Author: mootw Date: Sat Dec 2 10:49:29 2023 -0600 perf: avoid caching a single multiplication (#1743) commit ad8318b3a4791e911e816b91b7cc4b33b59d0f28 Author: Joscha <34318751+josxha@users.noreply.github.com> Date: Sat Dec 2 16:39:21 2023 +0100 refactor: example app plugins (#1744) commit c0829b4a33ba7268b9cb7b4099a6a308365fa722 Author: Joscha <34318751+josxha@users.noreply.github.com> Date: Sat Dec 2 16:31:38 2023 +0100 fix: `MapPosition.hashCode` value distribution (#1747) commit 51d3eda21dd6b020ca4d398f9e832ca6be23e524 Author: Luka S Date: Sat Dec 2 11:34:13 2023 +0000 revert: #1731 (#1745) Revert #1731 --- CHANGELOG.md | 44 +++++++++++++++- CONTRIBUTING.md | 15 +++--- example/android/app/build.gradle | 2 +- example/lib/main.dart | 4 +- .../lib/pages/animated_map_controller.dart | 1 + example/lib/pages/bundled_offline_map.dart | 1 + .../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/epsg3413_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 | 3 +- example/lib/pages/markers.dart | 1 + example/lib/pages/moving_markers.dart | 1 + example/lib/pages/overlay_image.dart | 1 + .../{plugins => pages}/plugin_scalebar.dart | 15 +++--- .../plugin_zoombuttons.dart | 3 +- 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 + .../lib/pages/tile_loading_error_handle.dart | 1 + example/lib/pages/wms_tile_layer.dart | 1 + .../scale_layer_plugin_option.dart | 50 ++++++++----------- .../{pages => plugins}/scalebar_utils.dart | 21 +++----- ...in_option.dart => zoombuttons_plugin.dart} | 0 example/lib/widgets/drawer/menu_drawer.dart | 4 +- example/pubspec.yaml | 4 +- lib/flutter_map.dart | 1 - lib/src/geo/latlng_bounds.dart | 6 ++- .../flutter_map_interactive_viewer.dart | 3 +- lib/src/map/camera/camera.dart | 18 ++----- lib/src/map/controller/internal.dart | 3 +- lib/src/misc/position.dart | 2 +- pubspec.yaml | 2 +- windowsApplicationInstallerSetup.iss | 2 +- 48 files changed, 141 insertions(+), 89 deletions(-) rename example/lib/{plugins => pages}/plugin_scalebar.dart (69%) rename example/lib/{plugins => pages}/plugin_zoombuttons.dart (89%) rename example/lib/{pages => plugins}/scale_layer_plugin_option.dart (79%) rename example/lib/{pages => plugins}/scalebar_utils.dart (89%) rename example/lib/plugins/{zoombuttons_plugin_option.dart => zoombuttons_plugin.dart} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad47e49c7..0f2e29111 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,50 @@ # Changelog -## [6.0.1] - 2023/10/XX +Please consider [donating](https://docs.fleaflet.dev/supporters#support-us) or [contributing](https://docs.fleaflet.dev/credits#contributing) if you're a fan of what we're doing and you'd like to support future releases! + +## [6.1.0] - 2023/12/02 + +Contains the following user-affecting changes: + +- 🟢 Added option to draw labels on top of all `Polygon`s in a layer - [#1707](https://github.com/fleaflet/flutter_map/pull/1707) +- (Released 'flutter_map_cancellable_tile_provider' [v2.0.0](https://pub.dev/packages/flutter_map_cancellable_tile_provider/changelog)) + +Contains the following user-affecting bug fixes: + +- Removed flutter_map text attribution when `RichAttributionWidget.showFlutterMapAttribution` is `false` - [#1712](https://github.com/fleaflet/flutter_map/pull/1712) +- Repaired `TileLayer.tileBounds` - [#1713](https://github.com/fleaflet/flutter_map/pull/1713) for [#1710](https://github.com/fleaflet/flutter_map/issues/1710) +- Added `doubleTapDragZoom` and `scrollWheelZoom` to `InteractiveFlag.all` - [#1726](https://github.com/fleaflet/flutter_map/pull/1726) for [#1725](https://github.com/fleaflet/flutter_map/issues/1725) +- Repaired correct movement for `CircleLayer` when panning - [#1735](https://github.com/fleaflet/flutter_map/pull/1735) +- Improved value distribution for `MapPosition.hashCode` - [#1747](https://github.com/fleaflet/flutter_map/pull/1747) + +Contains the following user-affecting performance improvements: + +- Optimized `Bounds` - [#1706](https://github.com/fleaflet/flutter_map/pull/1706) +- Avoided creating a new list on every frame unnecessarily - [#1708](https://github.com/fleaflet/flutter_map/pull/1708) +- Cull `Polygon` labels seperately (more strongly), and cache the `TextPainter` - [#1716](https://github.com/fleaflet/flutter_map/pull/1716) +- Avoided caching a single commonly-used multiplication - [#1743](https://github.com/fleaflet/flutter_map/pull/1743) + +Many thanks to these contributors (in no particular order): + +- @ignatz +- @amal-stack +- @Robbendebiene +- ... and all the maintainers + +And an additional special thanks to @ignatz for investing so much of their time into this project recently - we appreciate it! + +In other news: + +- A warm welcome to @josxha, who's recently joined the maintainer team +- We've also made some widespread minor improvmenents to the example application +- Check out the new [Showcase](https://docs.fleaflet.dev/showcase) page on our docs for some awesome projects +- We're working on some very exciting reworked features and performance improvements for v7 - keep an ear out by joining our [Discord server](https://discord.gg/BwpEsjqMAH) + +## [6.0.1] - 2023/10/24 Contains the following user-affecting bug fixes: -- Fixed `CircleMarker`'s incorrect appearance and size - [#1692](https://github.com/fleaflet/flutter_map/pull/1692) for [#1688](https://github.com/fleaflet/flutter_map/issues/1688) +- Fixed `CircleMarker`'s incorrect appearance and size - [#1692](https://github.com/fleaflet/flutter_map/pull/1692) for [#1688](https://github.com/fleaflet/flutter_map/issues/1688) - Fixed `LateInitializationError` when specifying `initialCameraFit` - [#1691](https://github.com/fleaflet/flutter_map/pull/1691) for [#1684](https://github.com/fleaflet/flutter_map/issues/1684) - Fixed incorrect behaviour issues caused by the adjusted default `MapOptions.cameraConstraint` - [#1700](https://github.com/fleaflet/flutter_map/pull/1700) for [#1682](https://github.com/fleaflet/flutter_map/issues/1682) & [#1699](https://github.com/fleaflet/flutter_map/issues/1699) - Fixed bug where not providing either `wmsOptions` nor `urlTemplate` caused a null exception in `getTileUrl` and when `retinaMode` is `true` - [#1701](https://github.com/fleaflet/flutter_map/pull/1701) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f8c11770b..63998ca1f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,14 +1,15 @@ # Contributing -'flutter_map' is only as great as it is because of generous open-source contributors! - We're always happy to receive improvements and fixes, so please submit them whenever you can! A few key points are listed below. > Many feature additions are more suitable for plugins, instead of being added to the core. This is aimed to reduce the future maintenance burden/cost on the maintainers. If we deny your PR for this reason, please do consider publishing a plugin, and we'll be happy to add it to the [Plugins List](https://docs.fleaflet.dev/plugins/list)! See [Making A Plugin](https://docs.fleaflet.dev/plugins/making-a-plugin) for more information. -* If your PR will add a major or breaking change, please discuss it with us first, via the Issue Tracker -* Always link your PR to at least one issue, and as many as are resolved -* Create a draft PR as soon as work starts, and take it out of draft status when ready for review -* Avoid changing the package version or GitHub workflows -* Fix issues reported by the GitHub workflows (such as formatting) yourself +* **If your PR will add a major or breaking change, please discuss it with us first, via the Issue Tracker** +We don't want to waste your time if we think it's more appropriate for a plugin, and it helps to make a clear plan before starting work +* **Create a draft PR as soon as work starts, and take it out of draft status when ready for review** +Keep everyone in the loop, so no-one tries working on the same thing as you +* **Don't change the package version, GitHub workflows, lints, or any other meta files without clarification** +We rely on a standardized process and procedure to ensure top-quality releases +* **Use a clear (preferably [Conventional](https://www.conventionalcommits.org/)) PR title** +This makes it easier for us to group commits for release and write correct CHANGELOGs diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index de1ae64a5..71eb09906 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -19,7 +19,7 @@ if (flutterVersionCode == null) { def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { - flutterVersionName = '6.0.1' + flutterVersionName = '6.1.0' } android { diff --git a/example/lib/main.dart b/example/lib/main.dart index 993a0da6d..dfa3974aa 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -17,6 +17,8 @@ import 'package:flutter_map_example/pages/map_inside_listview.dart'; import 'package:flutter_map_example/pages/markers.dart'; import 'package:flutter_map_example/pages/moving_markers.dart'; import 'package:flutter_map_example/pages/overlay_image.dart'; +import 'package:flutter_map_example/pages/plugin_scalebar.dart'; +import 'package:flutter_map_example/pages/plugin_zoombuttons.dart'; import 'package:flutter_map_example/pages/polygon.dart'; import 'package:flutter_map_example/pages/polyline.dart'; import 'package:flutter_map_example/pages/reset_tile_layer.dart'; @@ -28,8 +30,6 @@ import 'package:flutter_map_example/pages/stateful_markers.dart'; import 'package:flutter_map_example/pages/tile_builder.dart'; import 'package:flutter_map_example/pages/tile_loading_error_handle.dart'; import 'package:flutter_map_example/pages/wms_tile_layer.dart'; -import 'package:flutter_map_example/plugins/plugin_scalebar.dart'; -import 'package:flutter_map_example/plugins/plugin_zoombuttons.dart'; import 'package:url_strategy/url_strategy.dart'; void main() { diff --git a/example/lib/pages/animated_map_controller.dart b/example/lib/pages/animated_map_controller.dart index 313a3fbad..b4cc4fdb6 100644 --- a/example/lib/pages/animated_map_controller.dart +++ b/example/lib/pages/animated_map_controller.dart @@ -2,6 +2,7 @@ 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 e64ca9da1..dff0ebc34 100644 --- a/example/lib/pages/bundled_offline_map.dart +++ b/example/lib/pages/bundled_offline_map.dart @@ -1,6 +1,7 @@ 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 ec3de2fe8..aac67c461 100644 --- a/example/lib/pages/cancellable_tile_provider.dart +++ b/example/lib/pages/cancellable_tile_provider.dart @@ -3,6 +3,7 @@ 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 4d98a03ee..ed9363b22 100644 --- a/example/lib/pages/circle.dart +++ b/example/lib/pages/circle.dart @@ -2,6 +2,7 @@ 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 96d589cf8..9d7589e35 100644 --- a/example/lib/pages/custom_crs/custom_crs.dart +++ b/example/lib/pages/custom_crs/custom_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'; import 'package:proj4dart/proj4dart.dart' as proj4; import 'package:url_launcher/url_launcher.dart'; diff --git a/example/lib/pages/epsg3413_crs.dart b/example/lib/pages/epsg3413_crs.dart index a3c31986d..b72fb1c36 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'; 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 5b46d34db..76f088005 100644 --- a/example/lib/pages/epsg4326_crs.dart +++ b/example/lib/pages/epsg4326_crs.dart @@ -1,6 +1,7 @@ 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 893b34f54..49289772c 100644 --- a/example/lib/pages/fallback_url_page.dart +++ b/example/lib/pages/fallback_url_page.dart @@ -3,6 +3,7 @@ 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 ba3e1fbe7..2cf3c2f0b 100644 --- a/example/lib/pages/home.dart +++ b/example/lib/pages/home.dart @@ -6,6 +6,7 @@ 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 69db1cb79..8c0cb518b 100644 --- a/example/lib/pages/interactive_test_page.dart +++ b/example/lib/pages/interactive_test_page.dart @@ -2,6 +2,7 @@ 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 eacdd994c..4b35f2920 100644 --- a/example/lib/pages/latlng_to_screen_point.dart +++ b/example/lib/pages/latlng_to_screen_point.dart @@ -5,6 +5,7 @@ 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 93f48bb44..68ea62d8a 100644 --- a/example/lib/pages/many_circles.dart +++ b/example/lib/pages/many_circles.dart @@ -4,6 +4,7 @@ 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 4c7aa6e08..5b19aa8fb 100644 --- a/example/lib/pages/many_markers.dart +++ b/example/lib/pages/many_markers.dart @@ -4,6 +4,7 @@ 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 7f930b0a6..212305dab 100644 --- a/example/lib/pages/map_controller.dart +++ b/example/lib/pages/map_controller.dart @@ -2,6 +2,7 @@ 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 d57d10094..39d871b6b 100644 --- a/example/lib/pages/map_inside_listview.dart +++ b/example/lib/pages/map_inside_listview.dart @@ -1,8 +1,9 @@ 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/plugins/zoombuttons_plugin_option.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 d62caa16d..5431481d2 100644 --- a/example/lib/pages/markers.dart +++ b/example/lib/pages/markers.dart @@ -2,6 +2,7 @@ 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 5d80dedeb..e2f33263a 100644 --- a/example/lib/pages/moving_markers.dart +++ b/example/lib/pages/moving_markers.dart @@ -4,6 +4,7 @@ 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 e79b3457a..761927b3c 100644 --- a/example/lib/pages/overlay_image.dart +++ b/example/lib/pages/overlay_image.dart @@ -2,6 +2,7 @@ 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/plugins/plugin_scalebar.dart b/example/lib/pages/plugin_scalebar.dart similarity index 69% rename from example/lib/plugins/plugin_scalebar.dart rename to example/lib/pages/plugin_scalebar.dart index 646675071..42b16e3a9 100644 --- a/example/lib/plugins/plugin_scalebar.dart +++ b/example/lib/pages/plugin_scalebar.dart @@ -1,8 +1,9 @@ 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/pages/scale_layer_plugin_option.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'; @@ -22,13 +23,11 @@ class PluginScaleBar extends StatelessWidget { ), children: [ openStreetMapTileLayer, - ScaleLayerWidget( - options: ScaleLayerPluginOption( - lineColor: Colors.black, - lineWidth: 3, - textStyle: const TextStyle(color: Colors.black, fontSize: 14), - padding: const EdgeInsets.all(10), - ), + const FlutterMapScaleLayer( + lineColor: Colors.black, + lineWidth: 3, + textStyle: TextStyle(color: Colors.black, fontSize: 14), + padding: EdgeInsets.all(10), ), ], ), diff --git a/example/lib/plugins/plugin_zoombuttons.dart b/example/lib/pages/plugin_zoombuttons.dart similarity index 89% rename from example/lib/plugins/plugin_zoombuttons.dart rename to example/lib/pages/plugin_zoombuttons.dart index 12b5ff876..4da4d9246 100644 --- a/example/lib/plugins/plugin_zoombuttons.dart +++ b/example/lib/pages/plugin_zoombuttons.dart @@ -1,8 +1,9 @@ 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/plugins/zoombuttons_plugin_option.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 e16418ef4..d9a459657 100644 --- a/example/lib/pages/polygon.dart +++ b/example/lib/pages/polygon.dart @@ -2,6 +2,7 @@ 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 9cecc5fb8..66aa35fce 100644 --- a/example/lib/pages/polyline.dart +++ b/example/lib/pages/polyline.dart @@ -2,6 +2,7 @@ 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 3e80e5ea2..e30abb7eb 100644 --- a/example/lib/pages/reset_tile_layer.dart +++ b/example/lib/pages/reset_tile_layer.dart @@ -4,6 +4,7 @@ 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 75aa02dbb..eede4f5f0 100644 --- a/example/lib/pages/retina.dart +++ b/example/lib/pages/retina.dart @@ -1,6 +1,7 @@ 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 b7b77884a..02d08ccb7 100644 --- a/example/lib/pages/screen_point_to_latlng.dart +++ b/example/lib/pages/screen_point_to_latlng.dart @@ -4,6 +4,7 @@ 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 220b56f60..38a1db895 100644 --- a/example/lib/pages/secondary_tap.dart +++ b/example/lib/pages/secondary_tap.dart @@ -2,6 +2,7 @@ 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 dcf6f8a5a..c15a32459 100644 --- a/example/lib/pages/sliding_map.dart +++ b/example/lib/pages/sliding_map.dart @@ -1,6 +1,7 @@ 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 2c44f9dc5..da9a7d895 100644 --- a/example/lib/pages/stateful_markers.dart +++ b/example/lib/pages/stateful_markers.dart @@ -4,6 +4,7 @@ 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 88ada2901..25ddf4dc4 100644 --- a/example/lib/pages/tile_builder.dart +++ b/example/lib/pages/tile_builder.dart @@ -2,6 +2,7 @@ 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 a2a53cc42..4b328d0ea 100644 --- a/example/lib/pages/tile_loading_error_handle.dart +++ b/example/lib/pages/tile_loading_error_handle.dart @@ -2,6 +2,7 @@ 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 49f1a6e7e..484da0031 100644 --- a/example/lib/pages/wms_tile_layer.dart +++ b/example/lib/pages/wms_tile_layer.dart @@ -1,6 +1,7 @@ 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/pages/scale_layer_plugin_option.dart b/example/lib/plugins/scale_layer_plugin_option.dart similarity index 79% rename from example/lib/pages/scale_layer_plugin_option.dart rename to example/lib/plugins/scale_layer_plugin_option.dart index 40dd91c18..c21caaada 100644 --- a/example/lib/pages/scale_layer_plugin_option.dart +++ b/example/lib/plugins/scale_layer_plugin_option.dart @@ -3,24 +3,9 @@ import 'dart:ui' as ui; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:flutter_map_example/pages/scalebar_utils.dart'; +import 'package:flutter_map_example/plugins/scalebar_utils.dart'; -class ScaleLayerPluginOption { - TextStyle? textStyle; - Color lineColor; - double lineWidth; - final EdgeInsets? padding; - - ScaleLayerPluginOption({ - this.textStyle, - this.lineColor = Colors.white, - this.lineWidth = 2, - this.padding, - }); -} - -class ScaleLayerWidget extends StatelessWidget { - final ScaleLayerPluginOption options; +class FlutterMapScaleLayer extends StatelessWidget { static const scale = [ 25000000, 15000000, @@ -46,18 +31,27 @@ class ScaleLayerWidget extends StatelessWidget { 10, 5 ]; + final TextStyle? textStyle; + final Color lineColor; + final double lineWidth; + final EdgeInsets? padding; - const ScaleLayerWidget({super.key, required this.options}); + const FlutterMapScaleLayer({ + super.key, + this.textStyle, + this.lineColor = Colors.white, + this.lineWidth = 2, + this.padding, + }); @override Widget build(BuildContext context) { - final map = MapCamera.of(context); - final zoom = map.zoom; - final distance = scale[max(0, min(20, zoom.round() + 2))].toDouble(); - final center = map.center; - final start = map.project(center); + final camera = MapCamera.of(context); + final distance = scale[max(0, min(20, camera.zoom.round() + 2))].toDouble(); + final center = camera.center; + final start = camera.project(center); final targetPoint = calculateEndingGlobalCoordinates(center, 90, distance); - final end = map.project(targetPoint); + final end = camera.project(targetPoint); final displayDistance = distance > 999 ? '${(distance / 1000).toStringAsFixed(0)} km' : '${distance.toStringAsFixed(0)} m'; @@ -69,10 +63,10 @@ class ScaleLayerWidget extends StatelessWidget { painter: ScalePainter( width, displayDistance, - lineColor: options.lineColor, - lineWidth: options.lineWidth, - padding: options.padding, - textStyle: options.textStyle, + lineColor: lineColor, + lineWidth: lineWidth, + padding: padding, + textStyle: textStyle, ), ); }, diff --git a/example/lib/pages/scalebar_utils.dart b/example/lib/plugins/scalebar_utils.dart similarity index 89% rename from example/lib/pages/scalebar_utils.dart rename to example/lib/plugins/scalebar_utils.dart index 97f57ef1c..3c75451e5 100644 --- a/example/lib/pages/scalebar_utils.dart +++ b/example/lib/plugins/scalebar_utils.dart @@ -1,17 +1,8 @@ import 'dart:math'; import 'dart:ui'; -import 'package:flutter_map/flutter_map.dart'; - -const double piOver180 = pi / 180.0; - -double toDegrees(double radians) { - return radians / piOver180; -} - -double toRadians(double degrees) { - return degrees * piOver180; -} +import 'package:latlong2/latlong.dart'; +import 'package:vector_math/vector_math_64.dart'; LatLng calculateEndingGlobalCoordinates( LatLng start, double startBearing, double distance) { @@ -25,8 +16,8 @@ LatLng calculateEndingGlobalCoordinates( const aSquared = a * a; const bSquared = b * b; const f = mFlattening; - final phi1 = toRadians(start.latitude); - final alpha1 = toRadians(startBearing); + final phi1 = degrees2Radians * start.latitude; + final alpha1 = degrees2Radians * startBearing; final cosAlpha1 = cos(alpha1); final sinAlpha1 = sin(alpha1); final s = distance; @@ -138,7 +129,7 @@ LatLng calculateEndingGlobalCoordinates( // build result return LatLng( - clampDouble(toDegrees(phi2), -90, 90), - clampDouble(start.longitude + toDegrees(L), -180, 180), + clampDouble(radians2Degrees * phi2, -90, 90), + clampDouble(start.longitude + (L * radians2Degrees), -180, 180), ); } diff --git a/example/lib/plugins/zoombuttons_plugin_option.dart b/example/lib/plugins/zoombuttons_plugin.dart similarity index 100% rename from example/lib/plugins/zoombuttons_plugin_option.dart rename to example/lib/plugins/zoombuttons_plugin.dart diff --git a/example/lib/widgets/drawer/menu_drawer.dart b/example/lib/widgets/drawer/menu_drawer.dart index 4d0d8e6cf..d3bf254fc 100644 --- a/example/lib/widgets/drawer/menu_drawer.dart +++ b/example/lib/widgets/drawer/menu_drawer.dart @@ -17,6 +17,8 @@ import 'package:flutter_map_example/pages/map_inside_listview.dart'; import 'package:flutter_map_example/pages/markers.dart'; import 'package:flutter_map_example/pages/moving_markers.dart'; import 'package:flutter_map_example/pages/overlay_image.dart'; +import 'package:flutter_map_example/pages/plugin_scalebar.dart'; +import 'package:flutter_map_example/pages/plugin_zoombuttons.dart'; import 'package:flutter_map_example/pages/polygon.dart'; import 'package:flutter_map_example/pages/polyline.dart'; import 'package:flutter_map_example/pages/reset_tile_layer.dart'; @@ -28,8 +30,6 @@ import 'package:flutter_map_example/pages/stateful_markers.dart'; import 'package:flutter_map_example/pages/tile_builder.dart'; import 'package:flutter_map_example/pages/tile_loading_error_handle.dart'; import 'package:flutter_map_example/pages/wms_tile_layer.dart'; -import 'package:flutter_map_example/plugins/plugin_scalebar.dart'; -import 'package:flutter_map_example/plugins/plugin_zoombuttons.dart'; import 'package:flutter_map_example/widgets/drawer/menu_item.dart'; class MenuDrawer extends StatelessWidget { diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 312a4bdab..7298a7546 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_map_example description: Example application for 'flutter_map' package publish_to: "none" -version: 6.0.1 +version: 6.1.0 environment: sdk: ">=3.0.0 <4.0.0" @@ -12,11 +12,13 @@ dependencies: sdk: flutter flutter_map: flutter_map_cancellable_tile_provider: + latlong2: ^0.9.0 proj4dart: ^2.1.0 url_launcher: ^6.1.14 shared_preferences: ^2.2.1 url_strategy: ^0.2.0 http: ^1.1.0 + vector_math: ^2.1.2 dependency_overrides: flutter_map_cancellable_tile_provider: diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index 907eee917..aad7d80b8 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -60,4 +60,3 @@ 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'; diff --git a/lib/src/geo/latlng_bounds.dart b/lib/src/geo/latlng_bounds.dart index 72f664ae9..ddf841c00 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:vector_math/vector_math_64.dart'; /// Data structure representing rectangular bounding box constrained by its /// northwest and southeast corners @@ -98,8 +99,9 @@ class LatLngBounds { final lambda1 = southWest.longitudeInRad; final phi2 = northEast.latitudeInRad; - final dLambda = degToRadian(northEast.longitude - - southWest.longitude); // delta lambda = lambda2-lambda1 + final dLambda = degrees2Radians * + (northEast.longitude - + southWest.longitude); // 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/gestures/flutter_map_interactive_viewer.dart b/lib/src/gestures/flutter_map_interactive_viewer.dart index 083deac33..b1786dd92 100644 --- a/lib/src/gestures/flutter_map_interactive_viewer.dart +++ b/lib/src/gestures/flutter_map_interactive_viewer.dart @@ -16,6 +16,7 @@ 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, @@ -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/map/camera/camera.dart b/lib/src/map/camera/camera.dart index edf731b59..f5469433f 100644 --- a/lib/src/map/camera/camera.dart +++ b/lib/src/map/camera/camera.dart @@ -9,6 +9,7 @@ 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 => rotation * degrees2Radians; /// Calculates point value for the given [latLng] using this camera's /// [crs] and [zoom] (or the provided [zoom]). diff --git a/lib/src/map/controller/internal.dart b/lib/src/map/controller/internal.dart index 6746c5ab8..35bdec601 100644 --- a/lib/src/map/controller/internal.dart +++ b/lib/src/map/controller/internal.dart @@ -13,6 +13,7 @@ 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(degrees2Radians * rotationDiff), ), camera.zoom, offset: Offset.zero, diff --git a/lib/src/misc/position.dart b/lib/src/misc/position.dart index 16c08317a..982c5c716 100644 --- a/lib/src/misc/position.dart +++ b/lib/src/misc/position.dart @@ -17,7 +17,7 @@ class MapPosition { }); @override - int get hashCode => center.hashCode + bounds.hashCode + zoom.hashCode; + int get hashCode => Object.hash(center, bounds, zoom); @override bool operator ==(Object other) => diff --git a/pubspec.yaml b/pubspec.yaml index 83a24aeb2..987e6898e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_map description: A versatile mapping package for Flutter, that's simple and easy to learn, yet completely customizable and configurable -version: 6.0.1 +version: 6.1.0 repository: https://github.com/fleaflet/flutter_map issue_tracker: https://github.com/fleaflet/flutter_map/issues diff --git a/windowsApplicationInstallerSetup.iss b/windowsApplicationInstallerSetup.iss index c68bd0381..654ab3fff 100644 --- a/windowsApplicationInstallerSetup.iss +++ b/windowsApplicationInstallerSetup.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "flutter_map Demo" -#define MyAppVersion "for 6.0.1" +#define MyAppVersion "for 6.1.0" #define MyAppPublisher "fleaflet" #define MyAppURL "https://github.com/fleaflet/flutter_map" #define MyAppSupportURL "https://github.com/fleaflet/flutter_map/issues"