# hjl-canvas-map

> `npm run serve`

Latest version **1.0.15** (published 2022-07-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install hjl-canvas-map
pnpm add hjl-canvas-map
yarn add hjl-canvas-map
bun add hjl-canvas-map
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.15 |
| Published | 2022-07-27 |
| First published | 2022-04-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 145.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | fengshui.master |

## Links

- npm: https://www.npmjs.com/package/hjl-canvas-map
- npm.io page: https://npm.io/package/hjl-canvas-map

## Recent versions

- 1.0.15 (latest) — 2022-07-27
- 1.0.14 — 2022-07-25
- 1.0.13 — 2022-06-22
- 1.0.12 — 2022-04-26
- 1.0.11 — 2022-04-19
- 1.0.10 — 2022-04-19
- 1.0.9 — 2022-04-19
- 1.0.8 — 2022-04-19
- 1.0.7 — 2022-04-19
- 1.0.6 — 2022-04-18
- 1.0.5 — 2022-04-15
- 1.0.4 — 2022-04-15
- 1.0.3 — 2022-04-15
- 1.0.1 — 2022-04-13

## README

# 该项目是为了封装一个canvas坐标系绘制方法.以方便地图类型项目的绘制.

### 测试界面启动

`npm run serve` 

### ts文件打包

`npm run build` 打包后位置为 dist

### 项目笔记

* 项目主要包括的类型有 `EasyMap`(地图)、`OverLay`(覆盖物)、`layer`(图层) 三种类型

* 项目中的为了保证坐标轴方向可控,编写了 `Context2DProxy` 对 `CanvasRenderingContext2D`对象进行了代理.

    > 其中新增了
    > * `canvasPointToMapPoint` canvas坐标转换成map坐标
    > * `mapPointToCanvasPoint` map坐标转换成canvas坐标
    > * `saveDraw` 保存绘制内容,绘制完成后还原上下文设置
    > * `saveMapDraw` 保存绘制内容,在地图坐标系中绘制.会之后还原上下文设置
    > * `clearCanvas` 清空绘制
    > * `translateCenter` 原点移动到canvas中心
    > * `axisRotate` 旋转坐标轴

    > 其中重构了
    > * 绘制中包含坐标和角度的方法(例如 `moveTo` `lineTo`等)
    > * `save` `restore` 方法会进行计数.编译回到最初状态

    > <b style="color:#ff0000">使用注意事项</b>
    > * 在以 `canvas坐标系` 内绘制时,应该使用原来的 `CanvasRenderingContext2D` 进行坐标处理,若使用 `Context2DProxy` 会绘制错误.一般会在 `saveDraw` 时绘制基于 `canvas坐标系`

* 项目中使用 `EventHandler`和 `MapEventTarget` 对事件进行分发处理.
    > 其中包含了 `PCEventHandler` 和 `MobileEventHandler` 两个处理器.<br>
    > 这两个处理器会处理 `canvas` 上的事件,并 `dispatchEvent` 到 `MapEventTarget` 中.<br>
    > 其中`EasyMap`、`OverLayer` 和 `Layer` 都继承了 `MapEventTarget`.<br> 
    > <b style="color:#ff0000">注意:</b> 现在只实现了`PCEventHandler`的部分操作.这个地方需要进行思考.如何更合理的处理事件分发.避免在每个`MapEventTarget`子类中都重写 `dispatchEvent` 方法

---
_Source: https://npm.io/package/hjl-canvas-map · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
