Openlayers custom 4490 coordinate system & load custom coordinate system layer

1. Visit http://epsg.io/
2. Find the coordinate system you want to customize, take 4490 coordinate system as an example:
Openlayers custom 4490 coordinate system & load custom coordinate system layer
Openlayers custom 4490 coordinate system & load custom coordinate system layer
click Proj4js, copy the code under JavaScript;
Openlayers custom 4490 coordinate system & load custom coordinate system layer
3. Visit https://www.bootcdn.cn/ proj4js/
4. What do you use proj4js, proj4js for? The official website says there is such a word "Proj4js is a JavaScript library for converting coordinates from one coordinate system to another coordinate system, including the base conversion",
Openlayers custom 4490 coordinate system & load custom coordinate system layer
as used herein, version 2.2.2, click on "Copy the script tag,"
Openlayers custom 4490 coordinate system & load custom coordinate system layer
which This method must be connected to the Internet to succeed, otherwise an error will be reported and the map will not be loaded! So when we are not connected to the Internet, we can use the locally imported proj4.js, and we did not find the download address on the Internet, so we thought of a way to visit https://cdn.bootcdn.net/ajax/libs/proj4js /2.2.2/proj4.js
will display the js code, press ctrl+a to select all and copy, then create a new proj4.js file and paste the js code, copy proj4.js into the project for reference, OK, perfect solution!
Openlayers custom 4490 coordinate system & load custom coordinate system layer
Openlayers custom 4490 coordinate system & load custom coordinate system layer

5. Introduce proj4.js in the js file;
Openlayers custom 4490 coordinate system & load custom coordinate system layer
get the custom coordinate system and create an instance;
Openlayers custom 4490 coordinate system & load custom coordinate system layer
add the proj4 conversion method to
Openlayers custom 4490 coordinate system & load custom coordinate system layer
load the custom coordinate system layer to
Openlayers custom 4490 coordinate system & load custom coordinate system layer
test the coordinate system conversion, check the console, if there is no error, then the conversion is successful !
Openlayers custom 4490 coordinate system & load custom coordinate system layer

Guess you like

Origin blog.51cto.com/13560480/2542995