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

dmhsq-tian-map

v1.0.1

Published

天地图 webapi

Readme

dmhsq-tian-map

简化天地图的 web api 的 使用

带 ts 类型提示

官方的地址文档为http://lbs.tianditu.gov.cn/server/guide.html

特性

  • 类型提示

feature

  • 微信小程序使用[❌] 可以使用 httpAdapter 来暂时用
  • 驾车规划[❌]
  • 静态地图[❌]
  • 地名搜索[❌]
  • 公交规划[✅]
  • 地理编码接口[✅]
  • 逆地理编码查询[✅]
  • 行政区划[✅]

安装

npm i dmhsq-tian-map

使用方法

基础使用

// 从模块中导入所需内容
import TianMap from 'dmhsq-tian-map';
const tianMap = new TianMap({
  key: '', // 官网申请
});

tianMap
  .administrative({
    keyword: 156110000,
    childLevel: 0,
    extensions: true,
  })
  .then((res) => {
    console.log('请求完成', res);
  })
  .catch((error) => {
    console.error('请求完成:', error);
  });

html 直接引入使用

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://unpkg.com/[email protected]"></script>
  </head>
  <body>
    <script>
      const tianMap = new TianMap({
        key: '',
      });

      tianMap
        .geocoder({
          keyWord: '北京市海淀区莲花池西路28号',
        })
        .then((res) => {
          console.log('地理编码请求完成', res);
        })
        .catch((error) => {
          console.error('地理编码请求出错:', error);
        });
    </script>
  </body>
</html>

配置选项

const monitor = new TianMap({
  key: string;
  baseUrl: string; // 可选baseUrl
  runEnv: 'web' | 'node'; // 可选 默认自动计算
  httpAdapter: <T>(url: string, options: TianMapOptions) => Promise<T>; // 可选 自己的请求发送体
});

httpAdapter 自定义请求体

// 从模块中导入所需内容
import TianMap from '../dist/index.esm.js';
import axios from 'axios';
const httpAdapter = async (url, opt) => {
  //... 其它操作
  const res = await axios.get(url);
  return res.data;
};
const tianMap = new TianMap({
  key: '',
  httpAdapter,
});

tianMap
  .geocoder({
    keyWord: '北京市海淀区莲花池西路28号',
  })
  .then((res) => {
    console.log('地理编码请求完成', res);
  })
  .catch((error) => {
    console.error('地理编码请求出错:', error);
  });
const result = {
  msg: 'ok',
  location: {
    score: 100,
    level: '门址',
    lon: '116.290158',
    lat: '39.894696',
    keyWord: '北京市海淀区莲花池西路28号',
  },
  searchVersion: '7.0.0V',
  status: '0',
};

版本说明

0.0.2

  • 搭建基础功能

1.0.3

  • 正式版本

1.0.5

  • 更正 umd 的使用

配置选项

| 选项 | 类型 | 默认值 | 说明 | | ----------- | ---------- | ------ | ---------------------------- | | key | string | - | 应用 tk(必填) | | baseUrl | string | - | 服务端数据接收地址(非必填) | | runEnv | 'node/web' | - | 运行环境 (非必填) | | httpAdapter | Function | - | 请求体 |

注意事项

  • lerna+pnpm 的 学习开发包的练习 demo