# vue-js-track-map

> 百度/高德地图API基于vue的鹰眼轨迹图

Latest version **1.0.23** (published 2021-11-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-js-track-map
pnpm add vue-js-track-map
yarn add vue-js-track-map
bun add vue-js-track-map
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.23 |
| Published | 2021-11-27 |
| First published | 2021-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 196.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | liuwenjing |
| Maintainers | biubiubiu- |
| Keywords | template, rollup, vue2, library, BaiDuMap |

## Links

- npm: https://www.npmjs.com/package/vue-js-track-map
- Repository: https://github.com/AlwaysLoveme/rollup-ts-vue3/tree/vue2
- Homepage: https://github.com/AlwaysLoveme/rollup-ts-vue3/tree/vue2#readme
- Issues: https://github.com/AlwaysLoveme/rollup-ts-vue3/issues
- npm.io page: https://npm.io/package/vue-js-track-map

## Dependencies (1)

- [@amap/amap-jsapi-loader](https://npm.io/package/@amap/amap-jsapi-loader.md) ^1.0.1

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.23 (latest) — 2021-11-27
- 1.0.22 — 2021-11-27
- 1.0.21 — 2021-11-26
- 1.0.20 — 2021-11-26
- 1.0.19 — 2021-11-26
- 1.0.18 — 2021-11-26
- 1.0.17 — 2021-11-09
- 1.0.16 — 2021-11-09
- 1.0.15 — 2021-11-09
- 1.0.14-2 — 2021-11-09
- 1.0.14-1 — 2021-11-09
- 1.0.14 — 2021-11-09
- 1.0.13 — 2021-11-09
- 1.0.12-1 — 2021-10-26
- 1.0.12 — 2021-10-26
- … 18 more at https://npm.io/package/vue-js-track-map/versions

## README

### 百度地图轨迹动画
仅支持Vue2.0版本，支持Typescript,不支持Vue3.0，

<a href="https://github.com/AlwaysLoveme/rollup-ts-vue3-template/blob/vue2/Gaode.md">点此进入高德地图版本轨迹动画文档</a>


#### 安装
```bash
npm install vue-js-track-map -S
```

#### 引入

```js
import Vue from "vue";
import { TrajectoryAnimation } from "vue-js-track-map";

// 全局组件
Vue.component(TrajectoryAnimation.name, TrajectoryAnimation);

// 局部组件
<template>
  <TrajectoryAnimation @ready="mapReady" ak="XXXXXXX" />
</template>
<script>
  export default {
    name: 'demo',
    components: {
      TrajectoryAnimation
    },
    methods: {
      mapReady(mapInstance, BMapGL, BMapGLLib) {
        console.log(mapInstance);
      }
    }
  }
</script>

```
#### 属性
<table>
  <theader>
    <tr>
      <th>名称</th>
      <th>释义</th>
      <th>类型</th>
      <th>取值</th>
      <th>默认值</th>
    </tr>
  </theader>
  <tbody>
    <tr>
      <td>ak</td>
      <td>百度地图服务密钥</td>
      <td>string</td>
      <td align="center">-</td>
      <td align="center">-</td>
    </tr>
    <tr>
      <td>https</td>
      <td>是否允许加载https文件</td>
      <td>boolean</td>
      <td align="center">true/false</td>
      <td align="center">true</td>
    </tr>
    <tr>
      <td>width</td>
      <td>地图宽度</td>
      <td align="center">string</td>
      <td align="center">-</td>
      <td align="center">800px</td>
    </tr>
    <tr>
      <td>height</td>
      <td>地图高度</td>
      <td align="center">string</td>
      <td align="center">-</td>
      <td align="center">400px</td>
    </tr>
    <tr>
      <td>path</td>
      <td>轨迹数组集合</td>
      <td align="center">Array</td>
      <td align="center">[ { lng: '', lat: '' } ]</td>
      <td align="center">[]</td>
    </tr>
    <tr>
      <td>trackOptions</td>
      <td>轨迹运行配置项</td>
      <td align="center">Object</td>
      <td align="center">
      详见：https://lbsyun.baidu.com/index.php?title=jspopularGL/guide/trackAnimation
      </td>
      <td align="center">[]</td>
    </tr>
    <tr>
      <td>strokeColor</td>
      <td>轨迹路线填充颜色</td>
      <td align="center">String</td>
      <td align="center">颜色值</td>
      <td align="center">#409eff</td>
    </tr>
    <tr>
      <td>icon</td>
      <td>图标路径</td>
      <td align="center">String</td>
      <td align="center">*.png/*.jpg/*.svg</td>
      <td align="center">-</td>
    </tr>
    <tr>
      <td>iconWidth</td>
      <td>图标宽度</td>
      <td align="center">Number</td>
      <td align="center">-</td>
      <td align="center">26</td>
    </tr>
    <tr>
      <td>iconHeight</td>
      <td>图标高度</td>
      <td align="center">Number</td>
      <td align="center">-</td>
      <td align="center">13</td>
    </tr>
    <tr>
      <td>iconLabel</td>
      <td>图标上方跟随的文本框信息</td>
      <td align="center">String</td>
      <td align="center">-</td>
      <td align="center">-</td>
    </tr>
    <tr>
      <td>iconSpeed</td>
      <td>图标跟随轨迹速度</td>
      <td align="center">Number</td>
      <td align="center">-</td>
      <td align="center">300</td>
    </tr>
    <tr>
      <td>centerZoom</td>
      <td>地图缩放级别</td>
      <td align="center">Number</td>
      <td align="center">-</td>
      <td align="center">17</td>
    </tr>
  </tbody>
</table>

#### 事件
<table>
  <theader>
    <tr>
      <th>名称</th>
      <th>释义</th>
      <th>类型</th>
      <th>参数</th>
    </tr>
  </theader>
  <tbody>
    <tr>
      <td>ready</td>
      <td>地图加载完成的回调函数</td>
      <td>void</td>
      <td align="left">
        function(Bmap, BMapGL, BMapGLLib)...
        <br />
        Bmap: 地图实例
        <br />
        BMapGL: window.BMapGL
        <br />
        BMapGLLib: window.BMapGLLib
      </td>
    </tr>
  </tbody>
</table>

#### 轨迹动画开始、暂停、继续; 显示/隐藏信息提示框
```js
<template>
  <div>
    <TrajectoryAnimation ref="map" iconLabel="提示框文本" @ready="mapReady" ak="XXXXXXX" />
    <div>
      <button @click="start">开始</button>
      <button @click="pause">暂停</button>
      <button @click="stop">停止</button>
      <button @click="showInfo">显示信息框</button>
      <button @click="hideInfo">隐藏信息框</button>
    </div>
  </div>
</template>
<script>
  import { TrajectoryAnimation } from "vue-js-track-map";
  export default {
    name: 'demo',
    components: {
      TrajectoryAnimation
    },
    methods: {
      mapReady(mapInstance, BMapGL, BMapGLLib) {
        console.log(mapInstance);
      },
      // 开始
      start() {
        this.$refs.bmap.startTrackAnimation();
      },
      // 暂停
      pause() {
        this.$refs.bmap.pauseTrackAnimation();
      },
      // 继续
      stop() {
        this.$refs.bmap.stopTrackAnimation();
      },
      showInfo(){
        this.$refs.bmap.showInfoWindow();
      },
      hideInfo(){
        this.$refs.bmap.hideInfoWindow();
      }
    }
  }
</script>
```

#### 已知问题
这个轨迹动画是结合`BMapGLLib`工具库中`TrackAnimation` 和 `Lushu`类实现，`TrackAnimation`本身做轨迹动画会有所卡顿，这个无法避免，所以可能会导致轨迹运行动画和图标动画不一致的情况，目前可通过设置`iconSpeed`和`trackOptions`中的`duration`和`delay`来调整。

#### 链接
BMapGLLib: [https://github.com/huiyan-fe/BMapGLLib](https://github.com/huiyan-fe/BMapGLLib)

百度地图`TrackAnimation`示例: [https://lbsyun.baidu.com/index.php?title=jspopularGL/guide/trackAnimation](https://lbsyun.baidu.com/index.php?title=jspopularGL/guide/trackAnimation)

百度地图`Lushu`示例: [https://bj.bcebos.com/v1/mapopen/github/BMapGLLib/Lushu/examples/index.html](https://bj.bcebos.com/v1/mapopen/github/BMapGLLib/Lushu/examples/index.html)

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