ry-vue-map 0.3.3 → 0.3.4

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ry-vue-map",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "private": false,
5
5
  "main": "lib/ryui.umd.min.js",
6
6
  "description": "ry公共组件库",
@@ -10,9 +10,8 @@
10
10
  :isShowDrawTool="isShowDrawTool" :isRight="isRight" :isCrossHair="isCrossHair" :hideAdd="hideAdd"
11
11
  :hidePoint="hidePoint" :hideCancel="hideCancel" :hideDelete="hideDelete" :hideSave="hideSave"
12
12
  :hideLine="hideLine" :hideArea="hideArea" :isSwitchMap="isSwitchMap" :isSwitchMapRight="isSwitchMapRight"
13
- :isHideAreaAndKM="isHideAreaAndKM"
14
- @loadDrawPolygonEvent="loadDrawPolygonEvent($event)" @success="drawSuccess($event)"
15
- @error="drawError($event)">
13
+ :isHideAreaAndKM="isHideAreaAndKM" @loadDrawPolygonEvent="loadDrawPolygonEvent($event)"
14
+ @success="drawSuccess($event)" @error="drawError($event)">
16
15
  <template>
17
16
  <slot name="maptool"></slot>
18
17
  </template>
@@ -22,12 +21,12 @@
22
21
  <slot name="polygon" :mapDto="{map,lMap}">
23
22
 
24
23
  </slot>
25
-
24
+
26
25
  <slot name="marker" :mapDto="{map,lMap}">
27
-
26
+
28
27
  </slot>
29
28
  </template>
30
-
29
+
31
30
  </div>
32
31
 
33
32
 
@@ -40,9 +39,9 @@
40
39
  import MapToolDto from './../../models/ryMapTool/mapTool.js';
41
40
  import RyMapTool from '../../ryMapTool/src/index';
42
41
  import ImageLayer from 'ol/layer/Image';
43
- import ImageStatic from 'ol/source/ImageStatic';
42
+ import ImageStatic from 'ol/source/ImageStatic';
44
43
  import View from 'ol/View';
45
- import Projection from 'ol/proj/Projection';
44
+ import Projection from 'ol/proj/Projection';
46
45
 
47
46
  import {
48
47
  fitNew,
@@ -58,8 +57,7 @@
58
57
  ...new ViewDto(),
59
58
  ...new MapToolDto()
60
59
  },
61
- created() {
62
- },
60
+ created() {},
63
61
  watch: {
64
62
  center(newValue) {
65
63
  this.setCenter(newValue);
@@ -82,6 +80,13 @@
82
80
  this._bingMapEvent();
83
81
  }
84
82
  },
83
+ url(val){
84
+ if(this.map){
85
+
86
+ this.selectLayer();
87
+ this.setCenter();
88
+ }
89
+ }
85
90
  },
86
91
  data() {
87
92
  return {
@@ -92,50 +97,51 @@
92
97
  moveend: null,
93
98
  lastX: 0,
94
99
  lastY: 0,
100
+ layer: null,
95
101
  };
96
102
  },
97
103
  methods: {
98
-
99
- getImageLayer() {
100
- return new ImageLayer({
101
- source: new ImageStatic({
102
- crossOrigin: 'anonymous',
103
- imageSize: this.imageSize,
104
- imageExtent: this.imageExtent,
105
- // url: require('@/assets/jsmap.png')
106
- url:this.url
107
- })
108
- });
109
- },
110
- getProjection() {
111
- return new Projection({
112
- code: 3875,
113
- extent: this.imageExtent,
114
- units: 'm'
115
- });
116
- },
117
- getView() {
118
- return new View({
119
- projection: 'EPSG:3857',
120
- center: this.center,
121
- Projection: this.getProjection(),
122
- zoom: this.zoom,
123
- minZoom: this.minZoom,
124
- maxZoom: this.maxZoom
125
- });
126
- },
127
-
128
- async loadMap(el) {
129
- const map = await this.lMap.initStaticMap(el,{
130
- view:this.getView(),
131
- layer:this.getImageLayer(),
132
- });
133
- this.map=map;
134
- this.$emit('load', {
135
- map,
136
- mapServices: this.lMap,
137
- ryMapTool: this.$refs.mapTool
138
- });
104
+ getImageLayer() {
105
+ return new ImageLayer({
106
+ source: new ImageStatic({
107
+ crossOrigin: 'anonymous',
108
+ imageSize: this.imageSize,
109
+ imageExtent: this.imageExtent,
110
+ // url: require('@/assets/jsmap.png')
111
+ url: this.url
112
+ })
113
+ });
114
+ },
115
+ getProjection() {
116
+ return new Projection({
117
+ code: 3875,
118
+ extent: this.imageExtent,
119
+ units: 'm'
120
+ });
121
+ },
122
+ getView() {
123
+ return new View({
124
+ projection: 'EPSG:3857',
125
+ center: this.center,
126
+ Projection: this.getProjection(),
127
+ zoom: this.zoom,
128
+ minZoom: this.minZoom,
129
+ maxZoom: this.maxZoom
130
+ });
131
+ },
132
+
133
+ async loadMap(el) {
134
+ this.layer=this.getImageLayer();
135
+ const map = await this.lMap.initStaticMap(el, {
136
+ view: this.getView(),
137
+ layer: this.layer,
138
+ });
139
+ this.map = map;
140
+ this.$emit('load', {
141
+ map,
142
+ mapServices: this.lMap,
143
+ ryMapTool: this.$refs.mapTool
144
+ });
139
145
  },
140
146
  _bingMapEvent() {
141
147
  if (this.bindMapClick) {
@@ -194,6 +200,19 @@
194
200
  this.map.on('click', this.mapClick);
195
201
  }
196
202
  },
203
+ removeLayer(){
204
+ if(this.map && this.layer){
205
+ this.map.removeLayer(this.layer);
206
+ }
207
+ },
208
+ selectLayer(){
209
+ this.removeLayer();
210
+ if(this.map){
211
+ this.layer = this.getImageLayer();
212
+ this.map.addLayer(this.layer);
213
+ this.$emit('selectMapEvent');
214
+ }
215
+ },
197
216
  loadDrawPolygonEvent(e) {
198
217
  this.$emit('loadDrawPolygonEvent', e);
199
218
  }
@@ -230,4 +249,4 @@
230
249
  .move-box {
231
250
  position: absolute;
232
251
  }
233
- </style>
252
+ </style>