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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@medmotion-open/test-delete

v1.1.2

Published

简化天地图web服务的使用,ts类型提示

Downloads

1

Readme

简化 天地图的 web 服务 API 的使用

esModule

[✅]浏览器

[✅]小程序

小程序 需要添加安全域名 https://api.tianditu.gov.cn

Node 版见 https://www.npmjs.com/package/@medmotion-open/tdt-node

支持的接口

[❌]地名搜索 V2.0 (开发中) 类型定义部分支持

[❌]公交规划 (开发中)

[✅]地理编码接口

[❌]逆地理编码查询 (开发中)

[❌]行政区划服务 (开发中)

[❌]驾车规划 (开发中)

[❌]静态地图 API (开发中)

[❌]地图 API (开发中)

[❌]网页 API (开发中)

用法

import T_MAP from '@medmotion-open/tdt';

try {
  const map = new T_MAP(key);

  const res = await map.gencode({
    keyWord: '北京市延庆区延庆镇莲花池村前街50夕阳红养老院',
  });
  console.log(res);

  // 或

  const res = map
    .gencode({
      keyWord: '北京市延庆区延庆镇莲花池村前街50夕阳红养老院',
    })
    .then((res) => {
      console.log(res);
    });
} catch (error) {
  console.error(error);
}

使用代理

[✅] proxy

如果你想用自己的代理地址

import T_MAP from '@medmotion-open/tdt';

import axios from 'axios'; // 也可以用别的

const map = new T_MAP(key, {
  proxy: 'http://api.tianditu.gov.cn', // 换成你自己的
});

使用自己的网络请求体

如果想嵌入自己项目,统一网络请求,可以使用 httpAdapter

这里示例为 axios,可以用自己的 GET 请求即可

但是返回结果需要自己处理

httpAdapter(url);

// 貌似官网的大多为 get 请求,所以这里返回了拼接好的 url

// 后续会考虑暴露为

const obj = {
  url: '',
  type: '',
  params: {},
};

使用如下

import T_MAP from '@medmotion-open/tdt';

import axios from 'axios'; // 也可以用别的

const map = new T_MAP(key, {
  httpAdapter: axios.get,
});

const res = await map.gencode({
  keyWord: '北京市延庆区延庆镇莲花池村前街50夕阳红养老院',
});

刚刚打算做个简化的使用

也是第一次尝试写个 ts 类型定义的插件包

可能比较慢,但可以自己引用 baseRequest 来使用

用法如下

如官方示例为 http://api.tianditu.gov.cn/geocoder?ds={"keyWord":"北京市延庆区延庆镇莲花池村前街50夕阳红养老院"}&tk=您的密钥

import T_MAP from '@medmotion-open/tdt';
const map = new T_MAP(key);
const ds = JSON.stringify({
  keyWord: '北京市延庆区延庆镇莲花池村前街50夕阳红养老院',
}); // 自己处理参数
map.baseRequest({
  url: 'geocoder',
  params: {
    ds,
  },
});

interface GenCodeReq {
  location: {
    /**
     * 检索时的keyWord
     */
    keyWord: string;
    /**
     * 坐标点显示经度
     */
    lon: string;
    /**
     * 坐标点显示纬度
     */
    lat: string;
    /**
     * 类别名称
     */
    level?: string;
    /**
     * 附近相似点  开启周边查询必需返回。
     */
    typeRound?: string;
  };
}

map.baseRequest<GenCodeReq>({
  url: 'geocoder',
  params: {
    ds,
  },
});