ry-vue-map 0.1.0 → 0.1.2

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.1.0",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "main": "lib/ryui.umd.min.js",
6
6
  "description": "ry公共组件库",
@@ -38,7 +38,7 @@
38
38
  "element-ui": "~2.15.6",
39
39
  "nprogress": "~0.2.0",
40
40
  "ol": "^6.14.1",
41
- "ry-map": "^0.2.7",
41
+ "ry-map": "^0.3.0",
42
42
  "vue": "~2.6.14",
43
43
  "vue-router": "~3.5.2",
44
44
  "vue-server-renderer": "^2.6.14",
Binary file
Binary file
@@ -5,12 +5,13 @@ import RyMapTool from './maps/ryMapTool';
5
5
  import RyPolygon from './maps/ryPolygon';
6
6
  import RyPolygons from './maps/ryPolygons';
7
7
  import RyClusters from './maps/ryClusters';
8
+ import RyClustersMarker from './maps/ryClustersMarker';
8
9
  import RyPolygonGeo from './maps/ryPolygonGeo';
9
10
 
10
11
  // import "./fonts/iconfont.css";
11
12
 
12
13
  // 组件列表
13
- const components = [ RyMap,RyCrossHair,RyMapTool, RyPolygon,RyPolygons,RyClusters, RyPolygonGeo];
14
+ const components = [ RyMap,RyCrossHair,RyMapTool, RyPolygon,RyPolygons,RyClusters, RyPolygonGeo, RyClustersMarker];
14
15
 
15
16
  // 定义install
16
17
  const install = (Vue, options) => {
@@ -10,19 +10,18 @@
10
10
  fillColor: 'rgba(184, 233, 134, 0.56)',
11
11
  stroke: 'rgba(23, 168, 162, 0.56)',
12
12
  width: 3,
13
- id:'ceshi',
13
+ // id:'ceshi',
14
14
  text:'快'
15
15
  };
16
16
  import {
17
17
  CheckPoint,
18
18
  GrahamScan,
19
19
  LPolygonNew,
20
- LCluster,
21
20
  FeaturePolygon,
22
21
  FeaturePolygonModel,
23
22
  getCenterPoint,
24
23
  getLngAndLatMaxMin,
25
-
24
+ LCluster,
26
25
  }from 'ry-map'
27
26
 
28
27
  export default {
@@ -43,7 +42,23 @@
43
42
  gpsType:{
44
43
  type:Number,
45
44
  default:0,
46
- }
45
+ },
46
+ color:{
47
+ type:String,
48
+ default:'#fff',
49
+ },
50
+ fontSize:{
51
+ type:Number,
52
+ default:14,
53
+ },
54
+ offsetX:{
55
+ type:Number,
56
+ default:0,
57
+ },
58
+ offsetY:{
59
+ type:Number,
60
+ default:0,
61
+ }
47
62
  },
48
63
  data() {
49
64
  return {
@@ -51,7 +66,7 @@
51
66
  checkPointArr: new Map(),
52
67
  currentArr: Array(),
53
68
  fpModelArr: [],
54
- featurePolygon: new FeaturePolygon(),
69
+ featurePolygon: new FeaturePolygon(this.gpsType),
55
70
  multiPolygonMap: new Map(),
56
71
  // model: new multiPolygonGeoJsonModel(),
57
72
  scan: new GrahamScan(),
@@ -69,8 +84,8 @@
69
84
  }
70
85
  },
71
86
  gpsType(val){
72
- this.gpsType=val;
73
- this.selectGPSAll(2);
87
+ this.gpsType = val;
88
+ this.selectGPSAll(val);
74
89
  }
75
90
  },
76
91
  created(){
@@ -100,12 +115,14 @@
100
115
  idSet.forEach(val => {
101
116
  this.removeAggregation(val);
102
117
  });
103
- const options = {
118
+
119
+ const options = {
104
120
  ...this.clusterPolygonModel,
105
121
  coordinates: [this.scan.getHull()],
106
122
  ids: idSet
107
123
  };
108
- this.polygonSet.add(new LPolygonNew({...options,type:this.gpsType}, this.map));
124
+
125
+ this.polygonSet.add(new LPolygonNew({...options,gpsType:this.gpsType}, this.map));
109
126
  },
110
127
  removeAggregation(id) {
111
128
  let arr = [];
@@ -175,14 +192,13 @@
175
192
  center,
176
193
  bbox,
177
194
  } = this._serializeGeoJson(res.geo);
178
-
179
195
  const dto = this.createFeaturePolygonModel(res.id, center);
180
-
181
196
  this.fpModelArr.push(dto);
182
197
  });
198
+ // this.fpModelArr.push('this.fpModelArr',this.fpModelArr.length);
183
199
  },
184
200
  initCluster() {
185
- const cp = new LCluster((feature, featureArr, b) => {
201
+ const cp = new LCluster((feature, featureArr, b) => {
186
202
  const _id = feature.getId();
187
203
  if (b) {
188
204
  this.$emit('callback', {id:_id, isShow:true});
@@ -205,6 +221,10 @@
205
221
  }
206
222
  }, {
207
223
  text: this.clusterPolygonModel.text,
224
+ offsetX:this.offsetX,
225
+ offsetY:this.offsetY,
226
+ fontSize:this.fontSize,
227
+ color:this.fontColor,
208
228
  aggregationCallback: (arr) => {
209
229
  this.mergeGeoJson(arr);
210
230
  },
@@ -224,12 +244,13 @@
224
244
  },
225
245
 
226
246
  selectGPSAll(type){
227
- this.checkPointArr.forEach(val => {
228
- val.selectGPS(type);
229
- });
230
247
  this.polygonSet.forEach(val => {
231
248
  val.selectGPS(type);
232
249
  });
250
+
251
+ if(this.featurePolygon){
252
+ this.featurePolygon.selectGPSAll(type);
253
+ }
233
254
  }
234
255
  },
235
256
  }
@@ -0,0 +1,7 @@
1
+ import RyClustersMarker from './src/index';
2
+
3
+ RyClustersMarker.install = (Vue) => {
4
+ Vue.install(RyClustersMarker.name, RyClustersMarker);
5
+ };
6
+
7
+ export default RyClustersMarker;
@@ -0,0 +1,149 @@
1
+ <template>
2
+ <div>
3
+
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import LMapServices from '@/utils/lMapServices.js';
9
+ const _clusterPolygon = {
10
+ fillColor: 'rgba(184, 233, 134, 0.56)',
11
+ stroke: 'rgba(23, 168, 162, 0.56)',
12
+ width: 3,
13
+ // id:'ceshi',
14
+ text: '快'
15
+ };
16
+ import {
17
+ GrahamScan,
18
+ FeaturePolygon,
19
+ FeaturePolygonModel,
20
+ LClusterMarker as LCluster,
21
+ } from 'ry-map'
22
+
23
+ export default {
24
+ name: 'RyClusters',
25
+ props: {
26
+ modelArr: {
27
+ type: Array,
28
+ default: () => [],
29
+ },
30
+ text: {
31
+ type: String,
32
+ default: () => '台',
33
+ },
34
+ map: {
35
+ type: Object,
36
+ default: () => null
37
+ },
38
+ gpsType: {
39
+ type: Number,
40
+ default: 0,
41
+ },
42
+ color: {
43
+ type: String,
44
+ default: '#fff',
45
+ },
46
+ src: {
47
+ type: String,
48
+ default: () => null,
49
+ },
50
+ fontSize: {
51
+ type: Number,
52
+ default: 14,
53
+ },
54
+ offsetX: {
55
+ type: Number,
56
+ default: 0,
57
+ },
58
+ offsetY: {
59
+ type: Number,
60
+ default: 0,
61
+ }
62
+ },
63
+ data() {
64
+ return {
65
+ fpModelArr: [],
66
+ featurePolygon: new FeaturePolygon(this.gpsType),
67
+ scan: new GrahamScan(),
68
+ polygonSet: new Set(),
69
+ }
70
+ },
71
+ beforeDestroy() {
72
+ this.clear();
73
+ },
74
+ watch: {
75
+ modelArr(data) {
76
+ if (this.map) {
77
+ this.clear();
78
+ this.init();
79
+ }
80
+ },
81
+ gpsType(val) {
82
+ this.gpsType = val;
83
+ this.selectGPSAll(val);
84
+ }
85
+ },
86
+ created() {
87
+ this.clear();
88
+ this.init();
89
+ },
90
+ methods: {
91
+ clear() {},
92
+ createFeaturePolygonModel(id, coordinates) {
93
+ return new FeaturePolygonModel(coordinates, id);
94
+ },
95
+ async init() {
96
+ this.initFeature();
97
+ this.initCluster();
98
+ },
99
+ initFeature() {
100
+ this.modelArr.forEach(res => {
101
+ const dto = this.createFeaturePolygonModel(res.id, [res.x, res.y]);
102
+ this.fpModelArr.push(dto);
103
+ });
104
+ },
105
+ initCluster() {
106
+ const cp = new LCluster((feature, featureArr, b) => {
107
+ const _id = feature.getId();
108
+ if (b) {
109
+ this.$emit('callback', {
110
+ id: _id,
111
+ isShow: true
112
+ });
113
+ return;
114
+ } else {
115
+ this.$emit('callback', {
116
+ id: _id,
117
+ isShow: false
118
+ });
119
+ }
120
+ }, {
121
+ text: this.text,
122
+ offsetX: this.offsetX,
123
+ offsetY: this.offsetY,
124
+ fontSize: this.fontSize,
125
+ color: this.fontColor,
126
+ src: this.src,
127
+ aggregationCallback: (arr) => {
128
+
129
+ },
130
+ removeAggregationCallback: (feature) => {}
131
+ });
132
+
133
+ const vectorSource = this.featurePolygon.getVectorSource(this.fpModelArr);
134
+
135
+ const vectorLayer = cp.getVectorLayer(vectorSource);
136
+
137
+ this.map.addLayer(vectorLayer);
138
+ },
139
+
140
+ selectGPSAll(type) {
141
+ if (this.featurePolygon) {
142
+ this.featurePolygon.selectGPSAll(type);
143
+ }
144
+ }
145
+ },
146
+ }
147
+ </script>
148
+ <style lang="scss" scoped>
149
+ </style>
@@ -160,7 +160,7 @@
160
160
  this.setMaxZoom(18);
161
161
  }
162
162
  },
