ry-vue-map 0.2.2 → 0.2.3

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.2.2",
3
+ "version": "0.2.3",
4
4
  "private": false,
5
5
  "main": "lib/ryui.umd.min.js",
6
6
  "description": "ry公共组件库",
@@ -32,6 +32,10 @@
32
32
  "@form-create/element-ui": "^2.5.20",
33
33
  "@turf/helpers": "^6.5.0",
34
34
  "@turf/line-intersect": "^6.5.0",
35
+ "@vue-office/docx": "^0.2.4",
36
+ "@vue-office/excel": "^0.2.4",
37
+ "@vue-office/pdf": "^0.2.4",
38
+ "@vue/composition-api": "^1.7.1",
35
39
  "axios": "~0.21.1",
36
40
  "core-js": "~3.15.2",
37
41
  "countup.js": "~2.0.7",
@@ -39,8 +43,9 @@
39
43
  "element-ui": "~2.15.6",
40
44
  "nprogress": "~0.2.0",
41
45
  "ol": "^6.14.1",
42
- "ry-map": "^0.3.3",
46
+ "ry-map": "^0.3.8",
43
47
  "vue": "~2.6.14",
48
+ "vue-demi": "^0.13.11",
44
49
  "vue-router": "~3.5.2",
45
50
  "vue-server-renderer": "^2.6.14",
46
51
  "vuedraggable": "~2.24.3",
@@ -53,7 +58,6 @@
53
58
  "@vue/cli-plugin-router": "~4.4.6",
54
59
  "@vue/cli-plugin-vuex": "~4.4.6",
55
60
  "@vue/cli-service": "~4.4.6",
56
- "@vue/composition-api": "~1.2.2",
57
61
  "babel-eslint": "~10.1.0",
58
62
  "compression-webpack-plugin": "~6.1.1",
59
63
  "eslint": "~6.8.0",
Binary file
@@ -9,10 +9,11 @@ import RyClustersMarker from './maps/ryClustersMarker';
9
9
  import RyPolygonGeo from './maps/ryPolygonGeo';
10
10
  import RyVectorMap from './maps/ryVectorMap';
11
11
  import RyLines from './maps/ryLines';
12
+ import RyStaticMap from './maps/ryStaticMap/index';
12
13
  // import "./fonts/iconfont.css";
13
14
 
14
15
  // 组件列表
15
- const components = [ RyMap,RyCrossHair,RyMapTool, RyPolygon,RyPolygons,RyClusters, RyPolygonGeo, RyClustersMarker,RyVectorMap,RyLines];
16
+ const components = [RyMap,RyCrossHair,RyMapTool, RyPolygon,RyPolygons,RyClusters, RyPolygonGeo, RyClustersMarker,RyVectorMap,RyLines,RyStaticMap];
16
17
 
17
18
  // 定义install
