From 5f1d8e12cc714924728a6b851cca7913a0d16bc1 Mon Sep 17 00:00:00 2001 From: Bruno Milare Date: Mon, 23 Apr 2018 10:51:24 -0300 Subject: [PATCH] Add marker anchor support --- flutter_map/lib/src/layer/marker_layer.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flutter_map/lib/src/layer/marker_layer.dart b/flutter_map/lib/src/layer/marker_layer.dart index 4bc525f61..7b063af34 100644 --- a/flutter_map/lib/src/layer/marker_layer.dart +++ b/flutter_map/lib/src/layer/marker_layer.dart @@ -13,11 +13,13 @@ class Marker { final WidgetBuilder builder; final double width; final double height; + final List anchor; Marker({ this.point, this.builder, this.width = 30.0, this.height = 30.0, + this.anchor = const [15.0, 15.0] }); } @@ -40,8 +42,8 @@ class MarkerLayer extends StatelessWidget { new Positioned( width: markerOpt.width, height: markerOpt.height, - left: (pos.x - markerOpt.width / 2).toDouble(), - top: (pos.y - markerOpt.height / 2).toDouble(), + left: (pos.x - (markerOpt.width - markerOpt.anchor[0])).toDouble(), + top: (pos.y - (markerOpt.height - markerOpt.anchor[1])).toDouble(), child: markerOpt.builder(context), ), );