地图跳转
框架支持多种对象的定向跳转,包括跳转到对象、跳转到指定坐标、跳转到指定视角
支持说明
代码实例
创建场景
ts
let map: any
LarkExplorer.ready({
baseUrl: './dist/resources/',
}).then(()=>{
map = new LarkExplorer.Map('map')
})
跳转到对象
ts
// 加载数据对象
let obj: any
const geojson = async () => {
const url = 'http://localhost:8086/geojson/point.json'
obj = await map.Layers.Geojson.add(url, '1', 1)
}
// 跳转至对象
const flyToItem = () => map.Navigation.flyToItem(obj)
跳转到指定坐标
ts
// 跳转到指定坐标
const flyToDegree = () => {
const pos = { x: 119, y: 29, z: 5000 }
map.Navigation.flyToDegree(pos, 3, function () {
console.log('跳转至坐标完成')
})
}
跳转到指定视角
ts
// 跳转到指定视角(笛卡尔+弧度)
const flyToPos = () => {
const status = {
position: {
x: -2072151.6231208083,
y: 8120125.20405065,
z: 5940392.882414031,
},
hpr: {
heading: 1.7763568394002505e-15,
pitch: -1.5685994338656415,
roll: 0,
},
}
map.Navigation.flyToPos(status, 3)
}
// 跳转到指定视角(经纬度+度)
const flyToPos1 = () => {
const status = {
position: {
x: 118.68821467029362,
y: 41.03684292610083,
z: 89467.23321568606,
},
hpr: {
heading: 18,
pitch: -37,
roll: 0,
},
}
map.Navigation.flyToPos(status, 3, true, function () {
console.log('跳转完毕')
})
}
跳转到四至
ts
//跳转到四至
const flyToExtent = () => {
const extent = [
110.86500872959532, 38.02478603725613, 127.17812716067738,
47.56526430500362,
]
map.Navigation.flyToExtent(extent, 3, function () {
console.log('跳转完毕')
})
}
运行效果
更多示例