Cesium利用坐标定位代码为
coordinates(param) { let that = this; viewer.entities.removeById("coordinates");//第二次定位的时候移除上次的点 let terrainProvider = viewer.scene.terrainProvider; let point = Cartographic.fromDegrees(param.longitude, param.latitude); var promise = sampleTerrain(terrainProvider, 13, [point]); when(promise, function (updatedPositions) {//获取当前地形高度 var terrainHeight = updatedPositions[0].height; viewer.entities.add({//创建定位点 id: "coordinates", name: "coordinates", position: Cartesian3.fromDegrees(param.longitude, param.latitude, terrainHeight), billboard: { image: "../MyJS/CesiumTools/img/coordinate.png",//定位的图片样式 }, }); viewer.camera.flyTo({//定位过去 destination: Cartesian3.fromDegrees(param.longitude, param.latitude, 1000) }); }); },
传入的坐标为: