Custom Coordinate System in OpenLayers 6
11/9/21Less than 1 minute
Custom Coordinate System in OpenLayers 6
1. Determine the Definition of the Coordinate System
Visit http://epsg.io to find the coordinate system:

Select the proj4.js method to import

Copy the code
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"
);2. Import proj4.js
Online import address (for reference): https://cdn.jsdelivr.net/npm/proj4@2.7.5/dist/proj4.js
3. Coordinate System Transformation
import { fromLonLat, transform } from "ol/proj";
import { register } from "ol/proj/proj4";
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);4. Test Coordinate System Transformation
ol.proj.transform([118, 32], "EPSG:4326", "EPSG:4528"); // If this test succeeds, it means the definition is successful.Reference article: https://www.jianshu.com/p/9eca1bc8a12d
AI Translation | AI 翻译
This article was translated from Chinese to English by AI. If there are any inaccuracies, please refer to the original Chinese version.
本文由 AI 辅助从中文翻译为英文。如遇不准确之处,请以中文原版为准。
