nc-photos/np_gps_map/lib/src/static_map.dart

40 lines
1.1 KiB
Dart
Raw Normal View History

2023-09-12 18:29:44 +02:00
import 'package:flutter/material.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';
import 'package:np_gps_map/src/osm_gps_map.dart';
import 'package:np_gps_map/src/type.dart';
import 'package:np_gps_map/src/util.dart';
2023-09-12 18:29:44 +02:00
import 'package:np_platform_util/np_platform_util.dart';
2024-10-30 15:26:11 +01:00
class StaticMap extends StatelessWidget {
const StaticMap({
2023-09-12 18:29:44 +02:00
super.key,
required this.providerHint,
2024-10-30 15:22:49 +01:00
required this.location,
2023-09-12 18:29:44 +02:00
this.onTap,
});
@override
Widget build(BuildContext context) {
if (providerHint == GpsMapProvider.osm ||
(getRawPlatform() == NpPlatform.android && !isNewGMapsRenderer())) {
2023-09-12 18:29:44 +02:00
return OsmGpsMap(
2024-10-30 15:22:49 +01:00
location: location,
2023-09-12 18:29:44 +02:00
onTap: onTap,
);
} else {
return GoogleGpsMap(
2024-10-30 15:22:49 +01:00
location: location,
2023-09-12 18:29:44 +02:00
onTap: onTap,
);
}
}
/// The backend to provide the actual map. This works as a hint only, the
/// actual choice may be different depending on the runtime environment
final GpsMapProvider providerHint;
2024-10-30 15:22:49 +01:00
final CameraPosition location;
2023-09-12 18:29:44 +02:00
final void Function()? onTap;
}