-
-
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
Attribution is affected by map rotation #1040
Comments
I was a little confused looking at the implementation of the |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
This issue was closed because it has been stalled for 5 days with no activity. |
Can confirm this is an issue! @Robbendebiene Would be great if you could re-open it? |
@JaffaKetchup I don't think that I can reopen it since the bot closed the issue. At least I don't see any button. |
I've reopened this so hopefully it can get solved at some point soon. |
I would recommend removing this option, since this can easily be achieved with an Align widget inside the |
Not sure what's the best option here. |
I don't think we should get rid of it (just atm anyway), as it would be a breaking change for some. But there should be an added option or documentation about how to add a non-rotated one. Pull requests welcome! |
You could deprecate |
I have no problem with it getting deprecated (I think), but I also think there should be something in place first to replace it. I suspect this will have to be a separate layer as suggested, as whole layers get rotated, and there's no real easy way for a tile layer to do this itself. It's a shame as it is intuitive to have the option as part of the tiles. |
Yeah I agree. I don't want to deprecate this without a replacement as it's quite a useful feature. |
Theoretically in flutter_map_state.dart we could have a method.. List<Widget> _getAttributionLayers() {
final List<Widget> attributionLayers = [];
final layers = [...widget.layers, ...widget.children];
for (final object in layers) {
TileLayerOptions? tileOption;
if (object is TileLayerOptions) {
tileOption = object;
} else if (object is TileLayerWidget) {
tileOption = object.options;
}
if (tileOption != null && tileOption.attributionBuilder != null) {
attributionLayers.add(
Align(
alignment: tileOption.attributionAlignment,
child: tileOption.attributionBuilder!.call(context)
)
);
}
}
return attributionLayers;
} then in _buildmap final List<Widget> attributionLayers = _getAttributionLayers(); and in the nonRotatedChildren area have.. if(attributionLayers.isNotEmpty)
...attributionLayers, Remove the bit of code from TileLayer. I think this would work... |
Personally that's a bit too clunky for me, and would just pollute the code in my opinion. However, I don't have another solution (other than just wrapping the |
I don't think there's any nice way to do it without introducing a separate normal Widget layer. Another alternative then.... attribution_layer.dart import 'package:flutter/widgets.dart';
class AttributionWidget extends StatelessWidget {
final WidgetBuilder attributionBuilder;
final Alignment alignment;
const AttributionWidget({Key? key, required this.attributionBuilder, this.alignment = Alignment.bottomRight})
: super(key: key);
@override
Widget build(BuildContext context) {
return Align(
alignment: alignment,
child: attributionBuilder.call(context)
);
}
} flutter_map.dart export 'package:flutter_map/src/layer/attribution_layer.dart'; Where you end up including flutter_map nonRotatedChildren: [
AttributionWidget(
attributionBuilder: (_) {
return Text("© OpenStreetMap2 contributors");
}
)], Leave the original in and mark to be removed in future. |
Yeah that's probably the best option, I like it. It's small and still mostly self explanatory. Do you want to open PR or shall I? |
I'm out now until tomorrow, so feel free. |
The attribution widget introduced by @ondbyte (#1012) gets rotated whenever the map is rotated.
Maybe
attributionBuilder
is supposed to be used in thenonRotatedLayers
layer, but this means that the tiles of theTileLayerOptions
won't be rotated as well.I feel like the
attributionBuilder
in theTileLayerOptions
is obsolete, since one can add any number of widgets over the map usingchildren
andnonRotatedChildren
which is way more powerful.The text was updated successfully, but these errors were encountered: