Merge branch 'soru/maps-widget' into 'main'

fix: Properly position the pointer in the map bubble and add attribution

See merge request famedly/fluffychat!592
This commit is contained in:
Krille Fear 2021-11-29 15:25:11 +00:00
commit efddd1daf1

View File

@ -28,28 +28,56 @@ class MapBubble extends StatelessWidget {
constraints: BoxConstraints.loose(Size(width, height)), constraints: BoxConstraints.loose(Size(width, height)),
child: AspectRatio( child: AspectRatio(
aspectRatio: width / height, aspectRatio: width / height,
child: FlutterMap( child: Stack(
options: MapOptions( children: <Widget>[
center: LatLng(latitude, longitude), FlutterMap(
zoom: zoom, options: MapOptions(
), center: LatLng(latitude, longitude),
layers: [ zoom: zoom,
TileLayerOptions( ),
urlTemplate: layers: [
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', TileLayerOptions(
subdomains: ['a', 'b', 'c'], urlTemplate:
), 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
MarkerLayerOptions( subdomains: ['a', 'b', 'c'],
markers: [ ),
Marker( MarkerLayerOptions(
point: LatLng(latitude, longitude), rotate: true,
builder: (context) => const Icon( markers: [
Icons.location_pin, Marker(
color: Colors.red, point: LatLng(latitude, longitude),
), width: 30,
height: 30,
builder: (_) => Transform.translate(
// No idea why the offset has to be like this, instead of -15
// It has been determined by trying out, though, that this yields
// the tip of the location pin to be static when zooming.
// Might have to do with psychological perception of where the tip exactly is
offset: const Offset(0, -12.5),
child: const Icon(
Icons.location_pin,
color: Colors.red,
size: 30,
),
),
),
],
), ),
], ],
), ),
Container(
alignment: Alignment.bottomRight,
child: Text(
' © OpenStreetMap contributors ',
style: TextStyle(
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black,
backgroundColor:
Theme.of(context).appBarTheme.backgroundColor,
),
),
),
], ],
), ),
), ),