163
- loadMap(el) {
163
+ loadMap(el,layers) {
164
164
  // const dto =
165
165
  this.lMap.init({
166
166
  el,
@@ -91,6 +91,7 @@ export default class LMapServices {
91
91
  this.drawPolygonArr = new Set();
92
92
  this.drawLineArr = new Set();
93
93
  this._lRectangle=null;
94
+ this.layers=null;
94
95
  }
95
96
  init(optins) {
96
97
  const {
@@ -129,12 +130,13 @@ export default class LMapServices {
129
130
  if (this.map) {
130
131
  this.map = null;
131
132
  }
132
-
133
- this.map = await this.lmap.onLoad(el,type, layerType);
133
+ const {map,layers} = await this.lmap.onLoad(el,type, layerType);
134
+ this.map=map;
135
+ this.layers=layers;
134
136
  MapConfig.View = viewOptions;
135
137
  this.map.setView(MapConfig.View);
136
138
  if (callback) {
137
- callback(this.map);
139
+ callback(this.map,layers);
138
140
  }
139
141
  };
140
142
  _async();
@@ -163,11 +165,13 @@ export default class LMapServices {
163
165
  if (this.map) {
164
166
  this.map = null;
165
167
  }
166
- this.map = await this.lmap.onLoad(el, 2, 2);
168
+ const {map,layers} = await this.lmap.onLoad(el, 2, 2);
169
+ this.map=map;
170
+ this.layers=layers;
167
171
  MapConfig.View = viewOptions;
168
172
  this.map.setView(MapConfig.View);
169
173
  if (callback) {
170
- callback(this.map);
174
+ callback(this.map,layers);
171
175
  }
172
176
  };
173
177
  _async();
@@ -186,12 +190,14 @@ export default class LMapServices {
186
190
  const _async = async () => {
187
191
  if (this.map) {
188
192
  this.map = null;
189
- }
190
- this.map = await this.lmap.onLoad(el, 0, 2);
193
+ }
194
+ const {map,layers} = await this.lmap.onLoad(el, 0, 2);
195
+ this.map=map;
196
+ this.layers=layers;
191
197
  MapConfig.View = viewOptions;
192
198
  this.map.setView(MapConfig.View);
193
199
  if (callback) {
194
- callback(this.map);
200
+ callback(this.map,layers);
195
201
  }
196
202
  };
197
203
  _async();
@@ -236,7 +242,9 @@ export default class LMapServices {
236
242
  if (this.map) {
237
243
  this.map = null;
238
244
  }
239
- this.map = await this.lmap.onLoad(el);
245
+ const {map,layers} = await this.lmap.onLoad(el);
246
+ this.map=map;
247
+ this.layers=layers;
240
248
  this.map.setView(MapConfig.getVectorLayerView);
241
249
  if (callback) {
242
250
  callback(this.map);
@@ -6,9 +6,9 @@
6
6
  @drawError="drawError" :isShowRangingTool="true" :isShowDrawTool="isRyMapTool" :bindMapClick="true"
7
7
  @mapClick="mapClick($event)" @crossHairClick="crossHairClick($event)" :bindMapMoveend="true"
8
8
  :isSwitchMapRight='true' :switchMapPosTop='60' :switchMapPosLeftOrRight="20" :switchMapHeight="40"  
9
- :switchMapDefaultTypeOrLayer="[2,1]" @mapMoveend="mapMoveend($event)"
9
+ :switchMapDefaultTypeOrLayer="[1,2]" @mapMoveend="mapMoveend($event)"
10
10
  @loadDrawPolygonEvent="loadDrawPolygonEvent($event)" :initModifyPolygon="geoJson"
11
- @changeSwitchMap="changeSwitchMap($event)" :isDisabledSwitchMapTabEvent="false" :isShowSwitchMap="true"
11
+ @changeSwitchMap="changeSwitchMap($event)" :isShowSwitchMap="true"
12
12
  :layerType="1" :mapType="2">
13
13
  <!-- <template slot="maptool">
14
14
  <button>ry</button>
@@ -24,8 +24,8 @@
24
24
  :mapType="1" -->
25
25
  <template #polygon="{mapDto}">
26
26
  <!-- <ry-polygon :map="mapDto.map" :isShow="true" :polygonColor="colors" :model="polygonModel" :clear="isClear" @onLoad="onLoad($event)"></ry-polygon> -->
27
- <ry-polygon :isFit="false" :gpsType="gpsType" :map="mapDto.map" :model="polygonModel"></ry-polygon>
28
- <ry-polygon-geo :isFit="true" :gpsType="gpsType" :map="mapDto.map" :model="polygonModel6" > </ry-polygon-geo>
27
+ <!-- <ry-polygon :isFit="false" :gpsType="gpsType" :map="mapDto.map" :model="polygonModel"></ry-polygon>
28
+ <ry-polygon-geo :isFit="true" :gpsType="gpsType" :map="mapDto.map" :model="polygonModel6" > </ry-polygon-geo> -->
29
29
  <!-- <ry-polygon :isFit="true" :isShowAll="isShowAll" :map="mapDto.map" :isShow="true" :model="polygonModel" @onLoad="onLoad($event)"></ry-polygon> -->
30
30
  <!-- <ry-polygons :restFit="restFit" :isCheckPointHideAll="isShowAll" :isCheckPointHide="showPolygon"
31
31
  :isCheckPointHides="showPolygons" :isShowPolygon="showPolygon" :isShowPolygons="showPolygons" :range="range"
@@ -33,12 +33,12 @@
33
33
  :polygonColor="polygonColorObj" :remove="remove" :removes="removes" :polygonColors="polygonColors"
34
34
  :modelArr="modelArr" @onLoad="onLoad($event)"></ry-polygons> -->
35
35
 
36
- <ry-polygons
36
+ <ry-polygons
37
37
  :map="mapDto.map"
38
38
  :modelArr="modelArr"
39
39
  @onLoad="onLoad($event)"
40
40
  :isShowPolygon="showPolygon" :isCheckPointHide="isCheckPoint" :inserts="inserts" :gpsType="gpsType"></ry-polygons>
41
- <ry-clusters @callback="clusterCallback($event)" :map="mapDto.map" :modelArr="modelArr"></ry-clusters>
41
+ <ry-clusters :src="src" text="台" :gpsType="gpsType" @callback="clusterCallback($event)" :map="mapDto.map" :modelArr="modelArr2"></ry-clusters>
42
42
  </template>
43
43
 
44
44
  </ry-map>
@@ -84,7 +84,7 @@
84
84
  import RyMapTool from '@/components/maps/ryMapTool/src/index.vue';
85
85
  import RyPolygon from '@/components/maps/ryPolygon/src/index.vue';
86
86
  import RyPolygons from '@/components/maps/ryPolygons/src/index.vue';
87
- import RyClusters from '@/components/maps/ryClusters/src/index.vue';
87
+ import RyClusters from '@/components/maps/ryClustersMarker/src/index.vue';
88
88
  import RyPolygonGeo from '@/components/maps/ryPolygonGeo/src/index.vue';
89
89
  import gJson from './3301';
90
90
  import gJson2 from "./331123";
@@ -169,7 +169,8 @@
169
169
  RyPolygon,
170
170
  RyPolygons,
171
171
  RyClusters,
172
- RyPolygonGeo
172
+ RyPolygonGeo,
173
+
173
174
  },
174
175
  data() {
175
176
  return {
@@ -180,7 +181,13 @@
180
181
  isClear: false,
181
182
  geoJson: null,
182
183
  colors: [],
183
- modelArr: [polygonModel2, polygonModel3, polygonModel4],
184
+ modelArr: [polygonModel1,polygonModel2, polygonModel3, polygonModel4],
185
+ modelArr2: [
186
+ {id:'ceshi1', x:120.15535003220648,y:30.179378795342608},
187
+ {id:'ceshi2',x:120.16369976775891,y:30.1967116895034},
188
+ {id:'ceshi3',x:120.156817,y:30.1753985} ,
189
+ {id:'ceshi4',x:120.1538245,y:30.183076} ,
190
+ ],
184
191
  center: [121.03623185250073, 29.247091764239528],
185
192
  polygonColors: [],
186
193
  remove: 'ceshi1',
@@ -190,10 +197,7 @@
190
197
  range: 'ceshi2',
191
198
  isFit: false,
192
199
  insert: null,
193
- showPolygon: {
194
- id: 'ceshis',
195
- isShow: true,
196
- },
200
+ showPolygon: null,
197
201
  showPolygons: [{
198
202
  id: 'ceshi2',
199
203
  isShow: false
@@ -204,15 +208,13 @@
204
208
  polygonModel: null,
205
209
  geo: g1,
206
210
  mapTool: null,
207
- isCheckPoint: {
208
- id: 'ceshis',
209
- isShow: false,
210
- },
211
+ isCheckPoint: null,
211
212
  gpsType: 0,
212
213
  isRyMapTool: true,
213
214
  maxZoom: 18,
214
215
  polygonModel5: polygonModel5,
215
216
  polygonModel6:polygonModel6,
217
+ src:require("@/assets/1.png"),
216
218
  };
217
219
  },
218
220
  created() {
@@ -378,4 +380,4 @@
378
380
  height: 100vh;
379
381
  position: relative;
380
382
  }
381
- </style>
383
+ </style>