diff --git a/example/lib/main.dart b/example/lib/main.dart index a29d780..48d1f8c 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -6,7 +6,6 @@ import 'page/customize_marker_example.dart'; import 'page/geolocator_settings_example.dart'; import 'page/minimum_example.dart'; import 'page/navigation_example.dart'; -import 'page/old_style_example.dart'; import 'page/selectable_distance_filter_example.dart'; void main() { @@ -102,17 +101,6 @@ class Home extends StatelessWidget { ); }, ), - ListTile( - title: const Text('Old Style Example'), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => OldStyleExample(), - ), - ); - }, - ), ], ), ); diff --git a/example/lib/page/center_fab_example.dart b/example/lib/page/center_fab_example.dart index 31c8113..a0a8d94 100644 --- a/example/lib/page/center_fab_example.dart +++ b/example/lib/page/center_fab_example.dart @@ -49,14 +49,12 @@ class _CenterFabExampleState extends State { ), // ignore: sort_child_properties_last children: [ - TileLayerWidget( - options: TileLayerOptions( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - subdomains: ['a', 'b', 'c'], - userAgentPackageName: - 'net.tlserver6y.flutter_map_location_marker.example', - maxZoom: 19, - ), + TileLayer( + urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: ['a', 'b', 'c'], + userAgentPackageName: + 'net.tlserver6y.flutter_map_location_marker.example', + maxZoom: 19, ), LocationMarkerLayerWidget( plugin: LocationMarkerPlugin( diff --git a/example/lib/page/custom_stream_example.dart b/example/lib/page/custom_stream_example.dart index ce596c8..9f8d42a 100644 --- a/example/lib/page/custom_stream_example.dart +++ b/example/lib/page/custom_stream_example.dart @@ -61,14 +61,12 @@ class _CustomStreamExampleState extends State { ), // ignore: sort_child_properties_last children: [ - TileLayerWidget( - options: TileLayerOptions( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - subdomains: ['a', 'b', 'c'], - userAgentPackageName: - 'net.tlserver6y.flutter_map_location_marker.example', - maxZoom: 19, - ), + TileLayer( + urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: ['a', 'b', 'c'], + userAgentPackageName: + 'net.tlserver6y.flutter_map_location_marker.example', + maxZoom: 19, ), LocationMarkerLayerWidget( options: LocationMarkerLayerOptions( diff --git a/example/lib/page/customize_marker_example.dart b/example/lib/page/customize_marker_example.dart index 98e08b2..3979386 100644 --- a/example/lib/page/customize_marker_example.dart +++ b/example/lib/page/customize_marker_example.dart @@ -17,14 +17,12 @@ class CustomizeMarkerExample extends StatelessWidget { maxZoom: 19, ), children: [ - TileLayerWidget( - options: TileLayerOptions( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - subdomains: ['a', 'b', 'c'], - userAgentPackageName: - 'net.tlserver6y.flutter_map_location_marker.example', - maxZoom: 19, - ), + TileLayer( + urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: ['a', 'b', 'c'], + userAgentPackageName: + 'net.tlserver6y.flutter_map_location_marker.example', + maxZoom: 19, ), LocationMarkerLayerWidget( options: LocationMarkerLayerOptions( diff --git a/example/lib/page/geolocator_settings_example.dart b/example/lib/page/geolocator_settings_example.dart index a43061f..4efb340 100644 --- a/example/lib/page/geolocator_settings_example.dart +++ b/example/lib/page/geolocator_settings_example.dart @@ -18,14 +18,12 @@ class GeolocatorSettingsExample extends StatelessWidget { maxZoom: 19, ), children: [ - TileLayerWidget( - options: TileLayerOptions( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - subdomains: ['a', 'b', 'c'], - userAgentPackageName: - 'net.tlserver6y.flutter_map_location_marker.example', - maxZoom: 19, - ), + TileLayer( + urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: ['a', 'b', 'c'], + userAgentPackageName: + 'net.tlserver6y.flutter_map_location_marker.example', + maxZoom: 19, ), LocationMarkerLayerWidget( options: LocationMarkerLayerOptions( diff --git a/example/lib/page/minimum_example.dart b/example/lib/page/minimum_example.dart index e11436b..137bb18 100644 --- a/example/lib/page/minimum_example.dart +++ b/example/lib/page/minimum_example.dart @@ -17,14 +17,12 @@ class MinimumExample extends StatelessWidget { maxZoom: 19, ), children: [ - TileLayerWidget( - options: TileLayerOptions( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - subdomains: ['a', 'b', 'c'], - userAgentPackageName: - 'net.tlserver6y.flutter_map_location_marker.example', - maxZoom: 19, - ), + TileLayer( + urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: ['a', 'b', 'c'], + userAgentPackageName: + 'net.tlserver6y.flutter_map_location_marker.example', + maxZoom: 19, ), LocationMarkerLayerWidget(), ], diff --git a/example/lib/page/navigation_example.dart b/example/lib/page/navigation_example.dart index c1cd69d..20a60a9 100644 --- a/example/lib/page/navigation_example.dart +++ b/example/lib/page/navigation_example.dart @@ -52,14 +52,12 @@ class _NavigationExampleState extends State { ), // ignore: sort_child_properties_last children: [ - TileLayerWidget( - options: TileLayerOptions( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - subdomains: ['a', 'b', 'c'], - userAgentPackageName: - 'net.tlserver6y.flutter_map_location_marker.example', - maxZoom: 19, - ), + TileLayer( + urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: ['a', 'b', 'c'], + userAgentPackageName: + 'net.tlserver6y.flutter_map_location_marker.example', + maxZoom: 19, ), LocationMarkerLayerWidget( plugin: LocationMarkerPlugin( diff --git a/example/lib/page/old_style_example.dart b/example/lib/page/old_style_example.dart deleted file mode 100644 index 9f75720..0000000 --- a/example/lib/page/old_style_example.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_map/flutter_map.dart'; -import 'package:flutter_map_location_marker/flutter_map_location_marker.dart'; -import 'package:latlong2/latlong.dart'; - -class OldStyleExample extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('Old Style Example'), - ), - body: FlutterMap( - options: MapOptions( - center: LatLng(0, 0), - zoom: 1, - maxZoom: 19, - plugins: [ - const LocationMarkerPlugin(), - ], - ), - layers: [ - TileLayerOptions( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - subdomains: ['a', 'b', 'c'], - userAgentPackageName: - 'net.tlserver6y.flutter_map_location_marker.example', - maxZoom: 19, - ), - LocationMarkerLayerOptions(), - ], - ), - ); - } -} diff --git a/example/lib/page/selectable_distance_filter_example.dart b/example/lib/page/selectable_distance_filter_example.dart index ddb9c19..e83d2ac 100644 --- a/example/lib/page/selectable_distance_filter_example.dart +++ b/example/lib/page/selectable_distance_filter_example.dart @@ -46,14 +46,12 @@ class _SelectableDistanceFilterExampleState maxZoom: 19, ), children: [ - TileLayerWidget( - options: TileLayerOptions( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - subdomains: ['a', 'b', 'c'], - userAgentPackageName: - 'net.tlserver6y.flutter_map_location_marker.example', - maxZoom: 19, - ), + TileLayer( + urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: ['a', 'b', 'c'], + userAgentPackageName: + 'net.tlserver6y.flutter_map_location_marker.example', + maxZoom: 19, ), LocationMarkerLayerWidget( options: LocationMarkerLayerOptions( diff --git a/example/pubspec.lock b/example/pubspec.lock index f9464d2..7e92733 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -79,10 +79,12 @@ packages: flutter_map: dependency: "direct main" description: - name: flutter_map - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.0" + path: "." + ref: HEAD + resolved-ref: c6f31eaee57fa77785e7840931b0a9767e99a171 + url: "https://github.com/MooNag/flutter_map" + source: git + version: "3.0.0" flutter_map_location_marker: dependency: "direct main" description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index e981adb..c4b4d55 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -12,7 +12,8 @@ dependencies: flutter: sdk: flutter flutter_joystick: ^0.0.2 - flutter_map: any + flutter_map: #any + git: https://github.com/MooNag/flutter_map flutter_map_location_marker: path: ../ geolocator: any diff --git a/example/windows/flutter/generated_plugin_registrant.cc b/example/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..1ece8f2 --- /dev/null +++ b/example/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,14 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + GeolocatorWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("GeolocatorWindows")); +} diff --git a/example/windows/flutter/generated_plugin_registrant.h b/example/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..dc139d8 --- /dev/null +++ b/example/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/example/windows/flutter/generated_plugins.cmake b/example/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000..7f101a7 --- /dev/null +++ b/example/windows/flutter/generated_plugins.cmake @@ -0,0 +1,24 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + geolocator_windows +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/lib/src/layer.dart b/lib/src/layer.dart index b8ef0a1..15095d3 100644 --- a/lib/src/layer.dart +++ b/lib/src/layer.dart @@ -22,20 +22,14 @@ class LocationMarkerLayer extends StatefulWidget { final LocationMarkerLayerOptions? locationMarkerOpts; /// The map that should this layer be drawn. - final MapState map; - - /// A rebuild signal stream for GroupLayer. See [GroupLayer.stream]. - final Stream stream; + final FlutterMapState map; /// Create a LocationMarkerLayer. LocationMarkerLayer( this.plugin, this.locationMarkerOpts, this.map, - this.stream, - ) : super( - key: locationMarkerOpts?.key, - ); + ); @override LocationMarkerLayerState createState() => LocationMarkerLayerState(); @@ -199,11 +193,9 @@ class LocationMarkerLayerState extends State Widget _buildLocationMarker(LocationMarkerPosition position) { final latLng = position.latLng; final diameter = _locationMarkerOpts.headingSectorRadius * 2; - return GroupLayer( - GroupLayerOptions( - group: [ + return Stack(children: [ if (_locationMarkerOpts.showAccuracyCircle) - CircleLayerOptions( + CircleLayer( circles: [ CircleMarker( point: latLng, @@ -213,7 +205,7 @@ class LocationMarkerLayerState extends State ), ], ), - MarkerLayerOptions( + MarkerLayer( markers: [ if (_locationMarkerOpts.showHeadingSector) Marker( @@ -316,10 +308,7 @@ class LocationMarkerLayerState extends State ], ), ], - ), - widget.map, - widget.stream, - ); + ); } TickerFuture _moveMap(LatLng latLng, [double? zoom]) { diff --git a/lib/src/layer_options.dart b/lib/src/layer_options.dart index 4bdd828..057e0d6 100644 --- a/lib/src/layer_options.dart +++ b/lib/src/layer_options.dart @@ -13,7 +13,7 @@ import 'marker_direction.dart'; /// 1) an accuracy circle (in a circle layer) /// 2) a heading sector (in a marker layer) and /// 3) a marker (in the same marker layer). -class LocationMarkerLayerOptions extends LayerOptions { +class LocationMarkerLayerOptions { /// A Stream that provide position data for this marker. Default to /// [LocationMarkerDataStreamFactory.geolocatorPositionStream]. final Stream positionStream; @@ -64,7 +64,6 @@ class LocationMarkerLayerOptions extends LayerOptions { /// Create a LocationMarkerLayerOptions. LocationMarkerLayerOptions({ - Key? key, Stream? positionStream, Stream? headingStream, this.marker = const DefaultLocationMarker(), @@ -83,7 +82,6 @@ class LocationMarkerLayerOptions extends LayerOptions { Duration? rotateAnimationDuration, this.moveAnimationCurve = Curves.fastOutSlowIn, this.rotateAnimationCurve = Curves.easeInOut, - Stream? rebuild, }) : positionStream = positionStream ?? const LocationMarkerDataStreamFactory().geolocatorPositionStream(), headingStream = headingStream ?? @@ -91,11 +89,7 @@ class LocationMarkerLayerOptions extends LayerOptions { moveAnimationDuration = moveAnimationDuration ?? markerAnimationDuration, rotateAnimationDuration = - rotateAnimationDuration ?? markerAnimationDuration, - super( - key: key, - rebuild: rebuild, - ); + rotateAnimationDuration ?? markerAnimationDuration; /// The duration of the animation of location update. @Deprecated( diff --git a/lib/src/layer_widget.dart b/lib/src/layer_widget.dart index 24aa574..2d8f197 100644 --- a/lib/src/layer_widget.dart +++ b/lib/src/layer_widget.dart @@ -16,15 +16,14 @@ class LocationMarkerLayerWidget extends StatelessWidget { /// Create a LocationMarkerLayerWidget. LocationMarkerLayerWidget({ + super.key, this.plugin = const LocationMarkerPlugin(), this.options, - }) : super( - key: options?.key, - ); + }); @override Widget build(BuildContext context) { - final mapState = MapState.maybeOf(context)!; - return LocationMarkerLayer(plugin, options, mapState, mapState.onMoved); + final mapState = FlutterMapState.maybeOf(context)!; + return LocationMarkerLayer(plugin, options, mapState); } } diff --git a/lib/src/plugin.dart b/lib/src/plugin.dart index cb23fa4..c6ca1cd 100644 --- a/lib/src/plugin.dart +++ b/lib/src/plugin.dart @@ -10,7 +10,7 @@ import 'turn_on_heading_update.dart'; /// A plugin that should be registered in [FlutterMap] in order to render /// [LocationMarkerLayer]. -class LocationMarkerPlugin implements MapPlugin { +class LocationMarkerPlugin { /// The event stream for centering current location. Add a zoom level into /// this stream to center the current location at the provided zoom level or a /// null if the zoom level should be unchanged. Default to null. @@ -58,22 +58,4 @@ class LocationMarkerPlugin implements MapPlugin { this.turnAnimationCurve = Curves.easeInOut, }); - @override - Widget createLayer( - LayerOptions options, - MapState mapState, - Stream stream, - ) { - return LocationMarkerLayer( - this, - options as LocationMarkerLayerOptions, - mapState, - stream, - ); - } - - @override - bool supportsLayer(LayerOptions options) { - return options is LocationMarkerLayerOptions; - } } diff --git a/pubspec.yaml b/pubspec.yaml index 1d173b1..9eb39c8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,13 +4,14 @@ version: 4.1.4 homepage: https://github.com/tlserver/flutter_map_location_marker environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.17.0 <3.0.0" dependencies: flutter: sdk: flutter flutter_compass: ^0.7.0 - flutter_map: ^2.2.0 + flutter_map: #^3.0.0 + git: https://github.com/MooNag/flutter_map geolocator: ^9.0.1 latlong2: ^0.8.1