地图坐标的转换

需要引入的类为

import {transform, transformExtent, fromLonLat} from "ol/proj";

view中进行坐标的转换

var view = new View({
        projection: "EPSG:3857", //使用这个坐标系
        center: transform([0,0], "EPSG:4326", "EPSG:3857"),
        zoom: 13,
      });

 

//墨卡托坐标系(3857),转换为WGS-84坐标系(4326)经纬度
 var extentInWgs84 = transformExtent(extent, "EPSG:3857", "EPSG:4326");

 

posted on 2021-08-26 10:31  一往无前!  阅读(167)  评论(0编辑  收藏  举报