常用的坐标系定义方法
import proj4 from "proj4"; import {register} from "ol/proj/proj4"; import {Projection} from "ol/proj"; function definedProjection (_epsg) { let projection; switch (_epsg) { case 'EPSG:4528': proj4.defs("EPSG:4528", "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +ellps=GRS80 +units=m +no_defs"); register(proj4); projection = new Projection({ code: 'EPSG:4528', extent: [37520456.55526686, 1773540.5950746932, 43213597.20383039, 5379752.8534023315], units: 'm' }); break; case 'EPSG:4490': proj4.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs"); register(proj4); projection = new Projection({ code: 'EPSG:4490', extent: [-180, -90, 180, 90], units: 'degree' }); break; case 'EPSG:4326': proj4.defs("EPSG:4326", "+proj=longlat +datum=WGS84 +no_defs"); register(proj4); projection = new Projection({ code: 'EPSG:4326', extent: [-180, -90, 180, 90], units: 'degree' }); break; case 'EPSG:3857': proj4.defs("EPSG:3857", "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"); register(proj4); projection = new Projection({ code: 'EPSG:3857', extent: [-20026376.39 - 20048966.10, 20026376.39, 20048966.10], units: 'm' }); break; } return projection; }