Skip to content

Commit

Permalink
fix camera with stops and add type defination
Browse files Browse the repository at this point in the history
  • Loading branch information
r0b0t3d authored and mfazekas committed Apr 7, 2020
1 parent 25092df commit e443e71
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
18 changes: 18 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,23 @@ export interface CameraProps extends CameraSettings, ViewProps {
) => void;
}

export interface CameraStopSettings {
centerCoordinate?: GeoJSON.Position;
heading?: number;
pitch?: number;
bounds?: {
ne: GeoJSON.Position;
sw: GeoJSON.Position;
paddingLeft?: number;
paddingRight?: number;
paddingTop?: number;
paddingBottom?: number;
};
zoomLevel?: number;
animationDuration?: number;
animationMode?: 'flyTo' | 'easeTo' | 'moveTo';
}

export interface CameraSettings {
centerCoordinate?: GeoJSON.Position;
heading?: number;
Expand All @@ -427,6 +444,7 @@ export interface CameraSettings {
};
zoomLevel?: number;
animationDuration?: number;
stops?: CameraStopSettings[];
}

export interface UserLocationProps {
Expand Down
10 changes: 8 additions & 2 deletions ios/RCTMGL/RCTMGLCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ - (void)_updateCameraFromJavascript
if (_map != nil && _map.userTrackingMode != MGLUserTrackingModeNone) {
_map.userTrackingMode = MGLUserTrackingModeNone;
}

[cameraUpdateQueue enqueue:[CameraStop fromDictionary:_stop]];
if (_stop[@"stops"]) {
NSArray* stops = _stop[@"stops"];
for (NSDictionary* stop in stops) {
[cameraUpdateQueue enqueue:[CameraStop fromDictionary:stop]];
}
} else {
[cameraUpdateQueue enqueue:[CameraStop fromDictionary:_stop]];
}
[cameraUpdateQueue execute:_map];
}

Expand Down

0 comments on commit e443e71

Please sign in to comment.