-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[google_maps_flutter_web] set icon anchor for markers #8077
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
Changes from 1 commit
f93d346
16b28da
0dfee76
82839e4
dcbadfa
aa4a154
bb87e8e
0f8c9a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
## NEXT | ||
## 0.5.11 | ||
|
||
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. | ||
* Adds support for marker anchor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing a period (per linked CHANGELOG style). |
||
|
||
## 0.5.10 | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -493,5 +493,45 @@ void main() { | |||||||
expect(event, isA<InfoWindowTapEvent>()); | ||||||||
expect((event as InfoWindowTapEvent).value, equals(const MarkerId('1'))); | ||||||||
}); | ||||||||
|
||||||||
// https://github.com/flutter/flutter/issues/80578 | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not necessary to link to an issue when the purpose of the test is self-evident. There's nothing subtle here that requires the context of the issue to understand. |
||||||||
testWidgets('markers with anchor work', (WidgetTester tester) async { | ||||||||
final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); | ||||||||
final Marker marker1 = Marker( | ||||||||
markerId: const MarkerId('1'), | ||||||||
icon: BytesMapBitmap( | ||||||||
bytes, | ||||||||
width: 20, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use local constants instead of repeating magic numbers throughout the test. |
||||||||
height: 30, | ||||||||
), | ||||||||
); | ||||||||
final Marker marker2 = Marker( | ||||||||
markerId: const MarkerId('2'), | ||||||||
icon: BytesMapBitmap( | ||||||||
bytes, | ||||||||
width: 20, | ||||||||
height: 30, | ||||||||
), | ||||||||
anchor: const Offset(1.5, 2), | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anchors are in a normalized coordinate space; why are these both more than 1.0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not quite sure what you mean by this comment. What is it normalized to? The default value for anchor is const Offset(0.5, 1). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Lines 43 to 45 in 5498d4d
This is setting an anchor that is well outside the image's bounds in both directions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An example (from our project) to use an anchor outside the bounds would be positioning 2 markers in relation to one another. Eg a point (user's position) marker and a label for that point marker where the label needs to be offset from the marker and positioned lower on the y axis of the map. |
||||||||
); | ||||||||
final Set<Marker> markers = <Marker>{marker1, marker2}; | ||||||||
|
||||||||
await controller.addMarkers(markers); | ||||||||
expect(controller.markers.length, 2); | ||||||||
|
||||||||
final gmaps.Icon? icon1 = | ||||||||
controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; | ||||||||
expect(icon1, isNotNull); | ||||||||
final gmaps.Icon? icon2 = | ||||||||
controller.markers[const MarkerId('2')]?.marker?.icon as gmaps.Icon?; | ||||||||
expect(icon2, isNotNull); | ||||||||
|
||||||||
expect(icon1!.anchor, isNotNull); | ||||||||
expect(icon2!.anchor, isNotNull); | ||||||||
expect(icon1.anchor!.x, 20 * 0.5); | ||||||||
expect(icon1.anchor!.y, 30 * 1); | ||||||||
expect(icon2.anchor!.x, 20 * 1.5); | ||||||||
expect(icon2.anchor!.y, 30 * 2); | ||||||||
}); | ||||||||
}); | ||||||||
} |
Uh oh!
There was an error while loading. Please reload this page.