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

amap-drill

v0.0.2

Published

## 使用

Downloads

3

Readme

amap-drill

使用

yarn add amap-drill -S
// or
npm install amap-drill -S

首先引入 amap

<script src="https://webapi.amap.com/maps?v=1.4.15&key=yourkey&plugin=AMap.DistrictLayer"></script>

或者使用提供的获取 AMap 的工具函数

import { getAMap } from 'amap-drill'

async function init() {
  const AMap = await getAMap({ key: 'yourMapKey' })
  // 后续逻辑
}

注意

不支持 amap2.0

import { MapDrill, DisrtictLabel } from 'amap-drill'
const initDistrictLayer = new AMap.DistrictLayer.Country({
  zIndex: 10,
  SOC: 'CHN',
  depth: 1,
  styles: {
    fill: '#ffffff'
  }
})
const map = new AMap.Map('map', {
  zooms: [3, 18],
  showIndoorMap: false,
  center: [120, 30],
  zoom: 4,
  resizeEnable: true,
  layers: [initDistrictLayer]
})
const dirllOptions = {}
let mapDrill = new MapDrill(map, drillOptions)

显示行政区名称

new DisrtictLabel(mapDrill, {
  webApiKey: 'your_amap_web_api_key',
  // labelMarker配置,参考amap文档
  labelMarker: {
    text: {
      style: {
        fillColor: '#37C0F6'
      }
    }
  }
})

MapDrill

new MapDrill(map, dirllOptions)

  • map: Map 实例
  • dirllOptions: mapDirll 配置

配置

{
  webApiKey: 'your_amap_web_api_key',
  // 点击行政区外部返回上一层行政区
  clickOutsideToUp: true,
  drill: {
    province: {
      zoom: 7
    },
    country: {
      zoom: 4
    },
    city: {
      zoom: 8
    },
    district: {
      zoom: 10
    },
    street: {
      zoom: 12
    }
  }
}

MapDirll.drillTo

钻取行政区

MapDirll.drillTo(keywords)

  • keywords- 邮政编码或者行政区名称 api

MapDirll.updrill

向上一层行政区钻取

MapDirll.updrill()

MapDirll.drill

钻取行政区,这个方法是不需要通过查询行政区 api 的

MapDirll.drill(districtData)

  • districtData: DistrictLayer.getDistrictByContainerPos获取到的数据
{
  SOC: 'CHN',
  x: 120, // x,y将被设置为地图的中心点
  y: 30,
  level: 'country',
  adcode: '100000',
  NAME_CHN: '中华人民共和国'
}

DisrtictLabel

行政区名称显示

new DisrtictLabel(mapDrill, labelOptions)

  • mapDrill: MapDirll 实例
  • labelOptions
{
  webApiKey: 'your_amap_web_api_key',
  // labelMarker配置,参考amap文档
  labelMarker: {
    text: {
      style: {
        fillColor: '#37C0F6'
      }
    }
  }