feat(map in info): made map marker flexible in size without without distorting it's parts (image and pointer)

This commit is contained in:
ashilkn 2024-01-30 18:42:21 +05:30
parent 17bd6429fb
commit d05fd44a65
2 changed files with 17 additions and 6 deletions

View file

@ -2,21 +2,28 @@ import "package:flutter/material.dart";
import "package:flutter_map/flutter_map.dart";
import "package:latlong2/latlong.dart";
import "package:photos/ui/map/image_marker.dart";
import "package:photos/ui/map/map_view.dart";
import "package:photos/ui/map/marker_image.dart";
Marker mapMarker(ImageMarker imageMarker, String key) {
Marker mapMarker(
ImageMarker imageMarker,
String key, {
Size markerSize = MapView.defaultMarkerSize,
}) {
return Marker(
anchorPos: AnchorPos.exactly(Anchor(75 / 2, -6.5)),
//-6.5 is for taking in the height of the MarkerPointer
anchorPos: AnchorPos.exactly(Anchor(markerSize.height / 2, -6.5)),
key: Key(key),
width: 75,
height: 75,
width: markerSize.width,
height: markerSize.height,
point: LatLng(
imageMarker.latitude,
imageMarker.longitude,
),
builder: (context) => MarkerImage(
file: imageMarker.imageFile,
seperator: 85,
seperator: (MapView.defaultMarkerSize.height + 10) -
(MapView.defaultMarkerSize.height - markerSize.height),
),
);
}

View file

@ -23,6 +23,8 @@ class MapView extends StatefulWidget {
final bool showControls;
final int interactiveFlags;
final VoidCallback? onTap;
final Size markerSize;
static const defaultMarkerSize = Size(75, 75);
const MapView({
Key? key,
@ -35,6 +37,7 @@ class MapView extends StatefulWidget {
required this.initialZoom,
required this.debounceDuration,
required this.bottomSheetDraggableAreaHeight,
this.markerSize = MapView.defaultMarkerSize,
this.onTap,
this.interactiveFlags = InteractiveFlag.all,
this.showControls = true,
@ -113,7 +116,7 @@ class _MapViewState extends State<MapView> {
anchorPos: AnchorPos.align(AnchorAlign.top),
maxClusterRadius: 100,
showPolygon: false,
size: const Size(75, 75),
size: widget.markerSize,
fitBoundsOptions: const FitBoundsOptions(
padding: EdgeInsets.all(80),
),
@ -200,6 +203,7 @@ class _MapViewState extends State<MapView> {
return mapMarker(
imageMarker,
index.toString(),
markerSize: widget.markerSize,
);
});
}