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

dindo-cloud-map

v1.0.1

Published

基于天地图的地图选择组件,支持地点搜索、位置标注、逆地理编码等功能

Readme

dindo-cloud-map

基于天地图的地图选择组件,支持地点搜索、位置标注、逆地理编码等功能。

安装

npm install dindo-cloud-map

依赖要求

本组件需要以下依赖:

  • Vue: ^2.6.0 或 ^3.0.0
  • Element UI (可选): 如果使用搜索功能,需要 Element UI 的 el-autocompleteel-input 组件

注意: Leaflet 已内置在包中,无需单独安装。

使用方法

全局注册

import Vue from 'vue';
import DindoMap from 'dindo-cloud-map';

Vue.use(DindoMap);

局部注册

<template>
  <div>
    <tianditu-map
      :visible="true"
      :initial-position="[116.37304, 39.92594]"
      :show-search="true"
      :tk="yourTiandituKey"
      @location-change="handleLocationChange"
      @address-change="handleAddressChange"
    />
  </div>
</template>

<script>
import { TiandituMap } from 'dindo-cloud-map';

export default {
  components: {
    TiandituMap,
  },
  data() {
    return {
      yourTiandituKey: 'your-tianditu-key',
    };
  },
  methods: {
    handleLocationChange(location) {
      console.log('位置变化:', location);
      // location: { lng, lat, address }
    },
    handleAddressChange(address) {
      console.log('地址变化:', address);
    },
  },
};
</script>

Props

| 参数 | 说明 | 类型 | 默认值 | |------|------|------|--------| | visible | 是否显示组件 | Boolean | true | | initialPosition | 初始经纬度 [lng, lat] | Array | [116.37304, 39.92594] | | showSearch | 是否显示搜索框 | Boolean | true | | readonly | 是否只读模式(纯标注展示,去除手动标注和搜索) | Boolean | false | | disabled | 是否禁用(禁用时不能点击标注) | Boolean | false | | height | 地图高度 | String | '400px' | | tk | 天地图密钥 | String | '37058149a9a118dab5ccbffe7b0ec7dd' | | addressValue | 地址输入框的值(用于双向绑定) | String | '' | | initGeocode | 是否初始化时进行逆地理编码和标记 | Boolean | false |

Events

| 事件名 | 说明 | 回调参数 | |--------|------|----------| | location-change | 位置变化时触发 | { lng, lat, address } | | address-change | 地址变化时触发 | address (String) |

Methods

通过 ref 调用组件方法:

<template>
  <tianditu-map ref="map" />
</template>

<script>
export default {
  methods: {
    getLocation() {
      // 获取当前选中的位置
      const location = this.$refs.map.getLocation();
      console.log(location); // { lng, lat, address }
    },
    setLocation(lng, lat) {
      // 设置位置
      this.$refs.map.setLocation(lng, lat);
    },
    moveToRegion(regionName) {
      // 根据区域名称移动地图
      this.$refs.map.moveToRegion('北京市');
    },
    // 逆地理编码(@address-change="handleAddressChange"监听回值)
    getAddress(){
       this.$refs.map.getAddress(lng, lat);
    }
  },
};
</script>

获取天地图密钥

  1. 访问 天地图开放平台
  2. 注册账号并创建应用
  3. 获取 API Key (tk)

注意事项

  1. 本组件使用天地图服务,需要有效的天地图密钥
  2. Leaflet 已内置在包中,无需单独安装或引入
  3. 搜索功能依赖 Element UI,如果项目中没有 Element UI,需要自行安装或修改搜索框实现
  4. 地图使用 GCJ-02 坐标系(火星坐标系)

License

MIT