mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 08:46:18 +01:00
Add compass icon to show and reset OSM map orientation
This commit is contained in:
parent
dda79dadcc
commit
a37175d92a
7 changed files with 51 additions and 0 deletions
BIN
np_gps_map/assets/2.0x/map_compass.png
Normal file
BIN
np_gps_map/assets/2.0x/map_compass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
np_gps_map/assets/2.0x/map_compass_dark.png
Normal file
BIN
np_gps_map/assets/2.0x/map_compass_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
np_gps_map/assets/3.0x/map_compass.png
Normal file
BIN
np_gps_map/assets/3.0x/map_compass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
np_gps_map/assets/3.0x/map_compass_dark.png
Normal file
BIN
np_gps_map/assets/3.0x/map_compass_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
np_gps_map/assets/map_compass.png
Normal file
BIN
np_gps_map/assets/map_compass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 715 B |
BIN
np_gps_map/assets/map_compass_dark.png
Normal file
BIN
np_gps_map/assets/map_compass_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 725 B |
|
@ -107,6 +107,21 @@ class _OsmInteractiveMapState extends State<OsmInteractiveMap> {
|
|||
source: Text("OpenStreetMap contributors"),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
8, MediaQuery.of(context).padding.top + 8, 8, 0),
|
||||
child: _CompassIcon(
|
||||
mapRotationRadSubject: _mapRotationRadSubject,
|
||||
onTap: () {
|
||||
if (_controller.camera.rotation != 0) {
|
||||
_controller.rotate(0);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -135,6 +150,42 @@ class _OsmInteractiveMapState extends State<OsmInteractiveMap> {
|
|||
final _subscriptions = <StreamSubscription>[];
|
||||
}
|
||||
|
||||
class _CompassIcon extends StatelessWidget {
|
||||
const _CompassIcon({
|
||||
required this.mapRotationRadSubject,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StreamBuilder(
|
||||
stream: mapRotationRadSubject.stream,
|
||||
initialData: mapRotationRadSubject.value,
|
||||
builder: (context, snapshot) => Transform.rotate(
|
||||
angle: snapshot.requireData,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
onTap?.call();
|
||||
},
|
||||
child: Opacity(
|
||||
opacity: .8,
|
||||
child: Image(
|
||||
image: Theme.of(context).brightness == Brightness.light
|
||||
? const AssetImage(
|
||||
"packages/np_gps_map/assets/map_compass.png")
|
||||
: const AssetImage(
|
||||
"packages/np_gps_map/assets/map_compass_dark.png"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final BehaviorSubject<double> mapRotationRadSubject;
|
||||
final VoidCallback? onTap;
|
||||
}
|
||||
|
||||
class _OsmDataPoint extends Marker {
|
||||
_OsmDataPoint({
|
||||
required this.original,
|
||||
|
|
Loading…
Reference in a new issue