Map Coordinate Transform
usage
npm install map-coord-trans
ts
import * as mapCoordTrans from 'map-coord-trans';
// or use require
// const mapCoordTrans = require('map-coord-trans');
// between Baidu and gcj02 (which amap is)
const bdQingchuan = mapCoordTrans.gcj2bd09(114.2866416361414, 30.55516459946725);
const gcjQingchuan = mapCoordTrans.bd092gcj(114.2931983642802, 30.560897954950846);
console.log(bdQingchuan);
console.log(gcjQingchuan);
/* return: [lng, lat]
[ 114.29310372441911, 30.561382675557066 ]
[ 114.28673625949108, 30.55467992590629 ]
*/
// other APIs
const wgs2bd = mapCoordTrans.wgs2bd09(114.28, 30.56);
const wgs2gcj = mapCoordTrans.wgs2gcj(114.28, 30.56);
const bd2wgs = mapCoordTrans.bd092wgs(114.297267, 30.569653);
const gcj2wgs = mapCoordTrans.gcj2wgs(114.29063, 30.563695);
js
const mapCoordTrans = require('map-coord-trans');
const bdQingchuan = mapCoordTrans.gcj2bd09(114.2866416361414, 30.55516459946725);
const gcjQingchuan = mapCoordTrans.bd092gcj(114.2931983642802, 30.560897954950846);
console.log(bdQingchuan);
console.log(gcjQingchuan);