zoomToExtent
Adjust the camera view to focus on a specific geographic area by defining its bounding coordinates. Specify west, south, east, and north boundaries to view any region on the 3D globe.
Instructions
缩放到指定地理范围
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| west | Yes | 西边界经度(度) | |
| south | Yes | 南边界纬度(度) | |
| east | Yes | 东边界经度(度) | |
| north | Yes | 北边界纬度(度) | |
| duration | No | 动画时长(秒) |
Implementation Reference
- The core logic that executes the camera flyTo animation to the specified extent.
export function zoomToExtent(viewer: Cesium.Viewer, params: ZoomToExtentParams): Promise<void> { const { bbox, duration = 1.5 } = params const [west, south, east, north] = bbox return new Promise((resolve) => { viewer.camera.flyTo({ destination: Cesium.Rectangle.fromDegrees(west, south, east, north), duration, complete: resolve, }) }) } - packages/cesium-mcp-runtime/src/index.ts:433-447 (registration)The tool registration and schema definition for 'zoomToExtent' in the runtime.
_registerTool( 'zoomToExtent', '缩放到指定地理范围', { west: z.number().describe('西边界经度(度)'), south: z.number().describe('南边界纬度(度)'), east: z.number().describe('东边界经度(度)'), north: z.number().describe('北边界纬度(度)'), duration: z.number().optional().default(2).describe('动画时长(秒)'), }, async (params) => { const result = await sendToBrowser('zoomToExtent', { bbox: [params.west, params.south, params.east, params.north], duration: params.duration }) return { content: [{ type: 'text' as const, text: JSON.stringify(result ?? { success: true }) }] } }, ) - Bridge method that dispatches the zoomToExtent command to the Cesium viewer.
zoomToExtent(params: ZoomToExtentParams): Promise<void> { return zoomToExtent(this._viewer, params) }