Minor fixes
This commit is contained in:
parent
eecf26522d
commit
4325641b14
|
@ -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,34 +75,29 @@ 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(
|
if (!hasAnyLocation) {
|
||||||
latitude: 10.786971 * rand.nextDouble() * 0.1,
|
minLat = file.location!.latitude!;
|
||||||
longitude: 78.688241 * rand.nextDouble() * 0.1,
|
minLon = file.location!.longitude!;
|
||||||
);
|
maxLat = file.location!.latitude!;
|
||||||
// if (file.hasLocation) {
|
maxLon = file.location!.longitude!;
|
||||||
if (!hasAnyLocation) {
|
hasAnyLocation = true;
|
||||||
minLat = file.location!.latitude!;
|
} else {
|
||||||
minLon = file.location!.longitude!;
|
minLat = min(minLat, file.location!.latitude!);
|
||||||
maxLat = file.location!.latitude!;
|
minLon = min(minLon, file.location!.longitude!);
|
||||||
maxLon = file.location!.longitude!;
|
maxLat = max(maxLat, file.location!.latitude!);
|
||||||
hasAnyLocation = true;
|
maxLon = max(maxLon, file.location!.longitude!);
|
||||||
} else {
|
}
|
||||||
minLat = min(minLat, file.location!.latitude!);
|
tempMarkers.add(
|
||||||
minLon = min(minLon, file.location!.longitude!);
|
ImageMarker(
|
||||||
maxLat = max(maxLat, file.location!.latitude!);
|
latitude: file.location!.latitude!,
|
||||||
maxLon = max(maxLon, file.location!.longitude!);
|
longitude: file.location!.longitude!,
|
||||||
|
imageFile: file,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
tempMarkers.add(
|
}
|
||||||
ImageMarker(
|
|
||||||
latitude: file.location!.latitude!,
|
|
||||||
longitude: file.location!.longitude!,
|
|
||||||
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());
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue