1. 数据形式
cesium开发过程中需要处理接口中的4326和3857坐标系相互转换的问题
4326为地理坐标系 3857为投影坐标系 数据格式如下:
[15748903.882937903, 4947191.502814008] ===》3857投影坐标系
[141.47481066172395, 40.556824419796385] ===》4326地理坐标系 即常说的经纬度
2.使用流程
①安装ol
npm install ol
②在项目中引入ol对应的模块
import { transform, useGeographic, Projection } from "ol/proj";
③转换方法调用
// 坐标系转换 4326为地理坐标系 3857为投影坐标系
wgs26(Cartesian3) {
let aa = transform(Cartesian3, "EPSG:3857", "EPSG:4326");
return aa;
},
wgs57(Cartesian3) {
let aa = transform(Cartesian3, "EPSG:4326", "EPSG:3857");
return aa;
},
④注意 方法中传入的数据为数组格式 参数如下
this.wgs26([15748903.882937903, 4947191.502814008])
this.wgs57([141.47481066172395, 40.556824419796385])