nc-photos/lib/mobile/map_widget.dart
2021-07-25 00:23:08 +08:00

48 lines
1.3 KiB
Dart

import 'package:flutter/widgets.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:tuple/tuple.dart';
class Map extends StatelessWidget {
const Map({
Key? key,
required this.center,
required this.zoom,
this.onTap,
}) : super(key: key);
@override
build(BuildContext context) {
final centerLl = LatLng(center.item1, center.item2);
return GoogleMap(
compassEnabled: false,
mapToolbarEnabled: false,
rotateGesturesEnabled: false,
scrollGesturesEnabled: false,
zoomControlsEnabled: false,
zoomGesturesEnabled: false,
tiltGesturesEnabled: false,
myLocationButtonEnabled: false,
buildingsEnabled: false,
// liteModeEnabled: true,
initialCameraPosition: CameraPosition(
target: centerLl,
zoom: zoom,
),
markers: {
Marker(
markerId: MarkerId("at"),
position: centerLl,
// for some reason, GoogleMap's onTap is not triggered if
// tapped on top of the marker
onTap: onTap,
),
},
onTap: (_) => onTap?.call(),
);
}
/// A pair of latitude and longitude coordinates, stored as degrees
final Tuple2<double, double> center;
final double zoom;
final VoidCallback? onTap;
}