Pick 拾取
演练场
引入
ts
import { Pick } from "@m-tech/gis-core";
const pickInstance = new Pick(viewer, options);入参
| 参数名称 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| viewer | Viewer | 是 | - | 容器 |
| options | Object | 否 | - | 配置 |
| options.showTipInfo | Boolean | 否 | true | 是否显示提示信息 |
| options.tipFormatter | string | Function | 否 | 经度: {lng}°\n纬度: {lat}°\n高度: {alt}m | 提示信息格式化 |
TIP
tipFormat 默认值为字符串模板形式,支持经度lng、纬度lat、高度alt三个插值符,\n 为换行符。
也可以传入一个回调函数,返回一个字符串:
ts
tipFormatter: (position: Position) => {
const { lng, lat, alt } = position;
return `
longitude: ${lng.toString().slice(-12)}°
\n
latitude: ${lat.toString().slice(-12)}°
\n
height: ${alt.toString().slice(-12)}m
`;
};方法
turnOn(isSingle, callback)
开启拾取。
入参
| 参数名称 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| isSingle | boolean | 否 | true | 是否单次拾取 |
| callback | Function | 否 | - | 回调函数 |
ts
pickInstance.turnOn(isSingle, (evt: Position) => {
const {
lng, // 经度
lat, // 纬度
alt, // 高度
} = evt;
console.log(lng, lat, alt);
});turnOff()
关闭拾取。
ts
pickInstance.turnOff();