gi-nx / setMapCamera
function setMapCamera(camera?: Partial<MapCamera>): MapCameraView;Move the map, and take back where it landed. Every field is optional; what is left out holds its current value.
mode is the pair setTopView takes: '2D' is top-down with no perspective and pins pitch at 0, '3D' lets pitch bite. Asking for a pitch implies '3D', and the move out of '2D' carries the camera you asked for rather than snapping to the host's default. Nothing here throws over mode, and the returned view reports where the map actually ended up, clamped to its own scale limits.
The move lands on the calling frame, so a caller drawing from the returned view paints the same camera the map does, in the same frame. Exempt from call throttling, so it is safe to drive every frame.
Parameters
| Parameter | Type | Description |
|---|---|---|
camera | Partial<MapCamera> | Any subset of MapCamera. |
Returns
The map's view with the move applied.
Throws
If center is not a finite [lng, lat] pair with |lat| <= 90, or metresPerPixel is not a finite positive number.
Example
const view = await rpc.invoke('setMapCamera', [{ center: [lng, lat], metresPerPixel: 0.5 }]);