npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

wzlcoordconvert

v1.0.3

Published

经纬度坐标转换库:支持 WGS84、GCJ-02(高德/腾讯)、BD-09(百度)互转,支持批量与单点输入

Downloads

389

Readme

coord-convert

经纬度坐标转换库(WGS84 ⇄ GCJ-02 ⇄ BD-09),支持单点与批量输入,兼容 CommonJS 与 ESM。

特性

  • 支持 WGS84、GCJ-02(高德/腾讯)、BD-09(百度)互转
  • 支持单点(数组/对象/参数形式)与批量(数组/对象数组)
  • CommonJS 默认导出为主转换函数,内置转换函数挂载在该函数上,便于直接使用
  • 可在 Node 与浏览器中使用

安装

直接把仓库代码放入项目或通过 npm(如已发布):

npm install wzlcoordconvert

使用示例

ESM(package.json "type":"module" 或 .mjs)

import convert from 'wzlcoordconvert';

// 单点(传参形式)
const p1 = convert(116.397128, 39.916527, convert.wgs84ToGcj02);

// 单点(数组形式或对象形式)
const p2 = convert([116.397128, 39.916527], convert.wgs84ToGcj02);
const p3 = convert({ lng: 116.397128, lat: 39.916527 }, convert.wgs84ToGcj02);

// 批量
const arr = [[116.397128,39.916527],[121.473701,31.230416]];
const out = convert(arr, convert.wgs84ToBd09);
console.log(out);

CommonJS

const convert = require('wzlcoordconvert');

// 使用方式相同(convert 是函数,内置转换函数为属性)
const out = convert([[116.397128,39.916527]], convert.wgs84ToGcj02);
console.log(out);

API 概览

  • convert(points, converter) / convert(lng, lat, converter)
    • points 支持:[[lng,lat], ...]、[{lng,lat}, ...]、[lng,lat]、{lng,lat}
    • converter 为 (lng, lat) => [lng2, lat2] 或返回对象 {lng, lat}
  • 内置转换函数(都挂在 convert 上):
    • convert.wgs84ToGcj02(lng, lat)
    • convert.gcj02ToWgs84(lng, lat)
    • convert.gcj02ToBd09(lng, lat)
    • convert.bd09ToGcj02(lng, lat)
    • convert.wgs84ToBd09(lng, lat)
    • convert.bd09ToWgs84(lng, lat)

注意:gcj02ToWgs84 为迭代近似纠偏,精度满足地图显示与常规定位需求。