Mars Coordinate System: A Comprehensive Guide to China's Mapping Coordinates
China's map coordinate systems can be somewhat complex. Different map service providers use different coordinate standards, posing some challenges for developers. In this blog, we will delve into China's coordinate standards, explain the standards used by each mainstream map service, and introduce how to effortlessly convert coordinates using the mars-coord library.
Complexity of China's Coordinate Standards
The complexity of China's coordinate systems primarily stems from different map service providers using different coordinate standards. For example, Baidu Maps uses the BD-09 standard, while Amap and Tencent Maps use the GCJ-02 standard. The international standard WGS84 has some offsets within mainland China.
mars-coord: A One-Stop Coordinate Conversion Library
mars-coord is a library for converting Mars coordinate systems, written by me. Using this library, you can effortlessly transition between various coordinate standards.
Below is an overview table of the main coordinate standards and type keys in China:
Type Key | Coordinate Standard | Applicable Map Services |
---|---|---|
WGS84 | WGS84 | International Standard |
GCJ02 | GCJ-02 | Amap, Tencent Maps, Apple Maps(China), Google Maps(China) |
AMAP | GCJ-02 | Amap |
GCJ-02 | Tencent Maps | |
BD09 | BD-09 | Baidu Maps |
BAIDU | BD-09 | Baidu Maps |
CGCS2000 | CGCS2000 | China Geodetic |
Installation is quite simple:
npm install mars-coord
Conversion example code:
import { Coordinate, convertCoordinate } from 'mars-coord';
const myCoordinate: Coordinate = [110.030774, 36.815854];
const result = convertCoordinate(myCoordinate, 'WGS84');
Conclusion
The Mars coordinate system is a complex yet vital subject in Chinese map development. The mars-coord
library aims to simplify the process of coordinate conversion, helping developers focus on building excellent map applications.
Whether you are a map application developer or an enthusiast interested in coordinate studies, the mars-coord
library is worth a try.