Skip to content

Commit

Permalink
web: ignore myLocationTrackingMode if myLocationEnabled is false (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
m0nac0 authored Sep 8, 2020
1 parent ea199c7 commit 99b28ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
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

0 comments on commit 99b28ce

Please sign in to comment.