Closed comatory closed 1 year ago
Could someone point me how to implement this? I believe the plugin has to do this internally anyway since fitBounds
takes padding. Could you point me to relevant code?
Would be great to expose some utilities that do this calculation as well.
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.
I had to do this too, and ended up having to copy most of the relevant code in src/map/map.dart 😞. Hope this helps!
I had the same problem and was able to do it with the following lines:
LatLng _moveByBottomPadding(LatLng coordinates, double zoomLevel, double bottomOffset) {
// the following code is copied from unreachable flutter map internas
final crs = const Epsg3857();
final oldCenterPt = crs.latLngToPoint(coordinates, zoomLevel);
final offset = CustomPoint(0, bottomOffset);
final newCenterPt = oldCenterPt + offset;
final newCenter = crs.pointToLatLng(newCenterPt, zoomLevel);
return newCenter;
}
Would be nice if this is directly provided by the API :-)
@comatory how do you obtain the size/offset of bottom sheet ?
@comatory how do you obtain the size/offset of bottom sheet ?
There is a way to obtain widget sizes in Flutter, can't tell you from head right now but you use widget's key currentContext
property: https://stackoverflow.com/questions/49307677/how-to-get-height-of-a-widget
So I have a handler set up that after user changes size of the bottom sheet by dragging, I look up the size and store the value so I can then use it as an offset later. I also have to do it initially when the widget is mounted.
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.
Bump. I tried using @heebj but that did not work for me. Could we get this functionality built-in?
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.
This will be added for v5 by #1532 (2764747)!
I want to actually reopen this issue https://github.com/fleaflet/flutter_map/issues/777
I think it would be super useful to have. I have used Mapbox Javascript SDK in the past and would take advantage of their ability to calculate offset via pixels.
My use case is that I have map that takes up the whole screen. Then I have bottom sheet that covers the bottom of the map. Now I want to center / move map to programmatically via
MapController
, the problem is the bottom sheet could cover the point where I want to move. The bottom sheet is also expandable, you can pull it up and down so you never know it's size.I could get the height of the sheet in pixels before I center or move the map but at the moment, I can't easily do this since the
move
andmoveAndRotate
method does take any parameter. It seems likefitBounds
uses padding which I'm not sure if it's the same.I might resort to zooming out a bit to make sure it's not completely covered but it'd be really nice to have this feature.