2.7.6 • Published 2 years ago

vue-tianditu v2.7.6

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

vue-tianditu

安装

npm i vue-tianditu
# or
yarn add vue-tianditu

快速上手

全局引入

全部引入,解放双手

// main.ts
import { createApp } from "vue";
import App from "./App.vue";
import VueTianditu from "vue-tianditu";

const app = createApp(App);
app.use(VueTianditu, {
  v: "4.0", //目前只支持4.0版本
  tk: "your map token"
});
app.mount("#app");
<!-- App.vue -->
<template>
  <div class="mapDiv">
    <tdt-map :center="state.center" :zoom="state.zoom"></tdt-map>
  </div>
</template>

<script lang="ts" setup>
  import { reactive } from "vue";
  import { TdtMap } from "vue-tianditu";
  const state = reactive({
    center: [113.280637, 23.125178],
    zoom: 12
  });
</script>

<style>
  .mapDiv {
    width: 100%;
    height: 100%;
  }
</style>

按需引入

按需引入,配合 ts 获得类型提示

App.vue

<template>
  <div class="mapDiv">
    <tdt-map :center="state.center" :zoom="state.zoom" :loadConfig="loadScript"></tdt-map>
  </div>
</template>

<script lang="ts" setup>
  import { reactive } from "vue";
  import { TdtMap } from "vue-tianditu";
  const loadConfig = { v: "4.0", tk: "your map token" };
  const state = reactive({
    center: [113.280637, 23.125178],
    zoom: 12
  });
</script>

<style>
  .mapDiv {
    width: 100%;
    height: 100%;
  }
</style>

API 加载器

甚至可以把它当作无情的 API 加载工具

import { useApiLoader } from "vue-tianditu";

useApiLoader({
  v: "4.0",
  tk: "your map token",
  plugins: ["D3", "CarTrack", "HeatmapOverlay", "BufferTool", "ImageOverLayer"]
}).then(() => {
  new T.Map({...});
});

辅助函数

import { toLngLat, toBounds, toPoint, toIcon } from "vue-tianditu";

说明

函数名返回值描述
toLngLat(lnglat:number,number)T.LngLat转换为经纬度对象。参数说明:lnglat:经纬度数组
toBounds(bounds:[number,number,number,number])T.Bounds转换为地理范围对象。参数说明:bounds:地理范围数组
toPoint(point:number,number)T.Point转换为像素坐标点对象。参数说明:point:像素坐标点数组
toIcon(icon:IconOption|string)T.Icon转换为图标对象。参数说明:icon:string//图片地址{iconUrl:string,//图片地址iconSize:[number,number],//图片大小iconAnchor:[number,number]//偏移}
2.7.6

2 years ago

2.7.5

2 years ago

2.7.4

2 years ago

2.7.3

2 years ago

2.7.0

2 years ago

2.7.2

2 years ago

2.7.1

2 years ago

2.6.9

2 years ago

2.6.1

3 years ago

2.6.0

3 years ago

2.6.3

2 years ago

2.6.2

3 years ago

2.6.5

2 years ago

2.6.4

2 years ago

2.6.7

2 years ago

2.6.6

2 years ago

2.6.8

2 years ago

2.5.0

3 years ago

2.4.0

3 years ago

2.5.1

3 years ago

2.3.0

3 years ago

2.2.1

3 years ago

2.0.3

3 years ago

2.3.0-beta.1

3 years ago

2.2.0

3 years ago

2.1.1

3 years ago

2.0.2

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.3.0-beta.2

3 years ago

2.1.0

3 years ago

2.0.0-beta.1

3 years ago

2.0.0

3 years ago

1.2.11

3 years ago

1.2.8

3 years ago

1.2.9

3 years ago

1.2.10

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago