Skip to main content
Glama

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
NameRequiredDescriptionDefault
westYes西边界经度(度)
southYes南边界纬度(度)
eastYes东边界经度(度)
northYes北边界纬度(度)
durationNo动画时长(秒)

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,
        })
      })
    }
  • 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)
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gaopengbin/cesium-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server