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

gaode-tools

v0.0.7-beta6

Published

高德工具 多边型编辑器测距工具等

Downloads

22

Readme

高德未支持工具封装

安装

npm install gaode-tools

使用

import gaodeTools from 'gaode-tools';

const polygonRangingIns = new gaodeTools.PolygonRanging(map);

// 或者
import { PolygonRanging } from 'gaode-tools';

const polygonRangingIns = new PolygonRanging(map);

本地运行

git clone https://github.com/MeetTheBest/gaode-tools.git

cd gaode-tools

npm install

npm run dev

通用 API

| 参数 | 说明 | 类型 | | ----- | ----- | ---- | | start | 启用相应能力 | instance.start(arg?) | | stop | 停止相应能力 | instance.stop() | | destroy | 销毁相应能力 | instance.destroy() |

多边形类工具

多边形测距 PolygonRanging

示例

import { PolygonRanging } from 'gaode-tools';

const map = new AMap.Map('container');
const polygonRangingIns = new PolygonRanging(map);

const polygon = new AMap.Polygon({});

// 开启测距
polygonRangingIns.start(polygon);

// 适当时机销毁测距(如组件的 destroy 生命周期)
polygonRangingIns.destroy();

多边形测距

多边形绘制时测距 PolygonRangingInDrawing

示例

import { PolygonRangingInDrawing } from 'gaode-tools';

const map = new AMap.Map('container');
const polygonRangingIns = new PolygonRangingInDrawing(map);

const mouseTool = new AMap.MouseTool({});

mouseTool.on('draw', () => {
    // 绘制完成后,需要停止
    polygonRangingIns.stop();
});

// 开始绘制多边形
mouseTool.polygon();

// 开启测距
polygonRangingIns.start();

// 适当时机销毁测距(如组件的 destroy 生命周期)
polygonRangingIns.destroy();

多边形绘制时测距

多边形编辑器测距 PolygonEditorRanging

示例

import { PolygonEditorRanging } from 'gaode-tools';

const map = new AMap.Map('container');

const polygon = new AMap.Polygon({});

const editor = new AMap.PolygonEditor(map, polygon);

const polygonEditorRangingIns = new PolygonEditorRanging(map);

// 开启测距
polygonEditorRangingIns.start(editor);

// 适当时机停止测距
polygonEditorRangingIns.stop();

// 适当时机销毁测距(如组件的 destroy 生命周期)
polygonEditorRangingIns.destroy();

多边形编辑器测距

PolygonEditorEvent 多边形编辑器操作点事件

为什么要做这个?因为高德的 PolygonEditoradjust 事件,只支持在操作点位结束后响应,并且响应的内容是当前编辑的多边形。

示例

import { PolygonEditorEvent } from 'gaode-tools';

const map = new AMap.Map('container');

const polygon = new AMap.Polygon({});

const editor = new AMap.PolygonEditor(map, polygon);
editor.open();

const polygonEditorEventIns = new PolygonEditorEvent(editor);

polygonEditorEventIns.on('mousedown', (target) => {
    console.log('当前鼠标按下点位', target);
});

polygonEditorEventIns.on('mousemove', (target) => {
    console.log('当前移动点位', target);
});

polygonEditorEventIns.on('mouseup', (target) => {
    console.log('当前鼠标松开点位', target);
});

// 适当时机销毁测距(如组件的 destroy 生命周期)
polygonEditorEventIns.clearAll();

多边形编辑器事件

API

| 参数 | 说明 | 类型 | | ----- | ----- | ---- | | on | 监听指定事件 | on(eventName: mousedown \| mousemove \| mouseup, callback: (target: AMap.CircleMarker) => void) | | off | 移除指定事件 | off(eventName: mousedown \| mousemove \| mouseup, callback: (target: AMap.CircleMarker) => void) | | once | 监听指定事件行为,触发一次后自动移除 | once(eventName: mousedown \| mousemove \| mouseup, callback: (target: AMap.CircleMarker) => void) | | clearAll | 移除指定事件监听,eventName 不传则移除全部 | clearAll(eventName?: mousedown \| mousemove \| mouseup) |