From b941f27ed7dbbe76b592283c26a82713f79cf8b0 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Wed, 5 Jun 2024 11:05:07 +0200 Subject: [PATCH 1/6] rename Maplibre to MapLibre --- CHANGELOG.md | 14 ++--- README.md | 4 +- example/lib/animate_camera.dart | 6 +- example/lib/annotation_order_maps.dart | 14 ++--- example/lib/attribution.dart | 6 +- example/lib/click_annotations.dart | 6 +- example/lib/custom_marker.dart | 6 +- example/lib/full_map.dart | 6 +- example/lib/get_map_informations.dart | 6 +- example/lib/given_bounds.dart | 6 +- example/lib/layer.dart | 6 +- example/lib/line.dart | 6 +- example/lib/local_style.dart | 6 +- example/lib/localized_map.dart | 6 +- example/lib/main.dart | 6 +- example/lib/map_ui.dart | 10 ++-- example/lib/move_camera.dart | 6 +- example/lib/no_location_permission_page.dart | 2 +- example/lib/offline_region_map.dart | 2 +- example/lib/offline_regions.dart | 6 +- example/lib/place_batch.dart | 6 +- example/lib/place_circle.dart | 6 +- example/lib/place_fill.dart | 6 +- example/lib/place_source.dart | 6 +- example/lib/place_symbol.dart | 6 +- example/lib/scrolling_map.dart | 14 ++--- example/lib/sources.dart | 30 +++++----- example/lib/util.dart | 2 +- lib/maplibre_gl.dart | 22 +++---- lib/src/annotation_manager.dart | 2 +- lib/src/controller.dart | 20 +++---- lib/src/maplibre_map.dart | 58 +++++++++---------- lib/src/maplibre_styles.dart | 2 +- maplibre_gl_platform_interface/CHANGELOG.md | 2 +- maplibre_gl_platform_interface/README.md | 2 +- .../src/maplibre_gl_platform_interface.dart | 10 ++-- .../lib/src/method_channel_maplibre_gl.dart | 2 +- .../lib/src/ui.dart | 4 +- maplibre_gl_web/CHANGELOG.md | 2 +- maplibre_gl_web/README.md | 2 +- .../lib/src/maplibre_map_plugin.dart | 2 +- .../lib/src/maplibre_web_gl_platform.dart | 2 +- pubspec.yaml | 2 +- 43 files changed, 170 insertions(+), 170 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6149d74df..7ba0b6df7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * All Dart enums have been migrated from mixed cases to lower camelcase according to the `camel_case_types` lint rule. -* Move `MaplibreStyles` to the main `maplibre_gl` package. You can now use the +* Move `MapLibreStyles` to the main `maplibre_gl` package. You can now use the demo style without adding `maplibre_gl_platform_interface` as a dependency. * Updated maplibre-native for ios to v6.4.2. This introduces the new iOS Metal renderer and the OpenGL ES renderer now uses OpenGL ES 3.0. Only @@ -110,7 +110,7 @@ builds). ```dart @override Widget build() { - return MaplibreMap( + return MapLibreMap( myLocationRenderMode: MyLocationRenderMode.COMPASS, // ... ); @@ -158,7 +158,7 @@ at the end for a full changelog. in [#179](https://github.com/maplibre/flutter-maplibre-gl/pull/179) * Reenable textureMode which was disabled in f8b2d1 by @maxammann in [#194](https://github.com/maplibre/flutter-maplibre-gl/pull/194) -* android: Bump Maplibre SDK to 9.6.0 & OkHttp to 4.9.3 by @mariusvn +* android: Bump MapLibre SDK to 9.6.0 & OkHttp to 4.9.3 by @mariusvn in [#184](https://github.com/maplibre/flutter-maplibre-gl/pull/184) * Added getSourceIds to the controller by @mariusvn in [#197](https://github.com/maplibre/flutter-maplibre-gl/pull/197) @@ -166,7 +166,7 @@ at the end for a full changelog. in [#205](https://github.com/maplibre/flutter-maplibre-gl/pull/205) * Fix crash android dispose nullpointerdereference by @GaelleJoubert in [#203](https://github.com/maplibre/flutter-maplibre-gl/pull/203) -* Migrate links in README, pubspec to Maplibre by @kuhnroyal +* Migrate links in README, pubspec to MapLibre by @kuhnroyal in [#224](https://github.com/maplibre/flutter-maplibre-gl/pull/224) * Update LICENSE file by @mariusvn in [#230](https://github.com/maplibre/flutter-maplibre-gl/pull/230) @@ -209,7 +209,7 @@ https://github.com/maplibre/flutter-maplibre-gl/compare/0.16.0...0.17.0 * cherry-picked all commits from upstream up to [https://github.com/flutter-mapbox-gl/maps/commit/3496907955cd4b442e4eb905d67e8d46692174f1), including up to release 0.16.0 from upstream -* updated Maplibre GL JS for web +* updated MapLibre GL JS for web ## 0.15.1, May 24, 2022 @@ -267,11 +267,11 @@ https://github.com/maplibre/flutter-maplibre-gl/compare/0.16.0...0.17.0 ## 0.13.0, Oct 6, 2021 🎉 The first release of flutter-maplibre-gl with the complete transition to -Maplibre libraries. 🎉 +MapLibre libraries. 🎉 Further improvements: -* Update to Maplibre-Android-SDK 9.4.2 +* Update to MapLibre-Android-SDK 9.4.2 * Update to MapLibre-iOS-SDK 5.12.0 * Fix onUserLocationUpdated not firing on android [#14](https://github.com/m0nac0/flutter-maplibre-gl/pull/14) diff --git a/README.md b/README.md index 9d112afb0..6151a48fb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Flutter Maplibre GL +# Flutter MapLibre GL [![Pub Version](https://img.shields.io/pub/v/maplibre_gl)](https://pub.dev/packages/maplibre_gl) [![likes](https://img.shields.io/pub/likes/maplibre_gl?logo=flutter)](https://pub.dev/packages/maplibre_gl) @@ -126,7 +126,7 @@ your `web/index.html` file: ## Map Styles -Map styles can be supplied by setting the `styleString` in the `MaplibreMap` +Map styles can be supplied by setting the `styleString` in the `MapLibreMap` constructor. The following formats are supported: 1. Passing the URL of the map style. This should be a custom map style served diff --git a/example/lib/animate_camera.dart b/example/lib/animate_camera.dart index ad1e14792..ce1bb0424 100644 --- a/example/lib/animate_camera.dart +++ b/example/lib/animate_camera.dart @@ -25,9 +25,9 @@ class AnimateCamera extends StatefulWidget { } class AnimateCameraState extends State { - late MaplibreMapController mapController; + late MapLibreMapController mapController; - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { mapController = controller; } @@ -41,7 +41,7 @@ class AnimateCameraState extends State { child: SizedBox( width: 300.0, height: 200.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition(target: LatLng(0.0, 0.0)), diff --git a/example/lib/annotation_order_maps.dart b/example/lib/annotation_order_maps.dart index 37cd81ff0..9c00557a4 100644 --- a/example/lib/annotation_order_maps.dart +++ b/example/lib/annotation_order_maps.dart @@ -21,8 +21,8 @@ class AnnotationOrderBody extends StatefulWidget { } class _AnnotationOrderBodyState extends State { - late MaplibreMapController controllerOne; - late MaplibreMapController controllerTwo; + late MapLibreMapController controllerOne; + late MapLibreMapController controllerTwo; final LatLng center = const LatLng(36.580664, 32.5563837); @@ -44,7 +44,7 @@ class _AnnotationOrderBodyState extends State { child: SizedBox( width: 250.0, height: 250.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: onMapCreatedOne, onStyleLoadedCallback: () => onStyleLoaded(controllerOne), initialCameraPosition: CameraPosition( @@ -78,7 +78,7 @@ class _AnnotationOrderBodyState extends State { child: SizedBox( width: 250.0, height: 250.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: onMapCreatedTwo, onStyleLoadedCallback: () => onStyleLoaded(controllerTwo), initialCameraPosition: CameraPosition( @@ -102,15 +102,15 @@ class _AnnotationOrderBodyState extends State { ); } - void onMapCreatedOne(MaplibreMapController controller) { + void onMapCreatedOne(MapLibreMapController controller) { controllerOne = controller; } - void onMapCreatedTwo(MaplibreMapController controller) { + void onMapCreatedTwo(MapLibreMapController controller) { controllerTwo = controller; } - void onStyleLoaded(MaplibreMapController controller) async { + void onStyleLoaded(MapLibreMapController controller) async { await addImageFromAsset( controller, "custom-marker", "assets/symbols/custom-marker.png"); controller.addSymbol( diff --git a/example/lib/attribution.dart b/example/lib/attribution.dart index 8b17a869a..893da03a6 100644 --- a/example/lib/attribution.dart +++ b/example/lib/attribution.dart @@ -73,12 +73,12 @@ class _AttributionBodyState extends State { ); } - MaplibreMap buildMap( + MapLibreMap buildMap( AttributionButtonPosition? attributionButtonPosition, bool useDefaultAttributionPosition, ) { if (useDefaultAttributionPosition) { - return MaplibreMap( + return MapLibreMap( key: UniqueKey(), initialCameraPosition: const CameraPosition( target: LatLng(-33.852, 151.211), @@ -87,7 +87,7 @@ class _AttributionBodyState extends State { styleString: "assets/osm_style.json", ); } else { - return MaplibreMap( + return MapLibreMap( key: UniqueKey(), initialCameraPosition: const CameraPosition( target: LatLng(-33.852, 151.211), diff --git a/example/lib/click_annotations.dart b/example/lib/click_annotations.dart index 409254a88..10f7f7690 100644 --- a/example/lib/click_annotations.dart +++ b/example/lib/click_annotations.dart @@ -30,9 +30,9 @@ class ClickAnnotationBodyState extends State { static const LatLng center = LatLng(-33.88, 151.16); - MaplibreMapController? controller; + MapLibreMapController? controller; - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { this.controller = controller; controller.onFillTapped.add(_onFillTapped); controller.onCircleTapped.add(_onCircleTapped); @@ -139,7 +139,7 @@ class ClickAnnotationBodyState extends State { @override Widget build(BuildContext context) { - return MaplibreMap( + return MapLibreMap( annotationOrder: const [ AnnotationType.fill, AnnotationType.line, diff --git a/example/lib/custom_marker.dart b/example/lib/custom_marker.dart index c4ef10917..e202f1711 100644 --- a/example/lib/custom_marker.dart +++ b/example/lib/custom_marker.dart @@ -30,7 +30,7 @@ class CustomMarker extends StatefulWidget { class CustomMarkerState extends State { final _rnd = Random(); - late MaplibreMapController _mapController; + late MapLibreMapController _mapController; final _markers = []; final _markerStates = []; @@ -38,7 +38,7 @@ class CustomMarkerState extends State { _markerStates.add(markerState); } - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { _mapController = controller; controller.addListener(() { if (controller.isCameraMoving) { @@ -90,7 +90,7 @@ class CustomMarkerState extends State { Widget build(BuildContext context) { return Scaffold( body: Stack(children: [ - MaplibreMap( + MapLibreMap( trackCameraPosition: true, onMapCreated: _onMapCreated, onMapLongClick: _onMapLongClickCallback, diff --git a/example/lib/full_map.dart b/example/lib/full_map.dart index f852efc4a..13d2677fc 100644 --- a/example/lib/full_map.dart +++ b/example/lib/full_map.dart @@ -21,10 +21,10 @@ class FullMap extends StatefulWidget { } class FullMapState extends State { - MaplibreMapController? mapController; + MapLibreMapController? mapController; var isLight = true; - _onMapCreated(MaplibreMapController controller) { + _onMapCreated(MapLibreMapController controller) { mapController = controller; } @@ -52,7 +52,7 @@ class FullMapState extends State { // ), // ), // ), - body: MaplibreMap( + body: MapLibreMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition(target: LatLng(0.0, 0.0)), onStyleLoadedCallback: _onStyleLoadedCallback, diff --git a/example/lib/get_map_informations.dart b/example/lib/get_map_informations.dart index 2437a30d6..fcbe67ddc 100644 --- a/example/lib/get_map_informations.dart +++ b/example/lib/get_map_informations.dart @@ -21,10 +21,10 @@ class GetMapInfoBody extends StatefulWidget { } class _GetMapInfoBodyState extends State { - MaplibreMapController? controller; + MapLibreMapController? controller; String data = ''; - void onMapCreated(MaplibreMapController controller) { + void onMapCreated(MapLibreMapController controller) { setState(() { this.controller = controller; }); @@ -60,7 +60,7 @@ class _GetMapInfoBodyState extends State { child: SizedBox( width: 300.0, height: 200.0, - child: MaplibreMap( + child: MapLibreMap( initialCameraPosition: const CameraPosition( target: LatLng(-33.852, 151.211), zoom: 11.0, diff --git a/example/lib/given_bounds.dart b/example/lib/given_bounds.dart index 35e1c0226..f59a58983 100644 --- a/example/lib/given_bounds.dart +++ b/example/lib/given_bounds.dart @@ -25,9 +25,9 @@ class GivenBounds extends StatefulWidget { } class GivenBoundsState extends State { - late MaplibreMapController mapController; + late MapLibreMapController mapController; - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { mapController = controller; } @@ -41,7 +41,7 @@ class GivenBoundsState extends State { child: SizedBox( width: 300.0, height: 200.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition(target: LatLng(0.0, 0.0)), diff --git a/example/lib/layer.dart b/example/lib/layer.dart index c3b0c9cb3..50df8ec1d 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -24,7 +24,7 @@ class LayerBody extends StatefulWidget { class LayerState extends State { static const LatLng center = LatLng(-33.86711, 151.1947171); - late MaplibreMapController controller; + late MapLibreMapController controller; Timer? bikeTimer; Timer? filterTimer; int filteredId = 0; @@ -43,7 +43,7 @@ class LayerState extends State { Center( child: SizedBox( height: 400.0, - child: MaplibreMap( + child: MapLibreMap( dragEnabled: false, myLocationEnabled: true, onMapCreated: _onMapCreated, @@ -139,7 +139,7 @@ class LayerState extends State { ]); } - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { this.controller = controller; controller.onFeatureTapped.add(onFeatureTap); diff --git a/example/lib/line.dart b/example/lib/line.dart index a16a20009..b287441b3 100644 --- a/example/lib/line.dart +++ b/example/lib/line.dart @@ -31,12 +31,12 @@ class LineBodyState extends State { static const LatLng center = LatLng(-33.86711, 151.1947171); - MaplibreMapController? controller; + MapLibreMapController? controller; int _lineCount = 0; Line? _selectedLine; final String _linePatternImage = "assets/fill/cat_silhouette_pattern.png"; - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { this.controller = controller; controller.onLineTapped.add(_onLineTapped); } @@ -154,7 +154,7 @@ class LineBodyState extends State { Center( child: SizedBox( height: 400.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: _onMapCreated, onStyleLoadedCallback: _onStyleLoadedCallback, initialCameraPosition: const CameraPosition( diff --git a/example/lib/local_style.dart b/example/lib/local_style.dart index 5d49778c6..0ad4a84f1 100644 --- a/example/lib/local_style.dart +++ b/example/lib/local_style.dart @@ -24,7 +24,7 @@ class LocalStyle extends StatefulWidget { } class LocalStyleState extends State { - MaplibreMapController? mapController; + MapLibreMapController? mapController; String? styleAbsoluteFilePath; @override @@ -49,7 +49,7 @@ class LocalStyleState extends State { }); } - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { mapController = controller; } @@ -64,7 +64,7 @@ class LocalStyleState extends State { } return Scaffold( - body: MaplibreMap( + body: MapLibreMap( styleString: styleAbsoluteFilePath, onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition(target: LatLng(0.0, 0.0)), diff --git a/example/lib/localized_map.dart b/example/lib/localized_map.dart index 40eb49e00..ca22b4891 100644 --- a/example/lib/localized_map.dart +++ b/example/lib/localized_map.dart @@ -23,7 +23,7 @@ class LocalizedMap extends StatefulWidget { } class LocalizedMapState extends State { - final _mapReadyCompleter = Completer(); + final _mapReadyCompleter = Completer(); var _mapLanguage = "en"; @@ -51,7 +51,7 @@ class LocalizedMapState extends State { }).toList(), ), Expanded( - child: MaplibreMap( + child: MapLibreMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition(target: LatLng(0.0, 0.0)), @@ -63,7 +63,7 @@ class LocalizedMapState extends State { ); } - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { _mapReadyCompleter.complete(controller); } diff --git a/example/lib/main.dart b/example/lib/main.dart index 586ca4ca7..c54460f31 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -78,9 +78,9 @@ class _MapsDemoState extends State { final androidInfo = await DeviceInfoPlugin().androidInfo; final sdkVersion = androidInfo.version.sdkInt; if (sdkVersion >= 29) { - MaplibreMap.useHybridComposition = true; + MapLibreMap.useHybridComposition = true; } else { - MaplibreMap.useHybridComposition = false; + MapLibreMap.useHybridComposition = false; } } } @@ -106,7 +106,7 @@ class _MapsDemoState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: const Text('Maplibre examples')), + appBar: AppBar(title: const Text('MapLibre examples')), body: ListView.builder( itemCount: _allPages.length + 1, itemBuilder: (_, int index) => index == _allPages.length diff --git a/example/lib/map_ui.dart b/example/lib/map_ui.dart index cfabc6ec4..3d92ba060 100644 --- a/example/lib/map_ui.dart +++ b/example/lib/map_ui.dart @@ -39,7 +39,7 @@ class MapUiBodyState extends State { zoom: 11.0, ); - MaplibreMapController? mapController; + MapLibreMapController? mapController; CameraPosition _position = _kInitialPosition; bool _isMoving = false; bool _compassEnabled = true; @@ -50,9 +50,9 @@ class MapUiBodyState extends State { // Style string can a reference to a local or remote resources. // On Android the raw JSON can also be passed via a styleString, on iOS this is not supported. - final List _styleStrings = [MaplibreStyles.demo, "assets/style.json"]; + final List _styleStrings = [MapLibreStyles.demo, "assets/style.json"]; final List _styleStringLabels = [ - "Maplibre demo style", + "MapLibre demo style", "Local style file" ]; bool _rotateGesturesEnabled = true; @@ -343,7 +343,7 @@ class MapUiBodyState extends State { @override Widget build(BuildContext context) { - final MaplibreMap maplibreMap = MaplibreMap( + final MapLibreMap maplibreMap = MapLibreMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, trackCameraPosition: true, @@ -458,7 +458,7 @@ class MapUiBodyState extends State { ); } - void onMapCreated(MaplibreMapController controller) { + void onMapCreated(MapLibreMapController controller) { mapController = controller; mapController!.addListener(_onMapChanged); _extractMapInfo(); diff --git a/example/lib/move_camera.dart b/example/lib/move_camera.dart index db69d1488..879c72647 100644 --- a/example/lib/move_camera.dart +++ b/example/lib/move_camera.dart @@ -25,9 +25,9 @@ class MoveCamera extends StatefulWidget { } class MoveCameraState extends State { - late MaplibreMapController mapController; + late MapLibreMapController mapController; - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { mapController = controller; } @@ -41,7 +41,7 @@ class MoveCameraState extends State { child: SizedBox( width: 300.0, height: 200.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: _onMapCreated, onCameraIdle: () => debugPrint("onCameraIdle"), initialCameraPosition: diff --git a/example/lib/no_location_permission_page.dart b/example/lib/no_location_permission_page.dart index 4ab7b84ae..f0c283ca5 100644 --- a/example/lib/no_location_permission_page.dart +++ b/example/lib/no_location_permission_page.dart @@ -28,7 +28,7 @@ class NoLocationPermissionBody extends StatefulWidget { class _NoLocationPermissionBodyState extends State { @override Widget build(BuildContext context) { - return MaplibreMap( + return MapLibreMap( initialCameraPosition: const CameraPosition( target: LatLng(-33.852, 151.211), zoom: 11.0, diff --git a/example/lib/offline_region_map.dart b/example/lib/offline_region_map.dart index 52c9160d0..a5880ab1d 100644 --- a/example/lib/offline_region_map.dart +++ b/example/lib/offline_region_map.dart @@ -19,7 +19,7 @@ class _OfflineRegionMapState extends State { appBar: AppBar( title: Text('Offline Region: ${widget.item.name}'), ), - body: MaplibreMap( + body: MapLibreMap( initialCameraPosition: CameraPosition( target: _center, zoom: widget.item.offlineRegionDefinition.minZoom, diff --git a/example/lib/offline_regions.dart b/example/lib/offline_regions.dart index b9e4573e0..95a9f6040 100644 --- a/example/lib/offline_regions.dart +++ b/example/lib/offline_regions.dart @@ -25,19 +25,19 @@ final List regionDefinitions = [ bounds: hawaiiBounds, minZoom: 3.0, maxZoom: 8.0, - mapStyleUrl: MaplibreStyles.demo, + mapStyleUrl: MapLibreStyles.demo, ), OfflineRegionDefinition( bounds: santiagoBounds, minZoom: 10.0, maxZoom: 16.0, - mapStyleUrl: MaplibreStyles.demo, + mapStyleUrl: MapLibreStyles.demo, ), OfflineRegionDefinition( bounds: aucklandBounds, minZoom: 13.0, maxZoom: 16.0, - mapStyleUrl: MaplibreStyles.demo, + mapStyleUrl: MapLibreStyles.demo, ), ]; diff --git a/example/lib/place_batch.dart b/example/lib/place_batch.dart index e85fb23d2..9e2fbfd6a 100644 --- a/example/lib/place_batch.dart +++ b/example/lib/place_batch.dart @@ -71,9 +71,9 @@ class BatchAddBodyState extends State { static const LatLng center = LatLng(-33.86711, 151.1947171); - late MaplibreMapController controller; + late MapLibreMapController controller; - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { this.controller = controller; } @@ -148,7 +148,7 @@ class BatchAddBodyState extends State { Center( child: SizedBox( height: 200.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: _onMapCreated, onStyleLoadedCallback: () => addImageFromAsset(controller, "custom-marker", "assets/symbols/custom-marker.png"), diff --git a/example/lib/place_circle.dart b/example/lib/place_circle.dart index 04a66501a..2a7a32625 100644 --- a/example/lib/place_circle.dart +++ b/example/lib/place_circle.dart @@ -32,11 +32,11 @@ class PlaceCircleBodyState extends State { static const LatLng center = LatLng(-33.86711, 151.1947171); - MaplibreMapController? controller; + MapLibreMapController? controller; int _circleCount = 0; Circle? _selectedCircle; - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { this.controller = controller; controller.onCircleTapped.add(_onCircleTapped); } @@ -196,7 +196,7 @@ class PlaceCircleBodyState extends State { child: SizedBox( width: 300.0, height: 200.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition( target: LatLng(-33.852, 151.211), diff --git a/example/lib/place_fill.dart b/example/lib/place_fill.dart index b37470298..cc3e830de 100644 --- a/example/lib/place_fill.dart +++ b/example/lib/place_fill.dart @@ -49,11 +49,11 @@ class PlaceFillBodyState extends State { ] ]; - MaplibreMapController? controller; + MapLibreMapController? controller; int _fillCount = 0; Fill? _selectedFill; - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { this.controller = controller; controller.onFillTapped.add(_onFillTapped); this.controller!.onFeatureDrag.add(_onFeatureDrag); @@ -194,7 +194,7 @@ class PlaceFillBodyState extends State { child: SizedBox( width: 300.0, height: 200.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: _onMapCreated, onStyleLoadedCallback: _onStyleLoaded, initialCameraPosition: const CameraPosition( diff --git a/example/lib/place_source.dart b/example/lib/place_source.dart index 40b2ed0da..f59f8abd8 100644 --- a/example/lib/place_source.dart +++ b/example/lib/place_source.dart @@ -36,9 +36,9 @@ class PlaceSymbolBodyState extends State { bool sourceAdded = false; bool layerAdded = false; bool imageFlag = false; - late MaplibreMapController controller; + late MapLibreMapController controller; - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { this.controller = controller; } @@ -112,7 +112,7 @@ class PlaceSymbolBodyState extends State { child: SizedBox( width: 300.0, height: 200.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition( target: LatLng(-33.852, 151.211), diff --git a/example/lib/place_symbol.dart b/example/lib/place_symbol.dart index 1f4161a73..530e60a4a 100644 --- a/example/lib/place_symbol.dart +++ b/example/lib/place_symbol.dart @@ -35,12 +35,12 @@ class PlaceSymbolBodyState extends State { static const LatLng center = LatLng(-33.86711, 151.1947171); - MaplibreMapController? controller; + MapLibreMapController? controller; int _symbolCount = 0; Symbol? _selectedSymbol; bool _iconAllowOverlap = false; - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { this.controller = controller; controller.onSymbolTapped.add(_onSymbolTapped); } @@ -274,7 +274,7 @@ class PlaceSymbolBodyState extends State { child: SizedBox( width: 300.0, height: 200.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: _onMapCreated, onStyleLoadedCallback: _onStyleLoaded, initialCameraPosition: const CameraPosition( diff --git a/example/lib/scrolling_map.dart b/example/lib/scrolling_map.dart index e7e6f9fd5..059d59e66 100644 --- a/example/lib/scrolling_map.dart +++ b/example/lib/scrolling_map.dart @@ -29,8 +29,8 @@ class ScrollingMapBody extends StatefulWidget { } class _ScrollingMapBodyState extends State { - late MaplibreMapController controllerOne; - late MaplibreMapController controllerTwo; + late MapLibreMapController controllerOne; + late MapLibreMapController controllerTwo; final LatLng center = const LatLng(32.080664, 34.9563837); @@ -51,7 +51,7 @@ class _ScrollingMapBodyState extends State { child: SizedBox( width: 300.0, height: 300.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: onMapCreatedOne, onStyleLoadedCallback: () => onStyleLoaded(controllerOne), initialCameraPosition: CameraPosition( @@ -86,7 +86,7 @@ class _ScrollingMapBodyState extends State { child: SizedBox( width: 300.0, height: 300.0, - child: MaplibreMap( + child: MapLibreMap( onMapCreated: onMapCreatedTwo, onStyleLoadedCallback: () => onStyleLoaded(controllerTwo), initialCameraPosition: CameraPosition( @@ -110,15 +110,15 @@ class _ScrollingMapBodyState extends State { ); } - void onMapCreatedOne(MaplibreMapController controller) { + void onMapCreatedOne(MapLibreMapController controller) { controllerOne = controller; } - void onMapCreatedTwo(MaplibreMapController controller) { + void onMapCreatedTwo(MapLibreMapController controller) { controllerTwo = controller; } - void onStyleLoaded(MaplibreMapController controller) async { + void onStyleLoaded(MapLibreMapController controller) async { await addImageFromAsset( controller, "custom-marker", "assets/symbols/custom-marker.png"); controller.addSymbol(SymbolOptions( diff --git a/example/lib/sources.dart b/example/lib/sources.dart index e2538d4dd..265a7b7fa 100644 --- a/example/lib/sources.dart +++ b/example/lib/sources.dart @@ -7,7 +7,7 @@ import 'page.dart'; class StyleInfo { final String name; final String baseStyle; - final Future Function(MaplibreMapController) addDetails; + final Future Function(MapLibreMapController) addDetails; final CameraPosition position; const StyleInfo( @@ -34,15 +34,15 @@ class FullMap extends StatefulWidget { } class FullMapState extends State { - MaplibreMapController? controller; + MapLibreMapController? controller; final watercolorRasterId = "watercolorRaster"; int selectedStyleId = 0; - _onMapCreated(MaplibreMapController controller) { + _onMapCreated(MapLibreMapController controller) { this.controller = controller; } - static Future addRaster(MaplibreMapController controller) async { + static Future addRaster(MapLibreMapController controller) async { await controller.addSource( "watercolor", const RasterSourceProperties( @@ -58,7 +58,7 @@ class FullMapState extends State { } static Future addGeojsonCluster( - MaplibreMapController controller) async { + MapLibreMapController controller) async { await controller.addSource( "earthquakes", const GeojsonSourceProperties( @@ -99,11 +99,11 @@ class FullMapState extends State { )); } - static Future addVector(MaplibreMapController controller) async { + static Future addVector(MapLibreMapController controller) async { await controller.addSource( "terrain", const VectorSourceProperties( - url: MaplibreStyles.demo, + url: MapLibreStyles.demo, )); await controller.addLayer( @@ -118,7 +118,7 @@ class FullMapState extends State { sourceLayer: "countries"); } - static Future addImage(MaplibreMapController controller) async { + static Future addImage(MapLibreMapController controller) async { await controller.addSource( "radar", const ImageSourceProperties( @@ -137,7 +137,7 @@ class FullMapState extends State { ); } - static Future addVideo(MaplibreMapController controller) async { + static Future addVideo(MapLibreMapController controller) async { await controller.addSource( "video", const VideoSourceProperties(urls: [ @@ -157,7 +157,7 @@ class FullMapState extends State { ); } - static Future addHeatMap(MaplibreMapController controller) async { + static Future addHeatMap(MapLibreMapController controller) async { await controller.addSource( 'earthquakes-heatmap-source', const GeojsonSourceProperties( @@ -234,7 +234,7 @@ class FullMapState extends State { ); } - static Future addDem(MaplibreMapController controller) async { + static Future addDem(MapLibreMapController controller) async { // TODO: adapt example? // await controller.addSource( // "dem", @@ -253,13 +253,13 @@ class FullMapState extends State { final _stylesAndLoaders = [ const StyleInfo( name: "Vector", - baseStyle: MaplibreStyles.demo, + baseStyle: MapLibreStyles.demo, addDetails: addVector, position: CameraPosition(target: LatLng(33.3832, -118.4333), zoom: 6), ), const StyleInfo( name: "Default style", - // Using the raw github file version of MaplibreStyles.DEMO here, because we need to + // Using the raw github file version of MapLibreStyles.DEMO here, because we need to // specify a different baseStyle for consecutive elements in this list, // otherwise the map will not update baseStyle: @@ -269,7 +269,7 @@ class FullMapState extends State { ), const StyleInfo( name: "Geojson cluster", - baseStyle: MaplibreStyles.demo, + baseStyle: MapLibreStyles.demo, addDetails: addGeojsonCluster, position: CameraPosition(target: LatLng(33.5, -118.1), zoom: 5), ), @@ -334,7 +334,7 @@ class FullMapState extends State { ), body: Stack( children: [ - MaplibreMap( + MapLibreMap( styleString: styleInfo.baseStyle, onMapCreated: _onMapCreated, initialCameraPosition: styleInfo.position, diff --git a/example/lib/util.dart b/example/lib/util.dart index 88a7069eb..fa5ae9ed6 100644 --- a/example/lib/util.dart +++ b/example/lib/util.dart @@ -3,7 +3,7 @@ import 'package:maplibre_gl/maplibre_gl.dart'; /// Adds an asset image to the currently displayed style Future addImageFromAsset( - MaplibreMapController controller, String name, String assetName) async { + MapLibreMapController controller, String name, String assetName) async { final ByteData bytes = await rootBundle.load(assetName); final Uint8List list = bytes.buffer.asUint8List(); return controller.addImage(name, list); diff --git a/lib/maplibre_gl.dart b/lib/maplibre_gl.dart index 63c1de339..7fde95b0c 100644 --- a/lib/maplibre_gl.dart +++ b/lib/maplibre_gl.dart @@ -2,24 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -/// This library contains the Maplibre GL plugin for Flutter. +/// This library contains the MapLibre GL plugin for Flutter. /// -/// To display a map, add a [MaplibreMap] widget to the widget tree. +/// To display a map, add a [MapLibreMap] widget to the widget tree. /// -/// In this plugin, the map is configured through the parameters passed to the [MaplibreMap] constructor and through the [MaplibreMapController]. -/// The [MaplibreMapController] is provided at runtime by the [MaplibreMap.onMapCreated] callback. +/// In this plugin, the map is configured through the parameters passed to the [MapLibreMap] constructor and through the [MapLibreMapController]. +/// The [MapLibreMapController] is provided at runtime by the [MapLibreMap.onMapCreated] callback. /// The controller also allows adding annotations (icons, lines etc.) to the map at runtime and provides some callbacks to get notified when the user clicks those. /// /// The visual appearance of the map is configured through a MapLibre style passed to the -/// [styleString] parameter of the [MaplibreMap] constructor. -/// The Maplibre style is a JSON document following the specification at https://maplibre.org/maplibre-style-spec/. -/// The following is supposed to serve as a short introduction to the Maplibre style specification: +/// [styleString] parameter of the [MapLibreMap] constructor. +/// The MapLibre style is a JSON document following the specification at https://maplibre.org/maplibre-style-spec/. +/// The following is supposed to serve as a short introduction to the MapLibre style specification: /// The style document contains (among other things) sources and layers. /// Sources determine which data is displayed on the map, layers determine how the data is displayed. /// /// Typical types of sources are raster and vector tiles, as well as GeoJson data. /// For raster and vector tiles, the entire world is divided into a set of tiles in different zoom levels. -/// Depending on the map's zoom level and viewport, the Maplibre client libraries decide, which tiles are needed to fill the viewport and request them from the source. +/// Depending on the map's zoom level and viewport, the MapLibre client libraries decide, which tiles are needed to fill the viewport and request them from the source. /// /// The difference between raster and vector tiles is that raster tiles are images that are pre-rendered on a server, whereas vector tiles contain raw geometric information that is rendered on the client. /// Vector tiles are in the Mapbox Vector Tile (MVT) format, the de-facto standard for vector tiles that is implemented by multiple libraries. @@ -29,8 +29,8 @@ /// and the possibility to rotate them and keep text labels horizontal. /// Raster and vector tiles can be generated from a variety of sources, including OpenStreetMap data and are also available from a number of providers. /// -/// Raster sources are displayed by adding a "raster" layer to the Maplibre GL style. -/// Vector and GeoJson sources are displayed by adding a "line", "fill", "symbol" or "circle" layer to the Maplibre GL style and specifying +/// Raster sources are displayed by adding a "raster" layer to the MapLibre GL style. +/// Vector and GeoJson sources are displayed by adding a "line", "fill", "symbol" or "circle" layer to the MapLibre GL style and specifying /// which source to use (by setting the "source" property of the layer to the id of the source) as well as how to style the data by setting other properties of the layer such as "line-color" or "fill-outline-color". /// For example, a vector source layer (or a GeoJson source layer) with the outlines of countries could be displayed both by a fill layer to fill the countries with a color and by a line layer to draw the outlines of the countries. library maplibre_gl; @@ -79,7 +79,7 @@ export 'package:maplibre_gl_platform_interface/maplibre_gl_platform_interface.da VideoSourceProperties, ImageSourceProperties, MapLibreGlPlatform, - MethodChannelMaplibreGl, + MethodChannelMapLibreGl, OnPlatformViewCreatedCallback; part 'src/controller.dart'; diff --git a/lib/src/annotation_manager.dart b/lib/src/annotation_manager.dart index ea4d248fa..1ba3d4331 100644 --- a/lib/src/annotation_manager.dart +++ b/lib/src/annotation_manager.dart @@ -1,7 +1,7 @@ part of '../maplibre_gl.dart'; abstract class AnnotationManager { - final MaplibreMapController controller; + final MapLibreMapController controller; final _idToAnnotation = {}; final _idToLayerIndex = {}; diff --git a/lib/src/controller.dart b/lib/src/controller.dart index e6bbd1931..a15cfc373 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -32,13 +32,13 @@ typedef OnCameraIdleCallback = void Function(); typedef OnMapIdleCallback = void Function(); -/// Controller for a single [MaplibreMap] instance running on the host platform. +/// Controller for a single [MapLibreMap] instance running on the host platform. /// /// Some of its methods can only be called after the [onStyleLoaded] callback has been invoked. /// /// To add annotations ([Circle]s, [Line]s, [Symbol]s and [Fill]s) on the map, there are two ways: /// -/// 1. *Simple way to add annotations*: Use the corresponding add* methods ([addCircle], [addLine], [addSymbol] and [addFill]) on the MaplibreMapController to add one annotation at a time to the map. +/// 1. *Simple way to add annotations*: Use the corresponding add* methods ([addCircle], [addLine], [addSymbol] and [addFill]) on the MapLibreMapController to add one annotation at a time to the map. /// There are also corresponding [addCircles], [addLines] etc. methods which work the same but add multiple annotations at a time. /// /// (If you are interested how this works: under the hood, this uses AnnotationManagers to manage the annotations. @@ -56,21 +56,21 @@ typedef OnMapIdleCallback = void Function(); /// not for circles that are already contained in the map's style when the map is loaded or are added to that map's style with the methods from the advanced way (see below). /// The same of course applies for fills, lines and symbols. /// -/// 2. *Advanced way to add annotations*: Modify the underlying Maplibre Style of the map to add a new data source (e.g. with the [addSource] method or the more specific methods like [addGeoJsonSource]) +/// 2. *Advanced way to add annotations*: Modify the underlying MapLibre Style of the map to add a new data source (e.g. with the [addSource] method or the more specific methods like [addGeoJsonSource]) /// and add a new layer to display the data of that source on the map (either with the [addLayer] method or with the more specific methods like [addCircleLayer], [addLineLayer] etc.). -/// For more information about Maplibre Styles, see the documentation of [maplibre_gl] as well as the specification at [https://maplibre.org/maplibre-style-spec/]. +/// For more information about MapLibre Styles, see the documentation of [maplibre_gl] as well as the specification at [https://maplibre.org/maplibre-style-spec/]. /// -/// A MaplibreMapController is also a [ChangeNotifier]. Subscribers (change listeners) are notified upon changes to any of +/// A MapLibreMapController is also a [ChangeNotifier]. Subscribers (change listeners) are notified upon changes to any of /// -/// * the configuration options of the [MaplibreMap] widget +/// * the configuration options of the [MapLibreMap] widget /// * the [symbols], [lines], [circles] or [fills] properties /// (i.e. the collection of [Symbol]s, [Line]s, [Circle]s and [Fill]s added to this map via the "simple way" (see above)) /// * the [isCameraMoving] property /// * the [cameraPosition] property /// /// Listeners are notified after changes have been applied on the platform side. -class MaplibreMapController extends ChangeNotifier { - MaplibreMapController({ +class MapLibreMapController extends ChangeNotifier { + MapLibreMapController({ required MapLibreGlPlatform maplibreGlPlatform, required CameraPosition initialCameraPosition, required Iterable annotationOrder, @@ -258,7 +258,7 @@ class MaplibreMapController extends ChangeNotifier { bool _isCameraMoving = false; /// Returns the most recent camera position reported by the platform side. - /// Will be null, if [MaplibreMap.trackCameraPosition] is false. + /// Will be null, if [MapLibreMap.trackCameraPosition] is false. CameraPosition? get cameraPosition => _cameraPosition; CameraPosition? _cameraPosition; @@ -710,7 +710,7 @@ class MaplibreMapController extends ChangeNotifier { /// "a lowercase language's ISO 639-1 alpha2 code (second column), a lowercase ISO 639-2 code if an ISO 639-1 code doesn't exist, or a ISO 639-3 code if neither of those exist". /// /// If your vector tiles do not follow this schema of having labels with "name:$language" for different language, this method will not work for you. - /// In that case, you need to adapt your Maplibre style accordingly yourself to use labels in your preferred language. + /// In that case, you need to adapt your MapLibre style accordingly yourself to use labels in your preferred language. /// /// Attention: This may only be called after onStyleLoaded() has been invoked. /// diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index dfa3bf96b..9c67c5e4c 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -6,15 +6,15 @@ part of '../maplibre_gl.dart'; enum AnnotationType { fill, line, circle, symbol } -typedef MapCreatedCallback = void Function(MaplibreMapController controller); +typedef MapCreatedCallback = void Function(MapLibreMapController controller); /// Shows a MapLibre map. -/// Also refer to the documentation of [maplibre_gl] and [MaplibreMapController]. -class MaplibreMap extends StatefulWidget { - const MaplibreMap({ +/// Also refer to the documentation of [maplibre_gl] and [MapLibreMapController]. +class MapLibreMap extends StatefulWidget { + const MapLibreMap({ super.key, required this.initialCameraPosition, - this.styleString = MaplibreStyles.demo, + this.styleString = MapLibreStyles.demo, this.onMapCreated, this.onStyleLoadedCallback, this.gestureRecognizers, @@ -139,10 +139,10 @@ class MaplibreMap extends StatefulWidget { /// This takes presedence over zoomGesturesEnabled. Only supported for web. final bool? doubleClickZoomEnabled; - /// True if you want to be notified of map camera movements by the [MaplibreMapController]. Default is false. + /// True if you want to be notified of map camera movements by the [MapLibreMapController]. Default is false. /// - /// If this is set to true and the user pans/zooms/rotates the map, [MaplibreMapController] (which is a [ChangeNotifier]) - /// will notify it's listeners and you can then get the new [MaplibreMapController].cameraPosition. + /// If this is set to true and the user pans/zooms/rotates the map, [MapLibreMapController] (which is a [ChangeNotifier]) + /// will notify it's listeners and you can then get the new [MapLibreMapController].cameraPosition. final bool trackCameraPosition; /// True if a "My Location" layer should be shown on the map. @@ -234,24 +234,24 @@ class MaplibreMap extends StatefulWidget { /// * All fade/transition animations have completed final OnMapIdleCallback? onMapIdle; - /// Set `MaplibreMap.useHybridComposition` to `false` in order use Virtual-Display + /// Set `MapLibreMap.useHybridComposition` to `false` in order use Virtual-Display /// (better for Android 9 and below but may result in errors on Android 12) /// or leave it `true` (default) to use Hybrid composition (Slower on Android 9 and below). static bool get useHybridComposition => - MethodChannelMaplibreGl.useHybridComposition; + MethodChannelMapLibreGl.useHybridComposition; static set useHybridComposition(bool useHybridComposition) => - MethodChannelMaplibreGl.useHybridComposition = useHybridComposition; + MethodChannelMapLibreGl.useHybridComposition = useHybridComposition; @override - State createState() => _MaplibreMapState(); + State createState() => _MapLibreMapState(); } -class _MaplibreMapState extends State { - final Completer _controller = - Completer(); +class _MapLibreMapState extends State { + final Completer _controller = + Completer(); - late _MaplibreMapOptions _maplibreMapOptions; + late _MapLibreMapOptions _maplibreMapOptions; final MapLibreGlPlatform _maplibreGlPlatform = MapLibreGlPlatform.createInstance(); @@ -263,7 +263,7 @@ class _MaplibreMapState extends State { final Map creationParams = { 'initialCameraPosition': widget.initialCameraPosition.toMap(), 'styleString': widget.styleString, - 'options': _MaplibreMapOptions.fromWidget(widget).toMap(), + 'options': _MapLibreMapOptions.fromWidget(widget).toMap(), 'dragEnabled': widget.dragEnabled, if (widget.iosLongClickDuration != null) 'iosLongClickDurationMilliseconds': @@ -276,7 +276,7 @@ class _MaplibreMapState extends State { @override void initState() { super.initState(); - _maplibreMapOptions = _MaplibreMapOptions.fromWidget(widget); + _maplibreMapOptions = _MapLibreMapOptions.fromWidget(widget); } @override @@ -289,10 +289,10 @@ class _MaplibreMapState extends State { } @override - void didUpdateWidget(MaplibreMap oldWidget) { + void didUpdateWidget(MapLibreMap oldWidget) { super.didUpdateWidget(oldWidget); - final _MaplibreMapOptions newOptions = - _MaplibreMapOptions.fromWidget(widget); + final _MapLibreMapOptions newOptions = + _MapLibreMapOptions.fromWidget(widget); final Map updates = _maplibreMapOptions.updatesMap(newOptions); _updateOptions(updates); @@ -303,12 +303,12 @@ class _MaplibreMapState extends State { if (updates.isEmpty) { return; } - final MaplibreMapController controller = await _controller.future; + final MapLibreMapController controller = await _controller.future; controller._updateMapOptions(updates); } Future onPlatformViewCreated(int id) async { - final MaplibreMapController controller = MaplibreMapController( + final MapLibreMapController controller = MapLibreMapController( maplibreGlPlatform: _maplibreGlPlatform, initialCameraPosition: widget.initialCameraPosition, onStyleLoadedCallback: () { @@ -336,12 +336,12 @@ class _MaplibreMapState extends State { } } -/// Configuration options for the MaplibreMap user interface. +/// Configuration options for the MapLibreMap user interface. /// /// When used to change configuration, null values will be interpreted as /// "do not change this configuration option". -class _MaplibreMapOptions { - _MaplibreMapOptions({ +class _MapLibreMapOptions { + _MapLibreMapOptions({ this.compassEnabled, this.cameraTargetBounds, this.styleString, @@ -362,8 +362,8 @@ class _MaplibreMapOptions { this.attributionButtonMargins, }); - static _MaplibreMapOptions fromWidget(MaplibreMap map) { - return _MaplibreMapOptions( + static _MapLibreMapOptions fromWidget(MapLibreMap map) { + return _MapLibreMapOptions( compassEnabled: map.compassEnabled, cameraTargetBounds: map.cameraTargetBounds, styleString: map.styleString, @@ -471,7 +471,7 @@ class _MaplibreMapOptions { return optionsMap; } - Map updatesMap(_MaplibreMapOptions newOptions) { + Map updatesMap(_MapLibreMapOptions newOptions) { final Map prevOptionsMap = toMap(); final newOptionsMap = newOptions.toMap(); diff --git a/lib/src/maplibre_styles.dart b/lib/src/maplibre_styles.dart index 950058fba..9cce86c48 100644 --- a/lib/src/maplibre_styles.dart +++ b/lib/src/maplibre_styles.dart @@ -1,7 +1,7 @@ part of '../maplibre_gl.dart'; /// MapLibre styles used mostly for demonstration. -abstract class MaplibreStyles { +abstract class MapLibreStyles { /// A very simple MapLibre demo style that shows only countries with their /// boundaries. static const String demo = "https://demotiles.maplibre.org/style.json"; diff --git a/maplibre_gl_platform_interface/CHANGELOG.md b/maplibre_gl_platform_interface/CHANGELOG.md index 8dba6f2a3..062c5f5f8 100644 --- a/maplibre_gl_platform_interface/CHANGELOG.md +++ b/maplibre_gl_platform_interface/CHANGELOG.md @@ -23,7 +23,7 @@ see top-level CHANGELOG.md ## 0.13.0, Oct 6, 2021 🎉 The first release of flutter-maplibre-gl with the complete transition to -Maplibre libraries. 🎉 +MapLibre libraries. 🎉 ### Changes cherry-picked/ported from tobrun/flutter-mapbox-gl:0.12.0 diff --git a/maplibre_gl_platform_interface/README.md b/maplibre_gl_platform_interface/README.md index 91df2eb2f..fc3da6b0c 100644 --- a/maplibre_gl_platform_interface/README.md +++ b/maplibre_gl_platform_interface/README.md @@ -1 +1 @@ -Contains the web platform implementation for the [Flutter Maplibre GL plugin](https://github.com/maplibre/flutter-maplibre-gl). \ No newline at end of file +Contains the web platform implementation for the [Flutter MapLibre GL plugin](https://github.com/maplibre/flutter-maplibre-gl). \ No newline at end of file diff --git a/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart b/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart index 728ed7954..425fbe652 100644 --- a/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart +++ b/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart @@ -6,18 +6,18 @@ part of '../maplibre_gl_platform_interface.dart'; typedef OnPlatformViewCreatedCallback = void Function(int); abstract class MapLibreGlPlatform { - static MethodChannelMaplibreGl? _instance; + static MethodChannelMapLibreGl? _instance; - /// The default instance of [MaplibreGlPlatform] to use. + /// The default instance of [MapLibreGlPlatform] to use. /// - /// Defaults to [MethodChannelMaplibreGl]. + /// Defaults to [MethodChannelMapLibreGl]. /// /// Platform-specific plugins should set this with their own platform-specific /// class that extends [MapLibreGlPlatform] when they register themselves. static MapLibreGlPlatform Function() createInstance = - () => _instance ?? MethodChannelMaplibreGl(); + () => _instance ?? MethodChannelMapLibreGl(); - static set instance(MethodChannelMaplibreGl instance) { + static set instance(MethodChannelMapLibreGl instance) { _instance = instance; } diff --git a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart index c68159de1..5f46fbfa5 100644 --- a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart +++ b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart @@ -1,6 +1,6 @@ part of '../maplibre_gl_platform_interface.dart'; -class MethodChannelMaplibreGl extends MapLibreGlPlatform { +class MethodChannelMapLibreGl extends MapLibreGlPlatform { late MethodChannel _channel; static bool useHybridComposition = false; diff --git a/maplibre_gl_platform_interface/lib/src/ui.dart b/maplibre_gl_platform_interface/lib/src/ui.dart index 81d0e0691..2b7212787 100644 --- a/maplibre_gl_platform_interface/lib/src/ui.dart +++ b/maplibre_gl_platform_interface/lib/src/ui.dart @@ -41,7 +41,7 @@ enum AttributionButtonPosition { } /// Bounds for the map camera target. -/// Used with [_MaplibreMapOptions] to wrap a [LatLngBounds] value. This allows +/// Used with [_MapLibreMapOptions] to wrap a [LatLngBounds] value. This allows /// distinguishing between specifying an unbounded target (null `LatLngBounds`) /// from not specifying anything (null `CameraTargetBounds`). class CameraTargetBounds { @@ -76,7 +76,7 @@ class CameraTargetBounds { } /// Preferred bounds for map camera zoom level. -/// Used with [_MaplibreMapOptions] to wrap min and max zoom. This allows +/// Used with [_MapLibreMapOptions] to wrap min and max zoom. This allows /// distinguishing between specifying unbounded zooming (null [minZoom] and /// [maxZoom]) from not specifying anything (null [MinMaxZoomPreference]). class MinMaxZoomPreference { diff --git a/maplibre_gl_web/CHANGELOG.md b/maplibre_gl_web/CHANGELOG.md index a57e53dfe..4657f0928 100644 --- a/maplibre_gl_web/CHANGELOG.md +++ b/maplibre_gl_web/CHANGELOG.md @@ -15,7 +15,7 @@ see top-level CHANGELOG.md ## 0.13.0, Oct 6, 2021 🎉 The first release of flutter-maplibre-gl with the complete transition to -Maplibre libraries. 🎉 +MapLibre libraries. 🎉 ### Changes cherry-picked/ported from tobrun/flutter-mapbox-gl:0.12.0 diff --git a/maplibre_gl_web/README.md b/maplibre_gl_web/README.md index 9b5b7e76f..bd75f5024 100644 --- a/maplibre_gl_web/README.md +++ b/maplibre_gl_web/README.md @@ -1 +1 @@ -Contains the web interfaces for the [Flutter Maplibre GL plugin](https://github.com/maplibre/flutter-maplibre-gl). \ No newline at end of file +Contains the web interfaces for the [Flutter MapLibre GL plugin](https://github.com/maplibre/flutter-maplibre-gl). \ No newline at end of file diff --git a/maplibre_gl_web/lib/src/maplibre_map_plugin.dart b/maplibre_gl_web/lib/src/maplibre_map_plugin.dart index b528baab0..3aba469d5 100644 --- a/maplibre_gl_web/lib/src/maplibre_map_plugin.dart +++ b/maplibre_gl_web/lib/src/maplibre_map_plugin.dart @@ -3,6 +3,6 @@ part of '../maplibre_gl_web.dart'; class MapLibreMapPlugin { /// Registers this class as the default instance of [MapLibreGlPlatform]. static void registerWith(Registrar registrar) { - MapLibreGlPlatform.createInstance = () => MaplibreMapController(); + MapLibreGlPlatform.createInstance = () => MapLibreMapController(); } } diff --git a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart index 0b938afef..d3c21d9c2 100644 --- a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart +++ b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart @@ -1,6 +1,6 @@ part of '../maplibre_gl_web.dart'; -class MaplibreMapController extends MapLibreGlPlatform +class MapLibreMapController extends MapLibreGlPlatform implements MapLibreMapOptionsSink { late html.DivElement _mapElement; diff --git a/pubspec.yaml b/pubspec.yaml index c955334e6..1b19eb6b4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: maplibre_gl -description: A Flutter plugin for integrating Maplibre Maps inside a Flutter application on Android, iOS and web platforms. +description: A Flutter plugin for integrating MapLibre Maps inside a Flutter application on Android, iOS and web platforms. version: 0.19.0+2 repository: https://github.com/maplibre/flutter-maplibre-gl issue_tracker: https://github.com/maplibre/flutter-maplibre-gl/issues From 1f78968543b5844a8f93908ab49bacdd0910ef29 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Wed, 5 Jun 2024 11:18:35 +0200 Subject: [PATCH 2/6] add deprecations, add changelog --- CHANGELOG.md | 11 +++++++---- lib/src/controller.dart | 3 +++ lib/src/maplibre_map.dart | 3 +++ lib/src/maplibre_styles.dart | 3 +++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ba0b6df7..4e40a0c78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,18 +2,21 @@ ### Breaking changes -* All Dart enums have been migrated from mixed cases to lower camelcase +* All Dart enums have been migrated from mixed cases to lower camelcase according to the `camel_case_types` lint rule. * Move `MapLibreStyles` to the main `maplibre_gl` package. You can now use the demo style without adding `maplibre_gl_platform_interface` as a dependency. * Updated maplibre-native for ios to v6.4.2. This introduces the new - iOS Metal renderer and the OpenGL ES renderer now uses OpenGL ES 3.0. Only + iOS Metal renderer and the OpenGL ES renderer now uses OpenGL ES 3.0. Only iOS Devices with an Apple A7 GPU or later are supported onwards. See the [maplibre-native changelog](https://github.com/maplibre/maplibre-native/blob/main/platform/ios/CHANGELOG.md#600) for more information. -* Updated maplibre-native for android to v11.0.0. This version uses - OpenGL ES 3.0. +* Updated maplibre-native for android to v11.0.0. This version uses + OpenGL ES 3.0. See the + [maplibre-native changelog](https://github.com/maplibre/maplibre-native/blob/main/platform/android/CHANGELOG.md#1100) + for more information. * Renamed the method channel to `plugins.flutter.io/maplibre_gl_*` in all packages. +* Renamed `Maplibre` to `MapLibre` to be in line with maplibre-native. ## 0.19.0 diff --git a/lib/src/controller.dart b/lib/src/controller.dart index a15cfc373..c6984d5ee 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -32,6 +32,9 @@ typedef OnCameraIdleCallback = void Function(); typedef OnMapIdleCallback = void Function(); +@Deprecated('MaplibreMapController was renamed to MapLibreMapController.') +typedef MaplibreMapController = MapLibreMapController; + /// Controller for a single [MapLibreMap] instance running on the host platform. /// /// Some of its methods can only be called after the [onStyleLoaded] callback has been invoked. diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index 9c67c5e4c..a0245cc35 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -8,6 +8,9 @@ enum AnnotationType { fill, line, circle, symbol } typedef MapCreatedCallback = void Function(MapLibreMapController controller); +@Deprecated('MaplibreMap was renamed to MapLibreMap. ') +typedef MaplibreMap = MapLibreMap; + /// Shows a MapLibre map. /// Also refer to the documentation of [maplibre_gl] and [MapLibreMapController]. class MapLibreMap extends StatefulWidget { diff --git a/lib/src/maplibre_styles.dart b/lib/src/maplibre_styles.dart index 9cce86c48..ceefc7478 100644 --- a/lib/src/maplibre_styles.dart +++ b/lib/src/maplibre_styles.dart @@ -1,5 +1,8 @@ part of '../maplibre_gl.dart'; +@Deprecated('MaplibreStyles was renamed to MapLibreStyles.') +typedef MaplibreStyles = MapLibreStyles; + /// MapLibre styles used mostly for demonstration. abstract class MapLibreStyles { /// A very simple MapLibre demo style that shows only countries with their From 3db909aaaf1140718eba89b55ec219151354926f Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:06:34 +0200 Subject: [PATCH 3/6] rename MethodChannelMapLibreGl to MapLibreMethodChannel --- lib/maplibre_gl.dart | 2 +- lib/src/maplibre_map.dart | 4 ++-- .../lib/src/maplibre_gl_platform_interface.dart | 8 ++++---- .../lib/src/method_channel_maplibre_gl.dart | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/maplibre_gl.dart b/lib/maplibre_gl.dart index 7fde95b0c..eea2df223 100644 --- a/lib/maplibre_gl.dart +++ b/lib/maplibre_gl.dart @@ -79,7 +79,7 @@ export 'package:maplibre_gl_platform_interface/maplibre_gl_platform_interface.da VideoSourceProperties, ImageSourceProperties, MapLibreGlPlatform, - MethodChannelMapLibreGl, + MapLibreMethodChannel, OnPlatformViewCreatedCallback; part 'src/controller.dart'; diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index a0245cc35..542735417 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -241,10 +241,10 @@ class MapLibreMap extends StatefulWidget { /// (better for Android 9 and below but may result in errors on Android 12) /// or leave it `true` (default) to use Hybrid composition (Slower on Android 9 and below). static bool get useHybridComposition => - MethodChannelMapLibreGl.useHybridComposition; + MapLibreMethodChannel.useHybridComposition; static set useHybridComposition(bool useHybridComposition) => - MethodChannelMapLibreGl.useHybridComposition = useHybridComposition; + MapLibreMethodChannel.useHybridComposition = useHybridComposition; @override State createState() => _MapLibreMapState(); diff --git a/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart b/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart index 425fbe652..0f80bc511 100644 --- a/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart +++ b/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart @@ -6,18 +6,18 @@ part of '../maplibre_gl_platform_interface.dart'; typedef OnPlatformViewCreatedCallback = void Function(int); abstract class MapLibreGlPlatform { - static MethodChannelMapLibreGl? _instance; + static MapLibreMethodChannel? _instance; /// The default instance of [MapLibreGlPlatform] to use. /// - /// Defaults to [MethodChannelMapLibreGl]. + /// Defaults to [MapLibreMethodChannel]. /// /// Platform-specific plugins should set this with their own platform-specific /// class that extends [MapLibreGlPlatform] when they register themselves. static MapLibreGlPlatform Function() createInstance = - () => _instance ?? MethodChannelMapLibreGl(); + () => _instance ?? MapLibreMethodChannel(); - static set instance(MethodChannelMapLibreGl instance) { + static set instance(MapLibreMethodChannel instance) { _instance = instance; } diff --git a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart index 5f46fbfa5..989f2a4d2 100644 --- a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart +++ b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart @@ -1,6 +1,6 @@ part of '../maplibre_gl_platform_interface.dart'; -class MethodChannelMapLibreGl extends MapLibreGlPlatform { +class MapLibreMethodChannel extends MapLibreGlPlatform { late MethodChannel _channel; static bool useHybridComposition = false; From 11ab6b9bf546a68684cf2006348fc106931770ca Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:08:42 +0200 Subject: [PATCH 4/6] rename MapLibreGlPlatform to MapLibrePlatform --- lib/maplibre_gl.dart | 2 +- lib/src/controller.dart | 130 +++++++++--------- lib/src/maplibre_map.dart | 10 +- .../src/maplibre_gl_platform_interface.dart | 10 +- .../lib/src/method_channel_maplibre_gl.dart | 2 +- .../lib/src/maplibre_map_plugin.dart | 4 +- .../lib/src/maplibre_web_gl_platform.dart | 2 +- 7 files changed, 80 insertions(+), 80 deletions(-) diff --git a/lib/maplibre_gl.dart b/lib/maplibre_gl.dart index eea2df223..3def53d8e 100644 --- a/lib/maplibre_gl.dart +++ b/lib/maplibre_gl.dart @@ -78,7 +78,7 @@ export 'package:maplibre_gl_platform_interface/maplibre_gl_platform_interface.da GeojsonSourceProperties, VideoSourceProperties, ImageSourceProperties, - MapLibreGlPlatform, + MapLibrePlatform, MapLibreMethodChannel, OnPlatformViewCreatedCallback; diff --git a/lib/src/controller.dart b/lib/src/controller.dart index c6984d5ee..a851f8483 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -74,7 +74,7 @@ typedef MaplibreMapController = MapLibreMapController; /// Listeners are notified after changes have been applied on the platform side. class MapLibreMapController extends ChangeNotifier { MapLibreMapController({ - required MapLibreGlPlatform maplibreGlPlatform, + required MapLibrePlatform maplibrePlatform, required CameraPosition initialCameraPosition, required Iterable annotationOrder, required Iterable annotationConsumeTapEvents, @@ -87,17 +87,17 @@ class MapLibreMapController extends ChangeNotifier { this.onMapIdle, this.onUserLocationUpdated, this.onCameraIdle, - }) : _maplibreGlPlatform = maplibreGlPlatform { + }) : _maplibrePlatform = maplibrePlatform { _cameraPosition = initialCameraPosition; - _maplibreGlPlatform.onFeatureTappedPlatform.add((payload) { + _maplibrePlatform.onFeatureTappedPlatform.add((payload) { for (final fun in List.from(onFeatureTapped)) { fun(payload["id"], payload["point"], payload["latLng"]); } }); - _maplibreGlPlatform.onFeatureDraggedPlatform.add((payload) { + _maplibrePlatform.onFeatureDraggedPlatform.add((payload) { for (final fun in List.from(onFeatureDrag)) { final DragEventType enmDragEventType = DragEventType.values .firstWhere((element) => element.name == payload["eventType"]); @@ -110,17 +110,17 @@ class MapLibreMapController extends ChangeNotifier { } }); - _maplibreGlPlatform.onCameraMoveStartedPlatform.add((_) { + _maplibrePlatform.onCameraMoveStartedPlatform.add((_) { _isCameraMoving = true; notifyListeners(); }); - _maplibreGlPlatform.onCameraMovePlatform.add((cameraPosition) { + _maplibrePlatform.onCameraMovePlatform.add((cameraPosition) { _cameraPosition = cameraPosition; notifyListeners(); }); - _maplibreGlPlatform.onCameraIdlePlatform.add((cameraPosition) { + _maplibrePlatform.onCameraIdlePlatform.add((cameraPosition) { _isCameraMoving = false; if (cameraPosition != null) { _cameraPosition = cameraPosition; @@ -131,7 +131,7 @@ class MapLibreMapController extends ChangeNotifier { notifyListeners(); }); - _maplibreGlPlatform.onMapStyleLoadedPlatform.add((_) { + _maplibrePlatform.onMapStyleLoadedPlatform.add((_) { final interactionEnabled = annotationConsumeTapEvents.toSet(); for (var type in annotationOrder.toSet()) { final enableInteraction = interactionEnabled.contains(type); @@ -162,36 +162,36 @@ class MapLibreMapController extends ChangeNotifier { } }); - _maplibreGlPlatform.onMapClickPlatform.add((dict) { + _maplibrePlatform.onMapClickPlatform.add((dict) { if (onMapClick != null) { onMapClick!(dict['point'], dict['latLng']); } }); - _maplibreGlPlatform.onMapLongClickPlatform.add((dict) { + _maplibrePlatform.onMapLongClickPlatform.add((dict) { if (onMapLongClick != null) { onMapLongClick!(dict['point'], dict['latLng']); } }); - _maplibreGlPlatform.onCameraTrackingChangedPlatform.add((mode) { + _maplibrePlatform.onCameraTrackingChangedPlatform.add((mode) { if (onCameraTrackingChanged != null) { onCameraTrackingChanged!(mode); } }); - _maplibreGlPlatform.onCameraTrackingDismissedPlatform.add((_) { + _maplibrePlatform.onCameraTrackingDismissedPlatform.add((_) { if (onCameraTrackingDismissed != null) { onCameraTrackingDismissed!(); } }); - _maplibreGlPlatform.onMapIdlePlatform.add((_) { + _maplibrePlatform.onMapIdlePlatform.add((_) { if (onMapIdle != null) { onMapIdle!(); } }); - _maplibreGlPlatform.onUserLocationUpdatedPlatform.add((location) { + _maplibrePlatform.onUserLocationUpdatedPlatform.add((location) { onUserLocationUpdated?.call(location); }); } @@ -265,7 +265,7 @@ class MapLibreMapController extends ChangeNotifier { CameraPosition? get cameraPosition => _cameraPosition; CameraPosition? _cameraPosition; - final MapLibreGlPlatform _maplibreGlPlatform; //ignore: unused_field + final MapLibrePlatform _maplibrePlatform; //ignore: unused_field /// Updates configuration options of the map user interface. /// @@ -274,7 +274,7 @@ class MapLibreMapController extends ChangeNotifier { /// /// The returned [Future] completes after listeners have been notified. Future _updateMapOptions(Map optionsUpdate) async { - _cameraPosition = await _maplibreGlPlatform.updateMapOptions(optionsUpdate); + _cameraPosition = await _maplibrePlatform.updateMapOptions(optionsUpdate); notifyListeners(); } @@ -285,12 +285,12 @@ class MapLibreMapController extends ChangeNotifier { /// /// To force resize map (without any checks) have a look at forceResizeWebMap() void resizeWebMap() { - _maplibreGlPlatform.resizeWebMap(); + _maplibrePlatform.resizeWebMap(); } /// Triggers a hard map resize event on web and does not check if it is required or not. void forceResizeWebMap() { - _maplibreGlPlatform.forceResizeWebMap(); + _maplibrePlatform.forceResizeWebMap(); } /// Starts an animated change of the map camera position. @@ -303,7 +303,7 @@ class MapLibreMapController extends ChangeNotifier { /// Note: this currently always returns immediately with a value of null on iOS Future animateCamera(CameraUpdate cameraUpdate, {Duration? duration}) async { - return _maplibreGlPlatform.animateCamera(cameraUpdate, duration: duration); + return _maplibrePlatform.animateCamera(cameraUpdate, duration: duration); } /// Instantaneously re-position the camera. @@ -314,7 +314,7 @@ class MapLibreMapController extends ChangeNotifier { /// It returns true if the camera was successfully moved and false if the movement was canceled. /// Note: this currently always returns immediately with a value of null on iOS Future moveCamera(CameraUpdate cameraUpdate) async { - return _maplibreGlPlatform.moveCamera(cameraUpdate); + return _maplibrePlatform.moveCamera(cameraUpdate); } /// Adds a new geojson source @@ -330,7 +330,7 @@ class MapLibreMapController extends ChangeNotifier { /// platform side. Future addGeoJsonSource(String sourceId, Map geojson, {String? promoteId}) async { - await _maplibreGlPlatform.addGeoJsonSource(sourceId, geojson, + await _maplibrePlatform.addGeoJsonSource(sourceId, geojson, promoteId: promoteId); } @@ -347,7 +347,7 @@ class MapLibreMapController extends ChangeNotifier { /// platform side. Future setGeoJsonSource( String sourceId, Map geojson) async { - await _maplibreGlPlatform.setGeoJsonSource(sourceId, geojson); + await _maplibrePlatform.setGeoJsonSource(sourceId, geojson); } /// Sets new geojson data to and existing source @@ -363,7 +363,7 @@ class MapLibreMapController extends ChangeNotifier { /// platform side. Future setGeoJsonFeature( String sourceId, Map geojsonFeature) async { - await _maplibreGlPlatform.setFeatureForGeoJsonSource( + await _maplibrePlatform.setFeatureForGeoJsonSource( sourceId, geojsonFeature); } @@ -394,7 +394,7 @@ class MapLibreMapController extends ChangeNotifier { double? maxzoom, dynamic filter, bool enableInteraction = true}) async { - await _maplibreGlPlatform.addSymbolLayer( + await _maplibrePlatform.addSymbolLayer( sourceId, layerId, properties.toJson(), @@ -434,7 +434,7 @@ class MapLibreMapController extends ChangeNotifier { double? maxzoom, dynamic filter, bool enableInteraction = true}) async { - await _maplibreGlPlatform.addLineLayer( + await _maplibrePlatform.addLineLayer( sourceId, layerId, properties.toJson(), @@ -455,7 +455,7 @@ class MapLibreMapController extends ChangeNotifier { /// platform side. Future setLayerProperties( String layerId, LayerProperties properties) async { - await _maplibreGlPlatform.setLayerProperties(layerId, properties.toJson()); + await _maplibrePlatform.setLayerProperties(layerId, properties.toJson()); } /// Add a fill layer to the map with the given properties @@ -485,7 +485,7 @@ class MapLibreMapController extends ChangeNotifier { double? maxzoom, dynamic filter, bool enableInteraction = true}) async { - await _maplibreGlPlatform.addFillLayer( + await _maplibrePlatform.addFillLayer( sourceId, layerId, properties.toJson(), @@ -525,7 +525,7 @@ class MapLibreMapController extends ChangeNotifier { double? maxzoom, dynamic filter, bool enableInteraction = true}) async { - await _maplibreGlPlatform.addFillExtrusionLayer( + await _maplibrePlatform.addFillExtrusionLayer( sourceId, layerId, properties.toJson(), @@ -565,7 +565,7 @@ class MapLibreMapController extends ChangeNotifier { double? maxzoom, dynamic filter, bool enableInteraction = true}) async { - await _maplibreGlPlatform.addCircleLayer( + await _maplibrePlatform.addCircleLayer( sourceId, layerId, properties.toJson(), @@ -598,7 +598,7 @@ class MapLibreMapController extends ChangeNotifier { String? sourceLayer, double? minzoom, double? maxzoom}) async { - await _maplibreGlPlatform.addRasterLayer( + await _maplibrePlatform.addRasterLayer( sourceId, layerId, properties.toJson(), @@ -629,7 +629,7 @@ class MapLibreMapController extends ChangeNotifier { String? sourceLayer, double? minzoom, double? maxzoom}) async { - await _maplibreGlPlatform.addHillshadeLayer( + await _maplibrePlatform.addHillshadeLayer( sourceId, layerId, properties.toJson(), @@ -660,7 +660,7 @@ class MapLibreMapController extends ChangeNotifier { String? sourceLayer, double? minzoom, double? maxzoom}) async { - await _maplibreGlPlatform.addHeatmapLayer( + await _maplibrePlatform.addHeatmapLayer( sourceId, layerId, properties.toJson(), @@ -677,7 +677,7 @@ class MapLibreMapController extends ChangeNotifier { /// platform side. Future updateMyLocationTrackingMode( MyLocationTrackingMode myLocationTrackingMode) async { - return _maplibreGlPlatform + return _maplibrePlatform .updateMyLocationTrackingMode(myLocationTrackingMode); } @@ -686,7 +686,7 @@ class MapLibreMapController extends ChangeNotifier { /// The returned [Future] completes after the change has been made on the /// platform side. Future matchMapLanguageWithDeviceDefault() async { - return _maplibreGlPlatform.matchMapLanguageWithDeviceDefault(); + return _maplibrePlatform.matchMapLanguageWithDeviceDefault(); } /// Updates the distance from the edges of the map view’s frame to the edges @@ -702,7 +702,7 @@ class MapLibreMapController extends ChangeNotifier { /// platform side. Future updateContentInsets(EdgeInsets insets, [bool animated = false]) async { - return _maplibreGlPlatform.updateContentInsets(insets, animated); + return _maplibrePlatform.updateContentInsets(insets, animated); } /// Updates the language of the map labels to match the specified language. @@ -720,7 +720,7 @@ class MapLibreMapController extends ChangeNotifier { /// The returned [Future] completes after the change has been made on the /// platform side. Future setMapLanguage(String language) async { - return _maplibreGlPlatform.setMapLanguage(language); + return _maplibrePlatform.setMapLanguage(language); } /// Enables or disables the collection of anonymized telemetry data. @@ -728,7 +728,7 @@ class MapLibreMapController extends ChangeNotifier { /// The returned [Future] completes after the change has been made on the /// platform side. Future setTelemetryEnabled(bool enabled) async { - return _maplibreGlPlatform.setTelemetryEnabled(enabled); + return _maplibrePlatform.setTelemetryEnabled(enabled); } /// Retrieves whether collection of anonymized telemetry data is enabled. @@ -736,7 +736,7 @@ class MapLibreMapController extends ChangeNotifier { /// The returned [Future] completes after the query has been made on the /// platform side. Future getTelemetryEnabled() async { - return _maplibreGlPlatform.getTelemetryEnabled(); + return _maplibrePlatform.getTelemetryEnabled(); } /// Adds a symbol to the map, configured using the specified custom [options]. @@ -1106,13 +1106,13 @@ class MapLibreMapController extends ChangeNotifier { /// Query rendered (i.e. visible) features at a point in screen coordinates Future queryRenderedFeatures( Point point, List layerIds, List? filter) async { - return _maplibreGlPlatform.queryRenderedFeatures(point, layerIds, filter); + return _maplibrePlatform.queryRenderedFeatures(point, layerIds, filter); } /// Query rendered (i.e. visible) features in a Rect in screen coordinates Future queryRenderedFeaturesInRect( Rect rect, List layerIds, String? filter) async { - return _maplibreGlPlatform.queryRenderedFeaturesInRect( + return _maplibrePlatform.queryRenderedFeaturesInRect( rect, layerIds, filter); } @@ -1124,24 +1124,24 @@ class MapLibreMapController extends ChangeNotifier { /// Note: On web, this will probably only work for GeoJson source, not for vector tiles Future querySourceFeatures( String sourceId, String? sourceLayerId, List? filter) async { - return _maplibreGlPlatform.querySourceFeatures( + return _maplibrePlatform.querySourceFeatures( sourceId, sourceLayerId, filter); } Future invalidateAmbientCache() async { - return _maplibreGlPlatform.invalidateAmbientCache(); + return _maplibrePlatform.invalidateAmbientCache(); } /// Get last my location /// /// Return last latlng, nullable Future requestMyLocationLatLng() async { - return _maplibreGlPlatform.requestMyLocationLatLng(); + return _maplibrePlatform.requestMyLocationLatLng(); } /// This method returns the boundaries of the region currently displayed in the map. Future getVisibleRegion() async { - return _maplibreGlPlatform.getVisibleRegion(); + return _maplibrePlatform.getVisibleRegion(); } /// Adds an image to the style currently displayed in the map, so that it can later be referred to by the provided name. @@ -1180,7 +1180,7 @@ class MapLibreMapController extends ChangeNotifier { /// } /// ``` Future addImage(String name, Uint8List bytes, [bool sdf = false]) { - return _maplibreGlPlatform.addImage(name, bytes, sdf); + return _maplibrePlatform.addImage(name, bytes, sdf); } /// If true, the icon will be visible even if it collides with other previously drawn symbols. @@ -1207,7 +1207,7 @@ class MapLibreMapController extends ChangeNotifier { /// Not implemented on web. Future addImageSource( String imageSourceId, Uint8List bytes, LatLngQuad coordinates) { - return _maplibreGlPlatform.addImageSource( + return _maplibrePlatform.addImageSource( imageSourceId, bytes, coordinates); } @@ -1215,25 +1215,25 @@ class MapLibreMapController extends ChangeNotifier { /// Not implemented on web. Future updateImageSource( String imageSourceId, Uint8List? bytes, LatLngQuad? coordinates) { - return _maplibreGlPlatform.updateImageSource( + return _maplibrePlatform.updateImageSource( imageSourceId, bytes, coordinates); } /// Removes previously added image source by id @Deprecated("This method was renamed to removeSource") Future removeImageSource(String imageSourceId) { - return _maplibreGlPlatform.removeSource(imageSourceId); + return _maplibrePlatform.removeSource(imageSourceId); } /// Removes previously added source by id Future removeSource(String sourceId) { - return _maplibreGlPlatform.removeSource(sourceId); + return _maplibrePlatform.removeSource(sourceId); } /// Adds an image layer to the map's style at render time. Future addImageLayer(String layerId, String imageSourceId, {double? minzoom, double? maxzoom}) { - return _maplibreGlPlatform.addLayer( + return _maplibrePlatform.addLayer( layerId, imageSourceId, minzoom, maxzoom); } @@ -1241,7 +1241,7 @@ class MapLibreMapController extends ChangeNotifier { Future addImageLayerBelow( String layerId, String sourceId, String imageSourceId, {double? minzoom, double? maxzoom}) { - return _maplibreGlPlatform.addLayerBelow( + return _maplibrePlatform.addLayerBelow( layerId, sourceId, imageSourceId, minzoom, maxzoom); } @@ -1250,21 +1250,21 @@ class MapLibreMapController extends ChangeNotifier { Future addLayerBelow( String layerId, String sourceId, String imageSourceId, {double? minzoom, double? maxzoom}) { - return _maplibreGlPlatform.addLayerBelow( + return _maplibrePlatform.addLayerBelow( layerId, sourceId, imageSourceId, minzoom, maxzoom); } /// Removes a MapLibre style layer Future removeLayer(String layerId) { - return _maplibreGlPlatform.removeLayer(layerId); + return _maplibrePlatform.removeLayer(layerId); } Future setFilter(String layerId, dynamic filter) { - return _maplibreGlPlatform.setFilter(layerId, filter); + return _maplibrePlatform.setFilter(layerId, filter); } Future getFilter(String layerId) { - return _maplibreGlPlatform.getFilter(layerId); + return _maplibrePlatform.getFilter(layerId); } /// Returns the point on the screen that corresponds to a geographical coordinate ([latLng]). The screen location is in screen pixels (not display pixels) relative to the top left of the map (not of the whole screen) @@ -1274,27 +1274,27 @@ class MapLibreMapController extends ChangeNotifier { /// /// Returns null if [latLng] is not currently visible on the map. Future toScreenLocation(LatLng latLng) async { - return _maplibreGlPlatform.toScreenLocation(latLng); + return _maplibrePlatform.toScreenLocation(latLng); } Future> toScreenLocationBatch(Iterable latLngs) async { - return _maplibreGlPlatform.toScreenLocationBatch(latLngs); + return _maplibrePlatform.toScreenLocationBatch(latLngs); } /// Returns the geographic location (as [LatLng]) that corresponds to a point on the screen. The screen location is specified in screen pixels (not display pixels) relative to the top left of the map (not the top left of the whole screen). Future toLatLng(Point screenLocation) async { - return _maplibreGlPlatform.toLatLng(screenLocation); + return _maplibrePlatform.toLatLng(screenLocation); } /// Returns the distance spanned by one pixel at the specified [latitude] and current zoom level. /// The distance between pixels decreases as the latitude approaches the poles. This relationship parallels the relationship between longitudinal coordinates at different latitudes. Future getMetersPerPixelAtLatitude(double latitude) async { - return _maplibreGlPlatform.getMetersPerPixelAtLatitude(latitude); + return _maplibrePlatform.getMetersPerPixelAtLatitude(latitude); } /// Add a new source to the map Future addSource(String sourceid, SourceProperties properties) async { - return _maplibreGlPlatform.addSource(sourceid, properties); + return _maplibrePlatform.addSource(sourceid, properties); } /// Pans and zooms the map to contain its visible area within the specified geographical bounds. @@ -1308,7 +1308,7 @@ class MapLibreMapController extends ChangeNotifier { required double east, required int padding, }) async { - return _maplibreGlPlatform.setCameraBounds( + return _maplibrePlatform.setCameraBounds( west: west, north: north, south: south, @@ -1413,18 +1413,18 @@ class MapLibreMapController extends ChangeNotifier { } Future setLayerVisibility(String layerId, bool visible) async { - return _maplibreGlPlatform.setLayerVisibility(layerId, visible); + return _maplibrePlatform.setLayerVisibility(layerId, visible); } Future getLayerIds() { - return _maplibreGlPlatform.getLayerIds(); + return _maplibrePlatform.getLayerIds(); } /// Retrieve every source ids of the map as a [String] list, including the ones added internally /// /// This method is not currently implemented on the web Future> getSourceIds() async { - return (await _maplibreGlPlatform.getSourceIds()) + return (await _maplibrePlatform.getSourceIds()) .whereType() .toList(); } @@ -1432,6 +1432,6 @@ class MapLibreMapController extends ChangeNotifier { @override void dispose() { super.dispose(); - _maplibreGlPlatform.dispose(); + _maplibrePlatform.dispose(); } } diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index 542735417..3ddd9f1d6 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -255,8 +255,8 @@ class _MapLibreMapState extends State { Completer(); late _MapLibreMapOptions _maplibreMapOptions; - final MapLibreGlPlatform _maplibreGlPlatform = - MapLibreGlPlatform.createInstance(); + final MapLibrePlatform _maplibrePlatform = + MapLibrePlatform.createInstance(); @override Widget build(BuildContext context) { @@ -272,7 +272,7 @@ class _MapLibreMapState extends State { 'iosLongClickDurationMilliseconds': widget.iosLongClickDuration!.inMilliseconds, }; - return _maplibreGlPlatform.buildView( + return _maplibrePlatform.buildView( creationParams, onPlatformViewCreated, widget.gestureRecognizers); } @@ -312,7 +312,7 @@ class _MapLibreMapState extends State { Future onPlatformViewCreated(int id) async { final MapLibreMapController controller = MapLibreMapController( - maplibreGlPlatform: _maplibreGlPlatform, + maplibrePlatform: _maplibrePlatform, initialCameraPosition: widget.initialCameraPosition, onStyleLoadedCallback: () { if (_controller.isCompleted) { @@ -331,7 +331,7 @@ class _MapLibreMapState extends State { annotationOrder: widget.annotationOrder, annotationConsumeTapEvents: widget.annotationConsumeTapEvents, ); - await _maplibreGlPlatform.initPlatform(id); + await _maplibrePlatform.initPlatform(id); _controller.complete(controller); if (widget.onMapCreated != null) { widget.onMapCreated!(controller); diff --git a/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart b/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart index 0f80bc511..c54a4dfd2 100644 --- a/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart +++ b/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart @@ -2,19 +2,19 @@ part of '../maplibre_gl_platform_interface.dart'; -/// The default instance of [MapLibreGlPlatform] to use. +/// The default instance of [MapLibrePlatform] to use. typedef OnPlatformViewCreatedCallback = void Function(int); -abstract class MapLibreGlPlatform { +abstract class MapLibrePlatform { static MapLibreMethodChannel? _instance; - /// The default instance of [MapLibreGlPlatform] to use. + /// The default instance of [MapLibrePlatform] to use. /// /// Defaults to [MapLibreMethodChannel]. /// /// Platform-specific plugins should set this with their own platform-specific - /// class that extends [MapLibreGlPlatform] when they register themselves. - static MapLibreGlPlatform Function() createInstance = + /// class that extends [MapLibrePlatform] when they register themselves. + static MapLibrePlatform Function() createInstance = () => _instance ?? MapLibreMethodChannel(); static set instance(MapLibreMethodChannel instance) { diff --git a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart index 989f2a4d2..458c9561c 100644 --- a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart +++ b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart @@ -1,6 +1,6 @@ part of '../maplibre_gl_platform_interface.dart'; -class MapLibreMethodChannel extends MapLibreGlPlatform { +class MapLibreMethodChannel extends MapLibrePlatform { late MethodChannel _channel; static bool useHybridComposition = false; diff --git a/maplibre_gl_web/lib/src/maplibre_map_plugin.dart b/maplibre_gl_web/lib/src/maplibre_map_plugin.dart index 3aba469d5..08a914d62 100644 --- a/maplibre_gl_web/lib/src/maplibre_map_plugin.dart +++ b/maplibre_gl_web/lib/src/maplibre_map_plugin.dart @@ -1,8 +1,8 @@ part of '../maplibre_gl_web.dart'; class MapLibreMapPlugin { - /// Registers this class as the default instance of [MapLibreGlPlatform]. + /// Registers this class as the default instance of [MapLibrePlatform]. static void registerWith(Registrar registrar) { - MapLibreGlPlatform.createInstance = () => MapLibreMapController(); + MapLibrePlatform.createInstance = () => MapLibreMapController(); } } diff --git a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart index d3c21d9c2..321dcd94a 100644 --- a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart +++ b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart @@ -1,6 +1,6 @@ part of '../maplibre_gl_web.dart'; -class MapLibreMapController extends MapLibreGlPlatform +class MapLibreMapController extends MapLibrePlatform implements MapLibreMapOptionsSink { late html.DivElement _mapElement; From dbc6ab7af7b9a7ae32c58edbd685ec581f8bdb63 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:11:17 +0200 Subject: [PATCH 5/6] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e40a0c78..9847df197 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,10 @@ OpenGL ES 3.0. See the [maplibre-native changelog](https://github.com/maplibre/maplibre-native/blob/main/platform/android/CHANGELOG.md#1100) for more information. -* Renamed the method channel to `plugins.flutter.io/maplibre_gl_*` in all packages. -* Renamed `Maplibre` to `MapLibre` to be in line with maplibre-native. +* Renamed the method channel to `plugins.flutter.io/maplibre_gl_*` in all + packages. +* Renamed `Maplibre` to `MapLibre` to be in line with maplibre-native + (affects for example the classes MaplibreMap and MaplibreMapController). ## 0.19.0 From 501212968c0504f4d73382cb506e10ac37ff17b8 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:12:20 +0200 Subject: [PATCH 6/6] dart format --- lib/src/controller.dart | 6 ++---- lib/src/maplibre_map.dart | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/src/controller.dart b/lib/src/controller.dart index a851f8483..0d45d154c 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -1207,8 +1207,7 @@ class MapLibreMapController extends ChangeNotifier { /// Not implemented on web. Future addImageSource( String imageSourceId, Uint8List bytes, LatLngQuad coordinates) { - return _maplibrePlatform.addImageSource( - imageSourceId, bytes, coordinates); + return _maplibrePlatform.addImageSource(imageSourceId, bytes, coordinates); } /// Update the image and/or coordinates of an image source. @@ -1233,8 +1232,7 @@ class MapLibreMapController extends ChangeNotifier { /// Adds an image layer to the map's style at render time. Future addImageLayer(String layerId, String imageSourceId, {double? minzoom, double? maxzoom}) { - return _maplibrePlatform.addLayer( - layerId, imageSourceId, minzoom, maxzoom); + return _maplibrePlatform.addLayer(layerId, imageSourceId, minzoom, maxzoom); } /// Adds an image layer below the layer provided with belowLayerId to the map's style at render time. diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index 3ddd9f1d6..a515dc10d 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -255,8 +255,7 @@ class _MapLibreMapState extends State { Completer(); late _MapLibreMapOptions _maplibreMapOptions; - final MapLibrePlatform _maplibrePlatform = - MapLibrePlatform.createInstance(); + final MapLibrePlatform _maplibrePlatform = MapLibrePlatform.createInstance(); @override Widget build(BuildContext context) {