@sl-utils/map 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/demo/main.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createApp } from 'vue'
2
2
  import './style.css'
3
- import App from './App.vue'
3
+ import App from './plugin-draw.vue'
4
4
 
5
5
  createApp(App).mount('#app')
@@ -1,44 +1,44 @@
1
- <script setup lang="ts">
2
- import { SLUMap, MapPluginDraw } from "@sl-utils/map";
3
- import { ref, onMounted } from "vue";
4
-
5
- onMounted(() => {
6
- const map4 = new SLUMap("map", { type: "A" });
7
- setTimeout(() => {
8
- const draw = new MapPluginDraw(map4.map);
9
- draw.addRect({
10
- latlngs: [
11
- [26.3, 110.5],
12
- [27.3, 112.5],
13
- ],
14
- width: 500,
15
- height: 50,
16
- });
17
- draw.addArc({
18
- latlng: [22.5, 114.0],
19
- size: 100,
20
- });
21
- }, 1000);
22
- // const map1 = new MapCanvasDraw()
23
- // const map2 = new MapCanvasEvent()
24
- // const map3 = new MapCanvasLayer()
25
- // SLUCanvasText.drawText({},{})
26
- });
27
- </script>
28
-
29
-
30
- <template>
31
- <div id="map" class="card"></div>
32
- </template>
33
-
34
- <style scoped>
35
- .card {
36
- position: absolute;
37
- z-index: 100;
38
- width: 100%;
39
- height: 100%;
40
- left: 0px;
41
- top: 0px;
42
- overflow: hidden;
43
- }
44
- </style>
1
+ <script setup lang="ts">
2
+ import { SLUMap, MapPluginDraw } from "@sl-utils/map";
3
+ import { ref, onMounted } from "vue";
4
+
5
+ onMounted(() => {
6
+ const map4 = new SLUMap("map");
7
+ map4.init({ type: "A" }).then(()=>{
8
+ const draw = new MapPluginDraw(map4.map);
9
+ draw.addRect({
10
+ latlngs: [
11
+ [26.3, 110.5],
12
+ [27.3, 112.5],
13
+ ],
14
+ width: 500,
15
+ height: 50,
16
+ });
17
+ draw.addArc({
18
+ latlng: [22.5, 114.0],
19
+ size: 100,
20
+ });
21
+ })
22
+ // const map1 = new MapCanvasDraw()
23
+ // const map2 = new MapCanvasEvent()
24
+ // const map3 = new MapCanvasLayer()
25
+ // SLUCanvasText.drawText({},{})
26
+ });
27
+ </script>
28
+
29
+
30
+ <template>
31
+ <div id="map" class="card"></div>
32
+ </template>
33
+
34
+ <style scoped>
35
+ .card {
36
+ position: absolute;
37
+ z-index: 100;
38
+ width: 100%;
39
+ height: 100%;
40
+ left: 0px;
41
+ top: 0px;
42
+ overflow: hidden;
43
+ }
44
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sl-utils/map",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "",
5
5
  "main": "index.cjs",
6
6
  "module": "./src/sl-utils-map.ts",
@@ -4,16 +4,31 @@ import { SLEMap, SLULeafletNetMap } from '../leaflet';
4
4
  declare var AMap: any;
5
5
 
6
6
  export class SLUMap {
7
- constructor(ele: string)
8
7
  constructor(ele: string)
9
8
  constructor(ele: string, options: Partial<SLPMapOpt> = {}) {
10
- this.createMap(ele, options)
9
+ this.ele = ele;
10
+ }
11
+ private ele:string;
12
+ /**地图实例 */
13
+ private _map:L.Map | AMAP.Map;
14
+ public get map(){
15
+ return this._map
11
16
  }
12
-
13
- private map: L.Map | AMAP.Map;
14
17
  /**当前正在显示的网络图层 */
15
18
  private curs: Partial<{ [key in SLEMap]: SLULeafletNetMap | undefined }> = Object.create(null);
16
-
19
+ /**初始实例化地图
20
+ * @param options 地图初始化参数
21
+ */
22
+ public async init(options: Partial<SLPMapOpt> = {}){
23
+ const { type } = options,ele = this.ele;
24
+ let map: L.Map | AMAP.Map;
25
+ switch (type) {
26
+ case "A": this._map = await this.initAmap(ele, options); break;
27
+ default: this._map = await this.initLeaflet(ele, options);
28
+ this.showMap([SLEMap.tianDiTuNormalMap, SLEMap.tianDiTuNormalAnnotion]);
29
+ break;
30
+ }
31
+ }
17
32
  /**显示指定的网络图层 */
18
33
  public showMap(names: Array<SLEMap> = []): this {
19
34
  const { map, curs } = this;
@@ -40,16 +55,6 @@ export class SLUMap {
40
55
  }
41
56
  return this
42
57
  }
43
- private async createMap(ele: string, options: Partial<SLPMapOpt>) {
44
- const { type } = options;
45
- let map: L.Map | AMAP.Map;
46
- switch (type) {
47
- case "A": this.map = await this.initAmap(ele, options); break;
48
- default: this.map = await this.initLeaflet(ele, options);
49
- this.showMap([SLEMap.tianDiTuNormalMap, SLEMap.tianDiTuNormalAnnotion]);
50
- break;
51
- }
52
- }
53
58
  /**---------------leaflet地图的相关方法------------------- */
54
59
  private initLeaflet(ele: string, opt: Partial<SLPMapOpt>) {
55
60
  const { zoom = 11, minZoom = 2, maxZoom = 20, center: [lat, lng] = [22.68471, 114.12027], dragging = true, zoomControl = false, attributionControl = false, doubleClickZoom = false, closePopupOnClick = false } = opt;
@@ -1,8 +1,12 @@
1
1
  declare module '@sl-utils/map' {
2
2
  /**leaflet 需要开发者在样式表中挂载leaflet样式 */
3
3
  export class SLUMap {
4
- constructor(ele: string, options?: Partial<SLPMapOpt>);
4
+ constructor(ele: string,);
5
5
  map: AMAP.Map | L.Map
6
+ /**初始实例化地图
7
+ * @param options 地图初始化参数
8
+ */
9
+ public init(options?: Partial<SLPMapOpt>): Promise<void>
6
10
  }
7
11
  // 添加其他导出...
8
12
  export class MapCanvasDraw {
package/demo/app.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare module "UU" {
2
- export class UU { }
3
- }
package/demo/main.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vue_1 = require("vue");
4
- require("./style.css");
5
- const App_vue_1 = require("./App.vue");
6
- (0, vue_1.createApp)(App_vue_1.default).mount('#app');
7
- //# sourceMappingURL=main.js.map
package/demo/main.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":";;AAAA,6BAA+B;AAC/B,uBAAoB;AACpB,uCAA2B;AAE3B,IAAA,eAAS,EAAC,iBAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA"}