Skip to content

Commit 242fe63

Browse files
fix(tracking user): tracking the user was not implemented on iOS
Added implementation to track the user with different heading modes (`UserLocationCameraMode`).
1 parent f339929 commit 242fe63

File tree

1 file changed

+16
-30
lines changed

1 file changed

+16
-30
lines changed

src/ui-mapbox/index.ios.ts

+16-30
Original file line numberDiff line numberDiff line change
@@ -581,21 +581,6 @@ const _getMapStyle = (input: any): NSURL => {
581581
}
582582
};
583583

584-
function _getTrackingMode(input: UserLocationCameraMode): MGLUserTrackingMode {
585-
/*
586-
if (input === "FOLLOW") {
587-
return MGLUserTrackingMode.Follow;
588-
} else if (input === "FOLLOW_WITH_HEADING") {
589-
return MGLUserTrackingMode.FollowWithHeading;
590-
} else if (input === "FOLLOW_WITH_COURSE") {
591-
return MGLUserTrackingMode.FollowWithCourse;
592-
} else {
593-
return MGLUserTrackingMode.None;
594-
}
595-
*/
596-
return MGLUserTrackingMode.None;
597-
}
598-
599584
function _getLocation(loc: MGLUserLocation) {
600585
if (loc === null) {
601586
return null;
@@ -1775,35 +1760,36 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
17751760
* @todo come up with a reasonable set of cross platform defaults.
17761761
*/
17771762
_stringToCameraMode(mode: UserLocationCameraMode): any {
1778-
switch (mode) {
1779-
case 'NONE':
1763+
switch(mode) {
1764+
case "NONE":
17801765
return MGLUserTrackingMode.None;
17811766

1782-
case 'NONE_COMPASS':
1783-
if (Trace.isEnabled()) {
1784-
CLog(CLogTypes.info, '_stringToCameraMode(): NONE_COMPASS unsupported on iOS');
1785-
}
1767+
case "NONE_COMPASS":
1768+
console.log("MapboxView::_stringToCameraMode(): NONE_COMPASS unsupported on iOS");
17861769
return MGLUserTrackingMode.None;
17871770

1788-
case 'NONE_GPS':
1789-
if (Trace.isEnabled()) {
1790-
CLog(CLogTypes.info, '_stringToCameraMode(): NONE_GPS unsupported on iOS');
1791-
}
1771+
case "NONE_GPS":
1772+
console.log("MapboxView::_stringToCameraMode(): NONE_GPS unsupported on iOS");
17921773
return MGLUserTrackingMode.None;
17931774

1794-
case 'TRACKING':
1775+
case "TRACKING":
17951776
return MGLUserTrackingMode.Follow;
17961777

1797-
case 'TRACKING_COMPASS':
1778+
case "TRACKING_COMPASS":
17981779
return MGLUserTrackingMode.FollowWithHeading;
17991780

1800-
case 'TRACKING_GPS':
1781+
case "TRACKING_GPS":
18011782
// a reasonable approximation.
18021783
return MGLUserTrackingMode.Follow;
18031784

1804-
case 'TRACKING_GPS_NORTH':
1785+
case "TRACKING_GPS_NORTH":
18051786
return MGLUserTrackingMode.FollowWithCourse;
1787+
1788+
default:
1789+
console.log(`_stringToCameraMode: invalid cameraMode: ${mode}`);
18061790
}
1791+
1792+
return MGLUserTrackingMode.None;
18071793
}
18081794

18091795
_stringToRenderMode(mode): any {
@@ -3095,7 +3081,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
30953081
return;
30963082
}
30973083

3098-
theMap.setUserTrackingModeAnimated(_getTrackingMode(options.cameraMode), options.animated !== false);
3084+
theMap.setUserTrackingModeAnimated(this._stringToCameraMode(options.cameraMode), options.animated !== false);
30993085

31003086
resolve();
31013087
} catch (ex) {

0 commit comments

Comments
 (0)