Home > DMT_EditorControl > zoomTo
DMT_EditorControl.zoomTo() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Zoom to coordinates
Signature
function zoomTo(
x?: number,
y?: number,
scaleRatio?: number,
tabId?: string,
): Promise<{ left: number; right: number; top: number; bottom: number } | false>;2
3
4
5
6
Parameters
Parameter | Type | Description |
|---|---|---|
x | number | (Optional) Center X coordinate. If not passed in, the current X coordinate will not be changed |
y | number | (Optional) Center Y coordinate. If not passed in, the current Y coordinate will not be changed |
scaleRatio | number | (Optional) Zoom ratio. If not passed in, the current zoom ratio will not be changed. The unit span is |
tabId | string | (Optional) Tab ID. If not passed in, the canvas with the last input focus will be used |
Returns
Promise<{ left: number; right: number; top: number; bottom: number } | false>
Region data after zooming. false indicates that the canvas does not support the zoom operation or the tabId does not exist
Remarks
In the schematic and symbol canvases, the coordinate unit span is 0.01inch; in the PCB and footprint canvases, it is mil
Example
// 1. 打开一个原理图页,确定缩放的画布
const pages = await eda.dmt_Schematic.getAllSchematicPagesInfo();
const tabId = await eda.dmt_EditorControl.openDocument(pages[0].uuid);
// 2. 视口中心移到 (100, 100),缩放比 200%(单位跨度 1/100)
const bounds = await eda.dmt_EditorControl.zoomTo(100, 100, 200, tabId);
console.log('bounds:', bounds);2
3
4
5
6
7