-
-
Notifications
You must be signed in to change notification settings - Fork 860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Markers with rotate: true
do not adjust their anchor
#1500
Comments
Here's what the minimum repro looks like with the rotation.fixed.mp4The origin passed in here is the point opposite the anchor (width - left, height - top). The defaulting behavior of Workaround code fragment, with the origins hardcoded for simplicityimport 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
void main() => runApp(
MaterialApp(
home: Scaffold(
body: FlutterMap(
options: MapOptions(center: LatLng(0, 0)),
children: [
MarkerLayer(
rotate: true,
rotateAlignment: null,
markers: [
Marker(
point: LatLng(-.05, 0),
rotate: false,
builder: (context) => const ColoredBox(color: Colors.black),
),
Marker(
point: LatLng(.05, 0),
rotate: false,
builder: (context) => const ColoredBox(color: Colors.black),
),
Marker(
point: LatLng(0, 0),
width: 256,
height: 256,
anchorPos: AnchorPos.align(AnchorAlign.left),
rotateOrigin: const Offset(256, 128),
builder: (context) => const ColoredBox(
color: Colors.lightBlue,
child: Align(
alignment: Alignment.centerRight,
child: Text('-->'),
),
),
),
Marker(
point: LatLng(0, 0),
width: 256,
height: 256,
anchorPos: AnchorPos.align(AnchorAlign.right),
rotateOrigin: const Offset(0, 128),
builder: (context) => const ColoredBox(
color: Colors.pink,
child: Align(
alignment: Alignment.centerLeft,
child: Text('<--'),
),
),
),
],
),
],
),
),
),
); |
Thanks for the report! We'll investigate. |
Hi @AsturaPhoenix, Just to let you know, I did have a crack at implementing this for v5, but I couldn't get it to work correctly in all situations - I think I messed up with scaling/CRS translations somewhere, as the points vanished off to the other side of the world in some cases :D Leaving this open. |
Hi, is there any news on a solution for this fix? |
@ElecSmurf In case you're blocked, you can work around this issue by specifying a |
Not sure this is what you're looking for, but I recall we had a similar issue ages ago where markers would float around the map during rotation. Fix was to design a marker that matches one of the default Now you can rotate freely and it keeps the markers anchored where they're needed. |
I also just found out that just setting |
Fixed #1500 Removed `AnchorAlign` (without deprecation), preferring `Alignment` Added new documentation
What is the bug?
Markers (and info windows implemented as markers) with
rotate: true
to counter map rotation float around unexpectedly when the map is rotated. This seems to be because the rotation does not include the anchor offset, which is thus applied in the rotated space.What is the expected behaviour?
Marker geometry at the anchor position remains stationary in the map space when the map is rotated. That is, if the marker geometry is pointing at a particular map location and
rotate: true
, I expect the marker to continue pointing at that map location as the map is rotated.How can we reproduce this issue?
Do you have a potential solution?
A workaround could be to pass the resolved
Anchor
asrotateOrigin
.Fixes might include applying the anchor offset as a
Transform
, or fully usingTransform
s instead ofPositioned
widgets.Can you provide any other information?
The effect is more pronounced as markers are larger. In the video below, it is particularly pronounced on the info window "markers", which are sized to a max size much larger than the info window itself.
rotation.mp4
Platforms Affected
Android, iOS, Web, Windows, MacOS, Linux, Other
Severity
Minimum: Allows normal functioning
Frequency
Consistently: Always occurs at the same time and location
Requirements
flutter doctor
finds no relevant issuesThe text was updated successfully, but these errors were encountered: