From 4325641b1403fc1f950cb4661a1dc2e96c285ad4 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:04:33 +0530 Subject: [PATCH] Minor fixes --- lib/ui/map/map_screen.dart | 54 +++++++++++++++++--------------------- lib/ui/map/map_view.dart | 6 ++--- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/lib/ui/map/map_screen.dart b/lib/ui/map/map_screen.dart index 4e98aa623..cf6cdd038 100644 --- a/lib/ui/map/map_screen.dart +++ b/lib/ui/map/map_screen.dart @@ -8,7 +8,6 @@ import 'package:flutter_map/flutter_map.dart'; import "package:latlong2/latlong.dart"; import "package:logging/logging.dart"; import "package:photos/models/file.dart"; -import "package:photos/models/location/location.dart"; import "package:photos/theme/ente_theme.dart"; import "package:photos/ui/common/loading_widget.dart"; import "package:photos/ui/map/image_marker.dart"; @@ -76,34 +75,29 @@ class _MapScreenState extends State { late double minLat, maxLat, minLon, maxLon; final List tempMarkers = []; bool hasAnyLocation = false; - await Future.forEach(files, (file) async { - final rand = Random(); - file.location = Location( - latitude: 10.786971 * rand.nextDouble() * 0.1, - longitude: 78.688241 * rand.nextDouble() * 0.1, - ); - // if (file.hasLocation) { - if (!hasAnyLocation) { - minLat = file.location!.latitude!; - minLon = file.location!.longitude!; - maxLat = file.location!.latitude!; - maxLon = file.location!.longitude!; - hasAnyLocation = true; - } else { - minLat = min(minLat, file.location!.latitude!); - minLon = min(minLon, file.location!.longitude!); - maxLat = max(maxLat, file.location!.latitude!); - maxLon = max(maxLon, file.location!.longitude!); + for (final file in files) { + if (file.hasLocation) { + if (!hasAnyLocation) { + minLat = file.location!.latitude!; + minLon = file.location!.longitude!; + maxLat = file.location!.latitude!; + maxLon = file.location!.longitude!; + hasAnyLocation = true; + } else { + minLat = min(minLat, file.location!.latitude!); + minLon = min(minLon, file.location!.longitude!); + maxLat = max(maxLat, file.location!.latitude!); + maxLon = max(maxLon, file.location!.longitude!); + } + tempMarkers.add( + ImageMarker( + latitude: file.location!.latitude!, + longitude: file.location!.longitude!, + imageFile: file, + ), + ); } - tempMarkers.add( - ImageMarker( - latitude: file.location!.latitude!, - longitude: file.location!.longitude!, - imageFile: file, - ), - ); - // } - }); + } if (hasAnyLocation) { center = LatLng( @@ -176,12 +170,12 @@ class _MapScreenState extends State { final SendPort sendPort = message.sendPort; try { final List images = []; - imageMarkers.forEach((imageMarker) async { + for (var imageMarker in imageMarkers) { final point = LatLng(imageMarker.latitude, imageMarker.longitude); if (bounds.contains(point)) { images.add(imageMarker.imageFile); } - }); + } sendPort.send(images); } catch (e) { sendPort.send(e.toString()); diff --git a/lib/ui/map/map_view.dart b/lib/ui/map/map_view.dart index eab6f8f74..65111307c 100644 --- a/lib/ui/map/map_view.dart +++ b/lib/ui/map/map_view.dart @@ -1,4 +1,5 @@ import "dart:async"; + import "package:flutter/material.dart"; import "package:flutter_map/flutter_map.dart"; import "package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart"; @@ -43,6 +44,7 @@ class _MapViewState extends State { @override void initState() { super.initState(); + debugPrint("minZoom ${widget.minZoom} and maxZoom ${widget.maxZoom}"); // widget.controller.move(widget.center, widget.initialZoom); } @@ -64,10 +66,6 @@ class _MapViewState extends State { minZoom: widget.minZoom, maxZoom: widget.maxZoom, enableMultiFingerGestureRace: true, - maxBounds: LatLngBounds( - LatLng(-90, -180), - LatLng(90, 180), - ), zoom: widget.initialZoom, onPositionChanged: (position, hasGesture) { if (position.bounds != null) {