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 🙏

© 2026 – Pkg Stats / Ryan Hefner

aggregator-map-sdk

v1.0.0

Published

统一的地图JS API SDK,支持高德地图和百度地图

Readme

Map SDK

统一的地图JS API SDK,支持高德地图和百度地图,提供统一的接口和多种引入方式。

特性

  • 🗺️ 支持高德地图和百度地图
  • 🔄 统一的地图操作接口
  • 📍 地址解析和逆地址解析
  • 🚴 骑行路线规划
  • 🎯 丰富的覆盖物支持(标记点、折线、多边形、圆形、信息窗体)
  • 📦 支持多种引入方式:ES6模块、CommonJS、AMD、全局变量
  • 🚀 支持npm包安装
  • 📱 响应式设计,支持移动端

安装

NPM 安装

npm install map-sdk

直接引入

<!-- 引入构建后的文件 -->
<script src="dist/map-sdk.umd.js"></script>

使用方法

ES6 模块引入

import MapSDK from 'map-sdk';
// 或者
import { MapSDK, AmapMap, BmapMap } from 'map-sdk';

const mapSDK = new MapSDK();

CommonJS 引入

const MapSDK = require('map-sdk');
// 或者
const { MapSDK, AmapMap, BmapMap } = require('map-sdk');

const mapSDK = new MapSDK();

AMD 引入

require(['map-sdk'], function(MapSDK) {
  const mapSDK = new MapSDK();
});

全局变量引入

<script src="dist/map-sdk.umd.js"></script>
<script>
  const mapSDK = new MapSDK();
</script>

基础使用

初始化地图

const mapSDK = new MapSDK();

// 初始化高德地图
const amapConfig = {
  mapType: 'amap',
  amapKey: 'your_amap_key',
  container: 'map-container',
  center: [116.397428, 39.90923], // 北京天安门
  zoom: 12
};

try {
  const map = await mapSDK.initMap(amapConfig);
  console.log('地图初始化成功');
} catch (error) {
  console.error('地图初始化失败:', error);
}

切换地图类型

// 切换到百度地图
const bmapConfig = {
  mapType: 'bmap',
  bmapKey: 'your_bmap_key',
  container: 'map-container',
  center: [116.397428, 39.90923],
  zoom: 12
};

try {
  const map = await mapSDK.switchMap('bmap', bmapConfig);
  console.log('切换到百度地图成功');
} catch (error) {
  console.error('切换地图失败:', error);
}

构建

开发环境

npm install
npm run dev

生产构建

npm run build

清理构建文件

npm run clean

文件结构

map-sdk/
├── src/                    # 源码目录
│   ├── index.js          # 主入口文件
│   ├── map.js            # 主控制类
│   ├── amap.js           # 高德地图实现
│   └── bmap.js           # 百度地图实现
├── dist/                  # 构建输出目录
│   ├── map-sdk.js        # CommonJS 格式
│   ├── map-sdk.esm.js    # ES Module 格式
│   ├── map-sdk.umd.js    # UMD 格式(压缩)
│   ├── map-sdk.dev.js    # UMD 格式(未压缩)
│   └── index.d.ts        # TypeScript 类型定义
├── examples/              # 使用示例
├── package.json           # 包配置
├── rollup.config.js       # 构建配置
└── README.md             # 说明文档

许可证

MIT License