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

web: ignore myLocationTrackingMode if myLocationEnabled is false #363

Merged
merged 1 commit into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/src/mapbox_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class MapboxMap extends StatefulWidget {
/// when the map tries to turn on the My Location layer.
final bool myLocationEnabled;

/// The mode used to let the map's camera follow the device's physical location
/// The mode used to let the map's camera follow the device's physical location.
/// `myLocationEnabled` needs to be true for values other than `MyLocationTrackingMode.None` to work.
final MyLocationTrackingMode myLocationTrackingMode;

/// The mode to render the user location symbol
Expand Down
1 change: 1 addition & 0 deletions mapbox_gl_web/lib/src/convert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Convert {
sink.setMyLocationEnabled(options['myLocationEnabled']);
}
if (options.containsKey('myLocationTrackingMode')) {
//Should not be invoked before sink.setMyLocationEnabled()
sink.setMyLocationTrackingMode(options['myLocationTrackingMode']);
}
if (options.containsKey('myLocationRenderMode')) {
Expand Down
4 changes: 4 additions & 0 deletions mapbox_gl_web/lib/src/mapbox_map_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@ class MapboxMapController extends MapboxGlPlatform

@override
void setMyLocationTrackingMode(int myLocationTrackingMode) {
if(_geolocateControl==null){
//myLocationEnabled is false, ignore myLocationTrackingMode
return;
}
if (myLocationTrackingMode == 0) {
_addGeolocateControl(trackUserLocation: false);
} else {
Expand Down