18
19
  const install = (Vue, options) => {
@@ -1,5 +1,12 @@
1
1
  export default class MapToolDto {
2
2
 
3
+
4
+ //是否显示地图中的
5
+ isHideAreaAndKM = {
6
+ type:Boolean,
7
+ default:false,
8
+ };
9
+
3
10
  //切换地图控件top值
4
11
  switchMapPosTop = {
5
12
  type:Number,
@@ -0,0 +1,36 @@
1
+ export default class MapDto {
2
+ constructor() {
3
+
4
+
5
+ this.isSwitchMapTool = {
6
+ type: Boolean,
7
+ default: true,
8
+ };
9
+
10
+ this.isRyMapTool = {
11
+ type: Boolean,
12
+ default: false,
13
+ };
14
+
15
+ this.isRight = {
16
+ type: Boolean,
17
+ default: false,
18
+ };
19
+
20
+ this.bindMapClick = {
21
+ type: Boolean,
22
+ default: false,
23
+ }
24
+
25
+
26
+ // 初始化编辑多边形
27
+ this.initModifyPolygon = {
28
+ type: [String, Object],
29
+ default: () => null,
30
+ };
31
+
32
+
33
+ }
34
+
35
+
36
+ }
@@ -0,0 +1,66 @@
1
+ const viewOptions = {
2
+ projection: 'EPSG:4326',
3
+ center: [116.40769, 39.89945],
4
+ zoom: 18
5
+ }
6
+
7
+ export default class MapDto {
8
+ constructor(opt) {
9
+
10
+ // 默认缩放率
11
+ this.zoom = {
12
+ type: Number,
13
+ default: 10,
14
+ };
15
+
16
+ // 最大缩放率
17
+ this.maxZoom = {
18
+ type: Number,
19
+ default: 28,
20
+ };
21
+
22
+ // 最小缩放率
23
+ this.minZoom = {
24
+ type: Number,
25
+ default: 1,
26
+ };
27
+
28
+ // 默认中心点数组
29
+ this.center = {
30
+ type: Array,
31
+ default: () => [2575, 1450],
32
+ };
33
+
34
+ // 二维数组 [[],[]] 根据多个中心点数组进行定位 fit 适合用于 多边形 marker 折线等
35
+ this.bbox = {
36
+ type: Array,
37
+ default: () => [],
38
+ };
39
+
40
+ this.url = {
41
+ type: String,
42
+ default: () => null,
43
+ };
44
+
45
+ this.imageSize={
46
+ type: Array,
47
+ default: () => [0, 0, 7247, 3562],
48
+ }
49
+ this.imageExtent={
50
+ type: Array,
51
+ default: () =>[500, 400, 5000, 2700],
52
+ }
53
+ // this.viewOptions = {
54
+ // type: Object,
55
+ // default: () => {
56
+ // return {
57
+ // projection: 'EPSG:4326',
58
+ // center: [116.40769, 39.89945],
59
+ // zoom: 18,
60
+ // minZoom:1,
61
+ // maxZoom:18
62
+ // };
63
+ // }
64
+ // }
65
+ }
66
+ }
@@ -11,7 +11,7 @@
11
11
  stroke: 'rgba(23, 168, 162, 0.56)',
12
12
  width: 3,
13
13
  // id:'ceshi',
14
- text:''
14
+ text:''
15
15
  };
16
16
  import {
17
17
  CheckPoint,
@@ -70,7 +70,7 @@
70
70
  checkPointArr: new Map(),
71
71
  currentArr: Array(),
72
72
  fpModelArr: [],
73
- featurePolygon: new FeaturePolygon(this.gpsType),
73
+ featurePolygon:null,
74
74
  multiPolygonMap: new Map(),
75
75
  // model: new multiPolygonGeoJsonModel(),
76
76
  scan: new GrahamScan(),
@@ -80,6 +80,7 @@
80
80
  beforeDestroy() {
81
81
  this.clear();
82
82
  },
83
+
83
84
  watch: {
84
85
  modelArr(data) {
85
86
  if (this.map) {
@@ -93,6 +94,7 @@
93
94
  }
94
95
  },
95
96
  created(){
97
+ this.featurePolygon = new FeaturePolygon(this.gpsType);
96
98
  this.clear();
97
99
  this.init();
98
100
  },
@@ -283,7 +283,8 @@
283
283
  m,
284
284
  oversteSetValue: m >= this.m ? true : false,
285
285
  x,
286
- y
286
+ y,
287
+ e
287
288
  });
288
289
 
289
290
  if (m >= this.m) {
@@ -296,7 +297,8 @@
296
297
  m,
297
298
  oversteSetValue: false,
298
299
  x,
299
- y
300
+ y,
301
+ e
300
302
  });
301
303
  }
302
304
  if (isMoveend) {
@@ -90,9 +90,9 @@
90
90
  isCrossHair(val) {
91
91
  this.isCrossHair = val;
92
92
  },
93
- gpsType(val){
94
- if(this.lastType == val) return;
95
- this.gpsType=val;
93
+ gpsType(val){
94
+ if(this.lastType == val) return;
95
+ this.gpsType=val;
96
96
  this.lastType=val;
97
97
  if(this.drawPolygon){
98
98
  this.drawPolygon.type=val;
@@ -104,7 +104,7 @@
104
104
  data() {
105
105
  return {
106
106
  drawPolygon: null,
107
- isEdit:true,
107
+ isEdit:true,
108
108
  lastType:-1,
109
109
  };
110
110
  },
@@ -122,7 +122,7 @@
122
122
  bbox
123
123
  } = this._serializeGeoJson();
124
124
  this.onDelete();
125
- this.drawPolygon = this.lMap.onCreatePolygon(() => {});
125
+ this.drawPolygon = this.lMap.onCreatePolygon(() => {},this.isHideAreaAndKM);
126
126
  this.lastType=this.gpsType;
127
127
  this.drawPolygon.type= this.gpsType;
128
128
  this.drawPolygon.initCoordinates(coordinates);
@@ -159,7 +159,7 @@
159
159
  onCreatePolygon() {
160
160
  if (this.lMap) {
161
161
  // this.drawPolygon=null;
162
- this.drawPolygon = this.lMap.onCreatePolygon(() => {});
162
+ this.drawPolygon = this.lMap.onCreatePolygon(() => {},this.isHideAreaAndKM);
163
163
  this.lastType=this.gpsType;
164
164
  this.drawPolygon.type=this.gpsType;
165
165
  this.$emit('loadDrawPolygonEvent', this);
@@ -356,7 +356,6 @@
356
356
  checkPoint.show();
357
357
  return;
358
358
  }
359
-
360
359
  checkPoint.hide();
361
360
  }
362
361
  },
@@ -0,0 +1,7 @@
1
+ import RyStaticMap from './src/index';
2
+
3
+ RyStaticMap.install = (Vue) => {
4
+ Vue.install(RyStaticMap.name, RyStaticMap);
5
+ };
6
+
7
+ export default RyStaticMap;
@@ -0,0 +1,233 @@
1
+ <template>
2
+ <div class="map-box">
3
+ <div v-lmap:loadMap class="map-style"></div>
4
+ <!-- isRyMapTool -->
5
+ <RyMapTool class="ry-map-tool" :class="{
6
+ 'left':!isRight,
7
+ 'right':isRight
8
+ }" v-if="lMap.map && isRyMapTool" @crossHairClick="crossHairClick($event)" :lMap="lMap"
9
+ :isShowRangingTool="isShowRangingTool" :initModifyPolygon="initModifyPolygon"
10
+ :isShowDrawTool="isShowDrawTool" :isRight="isRight" :isCrossHair="isCrossHair" :hideAdd="hideAdd"
11
+ :hidePoint="hidePoint" :hideCancel="hideCancel" :hideDelete="hideDelete" :hideSave="hideSave"
12
+ :hideLine="hideLine" :hideArea="hideArea" :isSwitchMap="isSwitchMap" :isSwitchMapRight="isSwitchMapRight"
13
+ :isHideAreaAndKM="isHideAreaAndKM"
14
+ @loadDrawPolygonEvent="loadDrawPolygonEvent($event)" @success="drawSuccess($event)"
15
+ @error="drawError($event)">
16
+ <template>
17
+ <slot name="maptool"></slot>
18
+ </template>
19
+ </RyMapTool>
20
+
21
+ <template v-if="map">
22
+ <slot name="polygon" :mapDto="{map,lMap}">
23
+
24
+ </slot>
25
+
26
+ <slot name="marker" :mapDto="{map,lMap}">
27
+
28
+ </slot>
29
+ </template>
30
+
31
+ </div>
32
+
33
+
34
+
35
+ </template>
36
+ <script>
37
+ import MapServices from '@/utils/lMapServices.js';
38
+ import MapDto from './../../models/ryStaticMap/map.js';
39
+ import ViewDto from './../../models/ryStaticMap/view.js';
40
+ import MapToolDto from './../../models/ryMapTool/mapTool.js';
41
+ import RyMapTool from '../../ryMapTool/src/index';
42
+ import ImageLayer from 'ol/layer/Image';
43
+ import ImageStatic from 'ol/source/ImageStatic';
44
+ import View from 'ol/View';
45
+ import Projection from 'ol/proj/Projection';
46
+
47
+ import {
48
+ fitNew,
49
+ caculateLL,
50
+ } from 'ry-map';
51
+ export default {
52
+ name: 'RyStaticMap',
53
+ components: {
54
+ RyMapTool,
55
+ },
56
+ props: {
57
+ ...new MapDto(),
58
+ ...new ViewDto(),
59
+ ...new MapToolDto()
60
+ },
61
+ created() {
62
+ },
63
+ watch: {
64
+ center(newValue) {
65
+ this.setCenter(newValue);
66
+ },
67
+ bbox(newValue) {
68
+ this.setFit(newValue);
69
+ },
70
+ maxZoom(zoom) {
71
+ this.lMap.setMaxZoom(zoom);
72
+ },
73
+ zoom(zoom) {
74
+ this.lMap.setZoom(zoom);
75
+ },
76
+ minZoom(zoom) {
77
+ this.lMap.setMinZoom(zoom);
78
+ },
79
+ bindMapClick(val) {
80
+ if (this.bindMapClick !== val) {
81
+ this.bindMapClick = val;
82
+ this._bingMapEvent();
83
+ }
84
+ },
85
+ },
86
+ data() {
87
+ return {
88
+ lMap: new MapServices(),
89
+ drawPolygon: null,
90
+ mapClick: null,
91
+ map: null,
92
+ moveend: null,
93
+ lastX: 0,
94
+ lastY: 0,
95
+ };
96
+ },
97
+ 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
+ });
139
+ },
140
+ _bingMapEvent() {
141
+ if (this.bindMapClick) {
142
+ this._mapClickOnce();
143
+ } else {
144
+ this._mapClickOnce(true);
145
+ }
146
+ },
147
+ setMaxZoom(zoom) {
148
+ this.lMap.setMaxZoom(zoom)
149
+ },
150
+ setMinZoom(zoom) {
151
+ this.lMap.setMinZoom(zoom)
152
+ },
153
+ setZoom(zoom) {
154
+ this.lMap.setZoom(zoom);
155
+ },
156
+ crossHairClick(obj) {
157
+ this.$emit('crossHairClick', obj);
158
+ },
159
+ setCenter(center) {
160
+ this.lMap.setCenter(center, 15);
161
+ },
162
+ setFit(bbox) {
163
+ if (!bbox.length || !this.map) return;
164
+ fitNew(this.map, [bbox]);
165
+ },
166
+ drawSuccess(geo) {
167
+ this.$emit('drawSuccess', geo);
168
+ },
169
+ drawError(obj) {
170
+ this.$emit('drawError', obj);
171
+ },
172
+ _mapClickOnce(isBinClick = false) {
173
+ if (!this.mapClick) {
174
+ this.mapClick = evt => {
175
+ if (evt.dragging) {
176
+ return;
177
+ }
178
+ const pixel = this.map.getEventPixel(evt.originalEvent);
179
+ const hit = this.map.hasFeatureAtPixel(pixel);
180
+ if (hit) {
181
+ const _feature = this.map.forEachFeatureAtPixel(evt.pixel, feature => feature);
182
+ const _id = _feature.getId();
183
+ if (_id === undefined) {
184
+ return;
185
+ }
186
+ this.$emit('mapClick', _id);
187
+ }
188
+ };
189
+ }
190
+ if (isBinClick) {
191
+ this.map.un('click', this.mapClick);
192
+ this.mapClick = null;
193
+ } else {
194
+ this.map.on('click', this.mapClick);
195
+ }
196
+ },
197
+ loadDrawPolygonEvent(e) {
198
+ this.$emit('loadDrawPolygonEvent', e);
199
+ }
200
+ }
201
+ }
202
+ </script>
203
+
204
+ <style lang="scss" scoped>
205
+ .map-box {
206
+ height: 100%;
207
+ position: relative;
208
+
209
+ &>.map-style {
210
+ height: 100%;
211
+ position: relative;
212
+ width: 100%;
213
+ }
214
+ }
215
+
216
+ .ry-map-tool {
217
+ position: absolute;
218
+ top: 20px;
219
+ }
220
+
221
+ .left {
222
+ left: 30px;
223
+ }
224
+
225
+ .right {
226
+ right: 30px;
227
+ }
228
+
229
+
230
+ .move-box {
231
+ position: absolute;
232
+ }
233
+ </style>
@@ -145,9 +145,7 @@
145
145
  this.map.getView().setZoom(zoom + 0.00001);
146
146
  this.map.getView().setZoom(zoom - 0.0001);
147
147
  },
148
-
149
-
150
-
148
+
151
149
  }
152
150
  }
153
151
  </script>
@@ -59,26 +59,32 @@ export default {
59
59
  mapStyleCopy: [],
60
60
  }
61
61
  },
62
+
62
63
  watch: {
63
- switchMapDefaultTypeOrLayer: {
64
- handler(e) {
65
- if(!e)return;
66
- const isCorrect = this.formatToJudge(e);
67
- if (!isCorrect) return;
68
- const active = this.mapStyleActive;
69
- const mapType = (isCorrect || isCorrect===0)?e[0]:1;
70
- const layerType = (isCorrect || isCorrect===1)?active:2;
71
- setTimeout(() => {
72
- this.$emit('changeSwitchMap', {
73
- mapType,
74
- layerType
75
- });
76
- }, 100);
77
- },
78
- immediate: true
79
- },
64
+ switchMapDefaultTypeOrLayer(e){
65
+ console.log(e);
66
+ if(!e)return;
67
+ const isCorrect = this.formatToJudge(e);
68
+ if (!isCorrect) return;
69
+ const active = this.mapStyleActive;
70
+ const mapType = (isCorrect || isCorrect===0)?e[0]:1;
71
+ const layerType = (isCorrect || isCorrect===1)?active:2;
72
+ setTimeout(() => {
73
+ this.$emit('changeSwitchMap', {
74
+ mapType,
75
+ layerType
76
+ });
77
+ }, 100);
78
+ },
79
+ // switchMapDefaultTypeOrLayer: {
80
+ // handler(e) {
81
+
82
+ // },
83
+ // immediate: true
84
+ // },
80
85
  mapTypeAndLayer :{
81
86
  handler(e){
87
+ console.log('111111');
82
88
  if(!Array.isArray(e) || !e[1])return;
83
89
  e.forEach((r,index)=>{
84
90
  if(index===1 && !this.switchMapDefaultTypeOrLayer){
@@ -91,9 +97,9 @@ export default {
91
97
  }
92
98
  },
93
99
  created(){
94
-
95
100
  },
96
101
  mounted() {
102
+ this._switchMapDefaultTypeOrLayer(this.switchMapDefaultTypeOrLayer);
97
103
  if(!this.switchMapDefaultTypeOrLayer){
98
104
  setTimeout(()=>{
99
105
  this.$emit('changeSwitchMap', {
@@ -186,7 +192,21 @@ export default {
186
192
  mapType: this.mapTypeActive,
187
193
  layerType: this.mapStyleActive
188
194
  });
189
- }
195
+ },
196
+ _switchMapDefaultTypeOrLayer(e){
197
+ if(!e)return;
198
+ const isCorrect = this.formatToJudge(e);
199
+ if (!isCorrect) return;
200
+ const active = this.mapStyleActive;
201
+ const mapType = (isCorrect || isCorrect===0)?e[0]:1;
202
+ const layerType = (isCorrect || isCorrect===1)?active:2;
203
+ setTimeout(() => {
204
+ this.$emit('changeSwitchMap', {
205
+ mapType,
206
+ layerType
207
+ });
208
+ }, 100);
209
+ }
190
210
  }
191
211
  }
192
212
  </script>
@@ -14,11 +14,36 @@ const routes = [
14
14
  component: () => import('@/views/map'),
15
15
  meta: { title: '地图' }
16
16
  },
17
+ {
18
+ path: '/staticMap',
19
+ component: () => import('@/views/staticMap'),
20
+ meta: { title: '室内地图' }
21
+ },
17
22
  {
18
- path: '/',
19
- component: () => import('@/views/vectorMap'),
20
- meta: { title: '地图' }
23
+ path: '/excel',
24
+ component: () => import('@/views/excel'),
25
+ meta: { title: 'excel' }
21
26
  },
27
+ {
28
+ path: '/tree',
29
+ component: () => import('@/views/tree'),
30
+ meta: { title: 'tree' }
31
+ },
32
+ {
33
+ path: '/pdf',
34
+ component: () => import('@/views/pdf'),
35
+ meta: { title: 'pdf' }
36
+ },
37
+ {
38
+ path: '/docx',
39
+ component: () => import('@/views/docx'),
40
+ meta: { title: 'docx' }
41
+ },
42
+ {
43
+ path: '/',
44
+ component: () => import('@/views/vectorMap'),
45
+ meta: { title: '地图' }
46
+ },
22
47
  {
23
48
  path: '*',
24
49
     component: () => import('@/views/map'),