diff --git a/.fvm/flutter_sdk b/.fvm/flutter_sdk new file mode 120000 index 0000000..8d193f7 --- /dev/null +++ b/.fvm/flutter_sdk @@ -0,0 +1 @@ +/Users/hugo/fvm/versions/3.10.3 \ No newline at end of file diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json new file mode 100644 index 0000000..2472741 --- /dev/null +++ b/.fvm/fvm_config.json @@ -0,0 +1,4 @@ +{ + "flutterSdkVersion": "3.10.3", + "flavors": {} +} \ No newline at end of file diff --git a/example/.fvm/flutter_sdk b/example/.fvm/flutter_sdk new file mode 120000 index 0000000..8d193f7 --- /dev/null +++ b/example/.fvm/flutter_sdk @@ -0,0 +1 @@ +/Users/hugo/fvm/versions/3.10.3 \ No newline at end of file diff --git a/example/.fvm/fvm_config.json b/example/.fvm/fvm_config.json new file mode 100644 index 0000000..2472741 --- /dev/null +++ b/example/.fvm/fvm_config.json @@ -0,0 +1,4 @@ +{ + "flutterSdkVersion": "3.10.3", + "flavors": {} +} \ No newline at end of file diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index f683e9f..d53f896 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -179,10 +179,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -193,6 +195,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 1579fb3..4f68a2c 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -43,5 +43,7 @@ CADisableMinimumFrameDurationOnPhone + UIApplicationSupportsIndirectInputEvents + diff --git a/example/lib/main.dart b/example/lib/main.dart index 870b050..cbe3a27 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -67,8 +67,8 @@ class _MyHomePageState extends State { ), body: FlutterMap( options: MapOptions( - center: LatLng(45.1313258, 5.5171205), - zoom: 11.0, + initialCenter: LatLng(45.1313258, 5.5171205), + initialZoom: 11.0, ), children: [ TileLayer( diff --git a/example/pubspec.lock b/example/pubspec.lock index 46167a6..62b8d93 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -66,10 +66,10 @@ packages: dependency: transitive description: name: flutter_map - sha256: "5286f72f87deb132daa1489442d6cc46e986fc105cb727d9ae1b602b35b1d1f3" + sha256: e625957146c7d2e847da2cdefd893d6f5315ced6ee5228d2c05fec760cab3ad7 url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "6.0.0" flutter_map_tappable_polyline: dependency: "direct main" description: @@ -130,6 +130,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + logger: + dependency: transitive + description: + name: logger + sha256: "6bbb9d6f7056729537a4309bda2e74e18e5d9f14302489cc1e93f33b3fe32cac" + url: "https://pub.dev" + source: hosted + version: "2.0.2+1" matcher: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 5d03879..735daad 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: example description: A new Flutter project. -version: 5.0.0 +version: 6.0.0 publish_to: "none" environment: diff --git a/lib/flutter_map_tappable_polyline.dart b/lib/flutter_map_tappable_polyline.dart index 057cd30..73fb320 100644 --- a/lib/flutter_map_tappable_polyline.dart +++ b/lib/flutter_map_tappable_polyline.dart @@ -3,7 +3,7 @@ library flutter_map_tappable_polyline; import 'dart:math'; import 'package:flutter/widgets.dart'; -import 'package:flutter_map/plugin_api.dart'; +import 'package:flutter_map/flutter_map.dart'; import 'package:latlong2/latlong.dart'; /// A polyline with a tag @@ -45,27 +45,28 @@ class TappablePolylineLayer extends PolylineLayer { this.onTap, this.onMiss, this.pointerDistanceTolerance = 15, - super.polylineCulling = false, - super.key, - }); + polylineCulling = false, + key, + }) : super(key: key, polylines: polylines, polylineCulling: polylineCulling); @override Widget build(BuildContext context) { - final map = FlutterMapState.of(context); + final mapCamera = MapCamera.of(context); return _build( context, - Size(map.size.x, map.size.y), + Size(mapCamera.size.x, mapCamera.size.y), polylineCulling ? polylines - .where((p) => p.boundingBox.isOverlapping(map.bounds)) + .where( + (p) => p.boundingBox.isOverlapping(mapCamera.visibleBounds)) .toList() : polylines, ); } Widget _build(BuildContext context, Size size, List lines) { - FlutterMapState mapState = FlutterMapState.maybeOf(context)!; + final mapState = MapCamera.of(context); for (TaggedPolyline polyline in lines) { polyline._offsets.clear(); @@ -73,7 +74,7 @@ class TappablePolylineLayer extends PolylineLayer { for (var point in polyline.points) { var pos = mapState.project(point); pos = (pos * mapState.getZoomScale(mapState.zoom, mapState.zoom)) - - mapState.pixelOrigin; + mapState.pixelOrigin.toDoublePoint(); polyline._offsets.add(Offset(pos.x.toDouble(), pos.y.toDouble())); if (i > 0 && i < polyline.points.length) { polyline._offsets.add(Offset(pos.x.toDouble(), pos.y.toDouble())); @@ -88,7 +89,7 @@ class TappablePolylineLayer extends PolylineLayer { // For some strange reason i have to add this callback for the onDoubleTapDown callback to be called. }, onDoubleTapDown: (TapDownDetails details) { - _zoomMap(details, context, mapState); + _zoomMap(details, context); }, onTapUp: (TapUpDetails details) { _forwardCallToMapOptions(details, context, mapState); @@ -173,17 +174,18 @@ class TappablePolylineLayer extends PolylineLayer { onTap!(candidates[closestToTapKey], details); } - void _forwardCallToMapOptions( - TapUpDetails details, BuildContext context, FlutterMapState mapState) { - final latlng = _offsetToLatLng(details.localPosition, context.size!.width, - context.size!.height, mapState); - - final tapPosition = - TapPosition(details.globalPosition, details.localPosition); - - // Forward the onTap call to map.options so that we won't break onTap - mapState.options.onTap?.call(tapPosition, latlng); - } + // void _forwardCallToMapOptions(TapUpDetails details, BuildContext context) { + // final latlng = _offsetToLatLng(details.localPosition, context.size!.width, + // context.size!.height, context); + // + // final mapOptions = MapOptions.of(context); + // + // final tapPosition = + // TapPosition(details.globalPosition, details.localPosition); + // + // // Forward the onTap call to map.options so that we won't break onTap + // mapOptions.onTap?.call(tapPosition, latlng); + // } double _distance(Offset point1, Offset point2) { var distancex = (point1.dx - point2.dx).abs(); @@ -194,21 +196,24 @@ class TappablePolylineLayer extends PolylineLayer { return distance; } - void _zoomMap( - TapDownDetails details, BuildContext context, FlutterMapState mapState) { + void _zoomMap(TapDownDetails details, BuildContext context) { + final mapCamera = MapCamera.of(context); + final mapController = MapController.of(context); + var newCenter = _offsetToLatLng(details.localPosition, context.size!.width, - context.size!.height, mapState); - mapState.move(newCenter, mapState.zoom + 0.5, - source: MapEventSource.doubleTap); + context.size!.height, context); + mapController.move(newCenter, mapCamera.zoom + 0.5); } LatLng _offsetToLatLng( - Offset offset, double width, double height, FlutterMapState mapState) { - var localPoint = CustomPoint(offset.dx, offset.dy); + Offset offset, double width, double height, BuildContext context) { + final mapCamera = MapCamera.of(context); + + var localPoint = Point(offset.dx, offset.dy); var localPointCenterDistance = - CustomPoint((width / 2) - localPoint.x, (height / 2) - localPoint.y); - var mapCenter = mapState.project(mapState.center); + Point((width / 2) - localPoint.x, (height / 2) - localPoint.y); + var mapCenter = mapCamera.project(mapCamera.center); var point = mapCenter - localPointCenterDistance; - return mapState.unproject(point); + return mapCamera.unproject(point); } } diff --git a/pubspec.lock b/pubspec.lock index 305afa2..ed17863 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -50,10 +50,10 @@ packages: dependency: "direct main" description: name: flutter_map - sha256: "5286f72f87deb132daa1489442d6cc46e986fc105cb727d9ae1b602b35b1d1f3" + sha256: e625957146c7d2e847da2cdefd893d6f5315ced6ee5228d2c05fec760cab3ad7 url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "6.0.0" http: dependency: transitive description: @@ -102,6 +102,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + logger: + dependency: transitive + description: + name: logger + sha256: "6bbb9d6f7056729537a4309bda2e74e18e5d9f14302489cc1e93f33b3fe32cac" + url: "https://pub.dev" + source: hosted + version: "2.0.2+1" material_color_utilities: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 263f799..4feac53 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_map: ^5.0.0 + flutter_map: ^6.0.0 latlong2: ^0.9.0 dev_dependencies: