Skip to content
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

Camera padding for FollowPuckViewportState? #825

Open
RebinX1 opened this issue Dec 30, 2024 · 1 comment
Open

Camera padding for FollowPuckViewportState? #825

RebinX1 opened this issue Dec 30, 2024 · 1 comment

Comments

@RebinX1
Copy link

RebinX1 commented Dec 30, 2024

is there a way to add a camera padding for FollowPuckViewportState?

i have this code which zooms on the user location in my map, what i want is to make it so that we show the user location at the bottom portion of the screen, is there a possible way for that?

`
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart' as mapbox;
import 'package:cee/domain/services/location_service.dart';

part 'map_viewport_provider.g.dart';

@riverpod
class MapViewportState extends _$MapViewportState {
final _locationService = LocationServiceImpl();

@OverRide
FutureOr<mapbox.ViewportState> build() async {
final position = await _locationService.getCurrentLocation();

if (position == null) {
  throw Exception('Could not get current location');
}

// Start with FollowPuckViewportState by default
return mapbox.FollowPuckViewportState(
  zoom: 15.5,
  bearing: mapbox.FollowPuckViewportStateBearingCourse(),
  pitch: 45,
);

}

// Called when user interacts with map
void setIdleState() {
state = const AsyncValue.data(mapbox.IdleViewportState());
}

// Called when location panning button is pressed
void enableFollowPuckMode() {
state = AsyncValue.data(mapbox.FollowPuckViewportState(
zoom: 15.5,
bearing: mapbox.FollowPuckViewportStateBearingCourse(),
pitch: 45,
));
}
}
`

@noforeignland
Copy link

You can add padding but it does not work from Flutter, see #816

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants