mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 08:46:18 +01:00
Use actual type for map coord
This commit is contained in:
parent
63eb4d6c88
commit
0d68fdff4a
6 changed files with 22 additions and 9 deletions
|
@ -399,7 +399,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
|||
final lng = exif.gpsLongitudeDeg;
|
||||
if (lat != null && lng != null) {
|
||||
_log.fine("GPS: ($lat, $lng)");
|
||||
_gps = (lat: lat, lng: lng);
|
||||
_gps = MapCoord(lat, lng);
|
||||
_location = _file!.location;
|
||||
}
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
|||
if (getRawPlatform() == NpPlatform.android) {
|
||||
final intent = AndroidIntent(
|
||||
action: "action_view",
|
||||
data: Uri.encodeFull("geo:${_gps!.lat},${_gps!.lng}?z=16"),
|
||||
data: Uri.encodeFull("geo:${_gps!.latitude},${_gps!.longitude}?z=16"),
|
||||
);
|
||||
intent.launch();
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
|||
String? _exposureTime;
|
||||
double? _focalLength;
|
||||
int? _isoSpeedRatings;
|
||||
({double lat, double lng})? _gps;
|
||||
MapCoord? _gps;
|
||||
ImageLocation? _location;
|
||||
|
||||
final _tags = <String>[];
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
library np_gps_map;
|
||||
|
||||
export 'src/gps_map.dart';
|
||||
export 'src/map_coord.dart';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:np_gps_map/src/map_coord.dart';
|
||||
import 'package:np_gps_map/src/native.dart';
|
||||
import 'package:np_gps_map/src/native/google_gps_map.dart'
|
||||
if (dart.library.html) 'package:np_gps_map/src/web/google_gps_map.dart';
|
||||
|
@ -49,7 +50,7 @@ class GpsMap extends StatelessWidget {
|
|||
final GpsMapProvider providerHint;
|
||||
|
||||
/// A pair of latitude and longitude coordinates, stored as degrees
|
||||
final ({double lat, double lng}) center;
|
||||
final MapCoord center;
|
||||
final double zoom;
|
||||
final void Function()? onTap;
|
||||
|
||||
|
|
9
np_gps_map/lib/src/map_coord.dart
Normal file
9
np_gps_map/lib/src/map_coord.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
class MapCoord {
|
||||
const MapCoord(this.latitude, this.longitude);
|
||||
|
||||
@override
|
||||
String toString() => "MapCoord {latitude: $latitude, longitude: $longitude}";
|
||||
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:np_gps_map/src/map_coord.dart';
|
||||
|
||||
class GoogleGpsMap extends StatelessWidget {
|
||||
const GoogleGpsMap({
|
||||
|
@ -11,7 +12,7 @@ class GoogleGpsMap extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final centerLl = LatLng(center.lat, center.lng);
|
||||
final centerLl = LatLng(center.latitude, center.longitude);
|
||||
return GoogleMap(
|
||||
compassEnabled: false,
|
||||
mapToolbarEnabled: false,
|
||||
|
@ -40,7 +41,7 @@ class GoogleGpsMap extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
final ({double lat, double lng}) center;
|
||||
final MapCoord center;
|
||||
final double zoom;
|
||||
final VoidCallback? onTap;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:np_gps_map/src/map_coord.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
class OsmGpsMap extends StatelessWidget {
|
||||
|
@ -14,11 +15,11 @@ class OsmGpsMap extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const double pinSize = 48;
|
||||
final centerLl = LatLng(center.lat, center.lng);
|
||||
final centerLl = LatLng(center.latitude, center.longitude);
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
launchUrlString(
|
||||
"https://www.openstreetmap.org/?mlat=${center.lat}&mlon=${center.lng}#map=${zoom.toInt()}/${center.lat}/${center.lng}",
|
||||
"https://www.openstreetmap.org/?mlat=${center.latitude}&mlon=${center.longitude}#map=${zoom.toInt()}/${center.latitude}/${center.longitude}",
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
|
@ -61,7 +62,7 @@ class OsmGpsMap extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
final ({double lat, double lng}) center;
|
||||
final MapCoord center;
|
||||
final double zoom;
|
||||
final void Function()? onTap;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue