Minor fixes

This commit is contained in:
Neeraj Gupta 2023-06-14 17:04:33 +05:30
parent eecf26522d
commit 4325641b14
2 changed files with 26 additions and 34 deletions

View file

@ -8,7 +8,6 @@ import 'package:flutter_map/flutter_map.dart';
import "package:latlong2/latlong.dart"; import "package:latlong2/latlong.dart";
import "package:logging/logging.dart"; import "package:logging/logging.dart";
import "package:photos/models/file.dart"; import "package:photos/models/file.dart";
import "package:photos/models/location/location.dart";
import "package:photos/theme/ente_theme.dart"; import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/common/loading_widget.dart"; import "package:photos/ui/common/loading_widget.dart";
import "package:photos/ui/map/image_marker.dart"; import "package:photos/ui/map/image_marker.dart";
@ -76,13 +75,8 @@ class _MapScreenState extends State<MapScreen> {
late double minLat, maxLat, minLon, maxLon; late double minLat, maxLat, minLon, maxLon;
final List<ImageMarker> tempMarkers = []; final List<ImageMarker> tempMarkers = [];
bool hasAnyLocation = false; bool hasAnyLocation = false;
await Future.forEach<File>(files, (file) async { for (final file in files) {
final rand = Random(); if (file.hasLocation) {
file.location = Location(
latitude: 10.786971 * rand.nextDouble() * 0.1,
longitude: 78.688241 * rand.nextDouble() * 0.1,
);
// if (file.hasLocation) {
if (!hasAnyLocation) { if (!hasAnyLocation) {
minLat = file.location!.latitude!; minLat = file.location!.latitude!;
minLon = file.location!.longitude!; minLon = file.location!.longitude!;
@ -102,8 +96,8 @@ class _MapScreenState extends State<MapScreen> {
imageFile: file, imageFile: file,
), ),
); );
// } }
}); }
if (hasAnyLocation) { if (hasAnyLocation) {
center = LatLng( center = LatLng(
@ -176,12 +170,12 @@ class _MapScreenState extends State<MapScreen> {
final SendPort sendPort = message.sendPort; final SendPort sendPort = message.sendPort;
try { try {
final List<File> images = []; final List<File> images = [];
imageMarkers.forEach((imageMarker) async { for (var imageMarker in imageMarkers) {
final point = LatLng(imageMarker.latitude, imageMarker.longitude); final point = LatLng(imageMarker.latitude, imageMarker.longitude);
if (bounds.contains(point)) { if (bounds.contains(point)) {
images.add(imageMarker.imageFile); images.add(imageMarker.imageFile);
} }
}); }
sendPort.send(images); sendPort.send(images);
} catch (e) { } catch (e) {
sendPort.send(e.toString()); sendPort.send(e.toString());

View file

@ -1,4 +1,5 @@
import "dart:async"; import "dart:async";
import "package:flutter/material.dart"; import "package:flutter/material.dart";
import "package:flutter_map/flutter_map.dart"; import "package:flutter_map/flutter_map.dart";
import "package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart"; import "package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart";
@ -43,6 +44,7 @@ class _MapViewState extends State<MapView> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
debugPrint("minZoom ${widget.minZoom} and maxZoom ${widget.maxZoom}");
// widget.controller.move(widget.center, widget.initialZoom); // widget.controller.move(widget.center, widget.initialZoom);
} }
@ -64,10 +66,6 @@ class _MapViewState extends State<MapView> {
minZoom: widget.minZoom, minZoom: widget.minZoom,
maxZoom: widget.maxZoom, maxZoom: widget.maxZoom,
enableMultiFingerGestureRace: true, enableMultiFingerGestureRace: true,
maxBounds: LatLngBounds(
LatLng(-90, -180),
LatLng(90, 180),
),
zoom: widget.initialZoom, zoom: widget.initialZoom,
onPositionChanged: (position, hasGesture) { onPositionChanged: (position, hasGesture) {
if (position.bounds != null) { if (position.bounds != null) {