From 873510ae7fda70aaf1c3955280d7d88c2bd76b99 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Sun, 2 Jun 2024 19:42:23 +0200 Subject: [PATCH 1/5] move MaplibreStyles to maplibre_gl package --- example/lib/sources.dart | 1 - example/pubspec.yaml | 1 - lib/maplibre_gl.dart | 2 ++ lib/src/maplibre_styles.dart | 6 ++++++ maplibre_gl_platform_interface/lib/src/ui.dart | 5 ----- 5 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 lib/src/maplibre_styles.dart diff --git a/example/lib/sources.dart b/example/lib/sources.dart index 10aa3b2f7..21c4d8f03 100644 --- a/example/lib/sources.dart +++ b/example/lib/sources.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:maplibre_gl/maplibre_gl.dart'; import 'page.dart'; -import 'package:maplibre_gl_platform_interface/maplibre_gl_platform_interface.dart'; class StyleInfo { final String name; diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 0d15783b4..00bd849e1 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -14,7 +14,6 @@ dependencies: sdk: flutter maplibre_gl: ^0.19.0 - maplibre_gl_platform_interface: ^0.19.0 location: ^5.0.3 path_provider: ^2.0.15 http: ^1.1.0 diff --git a/lib/maplibre_gl.dart b/lib/maplibre_gl.dart index fe0a7748d..f520bdd4c 100644 --- a/lib/maplibre_gl.dart +++ b/lib/maplibre_gl.dart @@ -82,6 +82,8 @@ export 'package:maplibre_gl_platform_interface/maplibre_gl_platform_interface.da MethodChannelMaplibreGl, OnPlatformViewCreatedCallback; +export 'src/maplibre_styles.dart'; + part 'src/controller.dart'; part 'src/maplibre_map.dart'; diff --git a/lib/src/maplibre_styles.dart b/lib/src/maplibre_styles.dart new file mode 100644 index 000000000..72249b444 --- /dev/null +++ b/lib/src/maplibre_styles.dart @@ -0,0 +1,6 @@ +/// MapLibre styles used mostly for demonstration. +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/lib/src/ui.dart b/maplibre_gl_platform_interface/lib/src/ui.dart index ce7f10586..81d0e0691 100644 --- a/maplibre_gl_platform_interface/lib/src/ui.dart +++ b/maplibre_gl_platform_interface/lib/src/ui.dart @@ -4,11 +4,6 @@ part of '../maplibre_gl_platform_interface.dart'; -class MaplibreStyles { - /// A very simple MapLibre demo style - static const String demo = "https://demotiles.maplibre.org/style.json"; -} - /// The camera mode, which determines how the map camera will track the rendered location. enum MyLocationTrackingMode { none, From 7e541d58d1ea52acdfaa07c5aac8176e1d5f59ee Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Sun, 2 Jun 2024 19:50:50 +0200 Subject: [PATCH 2/5] Update CHANGELOG.md --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cad7ca606..8f56a36bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,10 @@ ### Breaking changes -* All Dart enums have been migrated from mixed cases to lower camelcase according to the `camel_case_types` lint rule. +* 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. ## 0.19.0 From c8dba012b1a27f2e4eaea383464daf9d231e7921 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Mon, 3 Jun 2024 01:58:04 +0200 Subject: [PATCH 3/5] make use of the MaplibreStyles.demo constant --- example/lib/map_ui.dart | 2 +- example/lib/offline_regions.dart | 6 +++--- example/lib/sources.dart | 2 +- lib/maplibre_gl.dart | 5 +++-- lib/src/maplibre_map.dart | 2 +- lib/src/maplibre_styles.dart | 2 ++ 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/example/lib/map_ui.dart b/example/lib/map_ui.dart index 3d8686543..308987391 100644 --- a/example/lib/map_ui.dart +++ b/example/lib/map_ui.dart @@ -51,7 +51,7 @@ 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 = [ - "https://demotiles.maplibre.org/style.json", + MaplibreStyles.demo, "assets/style.json" ]; final List _styleStringLabels = [ diff --git a/example/lib/offline_regions.dart b/example/lib/offline_regions.dart index 772a68e71..b9e4573e0 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: "https://demotiles.maplibre.org/style.json", + mapStyleUrl: MaplibreStyles.demo, ), OfflineRegionDefinition( bounds: santiagoBounds, minZoom: 10.0, maxZoom: 16.0, - mapStyleUrl: "https://demotiles.maplibre.org/style.json", + mapStyleUrl: MaplibreStyles.demo, ), OfflineRegionDefinition( bounds: aucklandBounds, minZoom: 13.0, maxZoom: 16.0, - mapStyleUrl: "https://demotiles.maplibre.org/style.json", + mapStyleUrl: MaplibreStyles.demo, ), ]; diff --git a/example/lib/sources.dart b/example/lib/sources.dart index 21c4d8f03..e2538d4dd 100644 --- a/example/lib/sources.dart +++ b/example/lib/sources.dart @@ -103,7 +103,7 @@ class FullMapState extends State { await controller.addSource( "terrain", const VectorSourceProperties( - url: "https://demotiles.maplibre.org/tiles/tiles.json", + url: MaplibreStyles.demo, )); await controller.addLayer( diff --git a/lib/maplibre_gl.dart b/lib/maplibre_gl.dart index f520bdd4c..b95bb6112 100644 --- a/lib/maplibre_gl.dart +++ b/lib/maplibre_gl.dart @@ -43,6 +43,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:maplibre_gl/maplibre_gl.dart'; import 'package:maplibre_gl_platform_interface/maplibre_gl_platform_interface.dart'; @@ -82,8 +83,6 @@ export 'package:maplibre_gl_platform_interface/maplibre_gl_platform_interface.da MethodChannelMaplibreGl, OnPlatformViewCreatedCallback; -export 'src/maplibre_styles.dart'; - part 'src/controller.dart'; part 'src/maplibre_map.dart'; @@ -103,3 +102,5 @@ part 'src/color_tools.dart'; part 'src/annotation_manager.dart'; part 'src/util.dart'; + +part 'src/maplibre_styles.dart'; diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index d4495bccf..dfa3bf96b 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -14,7 +14,7 @@ class MaplibreMap extends StatefulWidget { const MaplibreMap({ super.key, required this.initialCameraPosition, - this.styleString = "https://demotiles.maplibre.org/style.json", + this.styleString = MaplibreStyles.demo, this.onMapCreated, this.onStyleLoadedCallback, this.gestureRecognizers, diff --git a/lib/src/maplibre_styles.dart b/lib/src/maplibre_styles.dart index 72249b444..950058fba 100644 --- a/lib/src/maplibre_styles.dart +++ b/lib/src/maplibre_styles.dart @@ -1,3 +1,5 @@ +part of '../maplibre_gl.dart'; + /// MapLibre styles used mostly for demonstration. abstract class MaplibreStyles { /// A very simple MapLibre demo style that shows only countries with their From 94d63b40f7d9fd5a0a9f36ae5fe907785ff2d36e Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:41:30 +0200 Subject: [PATCH 4/5] dart format --- example/lib/map_ui.dart | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/example/lib/map_ui.dart b/example/lib/map_ui.dart index 308987391..cfabc6ec4 100644 --- a/example/lib/map_ui.dart +++ b/example/lib/map_ui.dart @@ -50,10 +50,7 @@ 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", "Local style file" From b9fc96471760fe42221d87cd84780a619b2ecb25 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Mon, 3 Jun 2024 12:52:09 +0200 Subject: [PATCH 5/5] resolve https://github.com/maplibre/flutter-maplibre-gl/pull/435#discussion_r1624193232 --- lib/maplibre_gl.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/maplibre_gl.dart b/lib/maplibre_gl.dart index b95bb6112..63c1de339 100644 --- a/lib/maplibre_gl.dart +++ b/lib/maplibre_gl.dart @@ -43,7 +43,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:maplibre_gl/maplibre_gl.dart'; import 'package:maplibre_gl_platform_interface/maplibre_gl_platform_interface.dart';