ry-vue-map 0.1.8 → 0.2.0

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.8",
3
+ "version": "0.2.0",
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.3.0",
41
+ "ry-map": "^0.3.2",
42
42
  "vue": "~2.6.14",
43
43
  "vue-router": "~3.5.2",
44
44
  "vue-server-renderer": "^2.6.14",
@@ -7,11 +7,11 @@ import RyPolygons from './maps/ryPolygons';
7
7
  import RyClusters from './maps/ryClusters';
8
8
  import RyClustersMarker from './maps/ryClustersMarker';
9
9
  import RyPolygonGeo from './maps/ryPolygonGeo';
10
-
10
+ import RyVectorMap from './maps/ryVectorMap';
11
11
  // import "./fonts/iconfont.css";
12
12
 
13
13
  // 组件列表
14
- const components = [ RyMap,RyCrossHair,RyMapTool, RyPolygon,RyPolygons,RyClusters, RyPolygonGeo, RyClustersMarker];
14
+ const components = [ RyMap,RyCrossHair,RyMapTool, RyPolygon,RyPolygons,RyClusters, RyPolygonGeo, RyClustersMarker,RyVectorMap];
15
15
 
16
16
  // 定义install
17
17
  const install = (Vue, options) => {
@@ -0,0 +1,7 @@
1
+ import RyVectorMap from './src/index';
2
+
3
+ RyVectorMap.install = (Vue) => {
4
+ Vue.install(RyVectorMap.name, RyVectorMap);
5
+ };
6
+
7
+ export default RyVectorMap;
@@ -0,0 +1,161 @@
1
+ <template>
2
+ <div class="vector-map" v-lmap:loadMap>
3
+
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import MapServices from '@/utils/lMapServices.js';
9
+ export default {
10
+ name: 'RyVectorMap',
11
+ props: {
12
+ isAnalysisBBOX: {
13
+ type: Boolean,
14
+ default: true,
15
+ },
16
+ isAnalysisCenter: {
17
+ type: Boolean,
18
+ default: true,
19
+ },
20
+ modelArr : {
21
+ type: Array,
22
+ default: () => [],
23
+ },
24
+ delayTime:{
25
+ type: Number,
26
+ default: () =>50,
27
+ },
28
+ bindMapClick:{
29
+ type: Boolean,
30
+ default: false,
31
+ },
32
+ isDrag:{
33
+ type: Boolean,
34
+ default: true,
35
+ },
36
+ },
37
+ data() {
38
+ return {
39
+ lMap: new MapServices(),
40
+ drawPolygon: null,
41
+ mapClick: null,
42
+ map: null,
43
+ vmap:null,
44
+ lastX: 0,
45
+ lastY: 0,
46
+ moveend: null,
47
+ polygonMap:null,
48
+ }
49
+ },
50
+ watch: {
51
+ modelArr(val){
52
+ this.initLayers(val);
53
+ },
54
+ bindMapClick(val) {
55
+ if (this.bindMapClick !== val) {
56
+ this.bindMapClick = val;
57
+ this._bingMapEvent();
58
+ }
59
+ },
60
+ polygonColor(val) {
61
+ if (val) {
62
+ this.setPolygonColor(val.id, val.colorArr);
63
+ }
64
+ },
65
+ },
66
+ mounted() {
67
+
68
+ },
69
+ methods: {
70
+ async loadMap(el) {
71
+ const {
72
+ map,
73
+ vmap
74
+ } = await this.lMap.initVectorMap({
75
+ el,
76
+ isAnalysisBBOX:this.isAnalysisBBOX,
77
+ isAnalysisCenter:this.isAnalysisCenter,
78
+ delayTime:this.delayTime,
79
+ isDrag:this.isDrag,
80
+ callback: r => this.$emit('initLayersEvent', r),
81
+ });
82
+ this.map=map;
83
+ this.vmap=vmap;
84
+ this.polygonMap=vmap.getLayerMap;
85
+ this._bingMapEvent();
86
+ this.$emit('load', {
87
+ map,
88
+ vmap
89
+ });
90
+ if(this.modelArr.length){
91
+ this.initLayers(val);
92
+ }
93
+ },
94
+ initLayers(val){
95
+ if(!this.vmap) return;
96
+ this.vmap.initLayers(val);
97
+ },
98
+ _mapClickOnce(isBinClick = false) {
99
+ if (!this.mapClick) {
100
+ this.mapClick = evt => {
101
+ if (evt.dragging) {
102
+ return;
103
+ }
104
+ const pixel = this.map.getEventPixel(evt.originalEvent);
105
+ const hit = this.map.hasFeatureAtPixel(pixel);
106
+ if (hit) {
107
+    const _feature = this.map.forEachFeatureAtPixel(evt.pixel, feature => feature);
108
+ const pro =_feature.getProperties();
109
+ const view = this.map.getView();
110
+ const [lon,lat]=view.getCenter();
111
+ const _id = _feature.getId();
112
+ if(pro){
113
+ this.$emit('mapClick', {...pro,id: _id ? _id:null,lon,lat});
114
+ }
115
+ }
116
+ };
117
+ }
118
+ if (isBinClick) {
119
+ this.map.un('click', this.mapClick);
120
+ this.mapClick = null;
121
+ } else {
122
+ this.map.on('click', this.mapClick);
123
+ }
124
+ },
125
+ _bingMapEvent() {
126
+ if (this.bindMapClick) {
127
+ this._mapClickOnce();
128
+ } else {
129
+ this._mapClickOnce(true);
130
+ }
131
+ },
132
+
133
+ setPolygonColor(id, color, isLoad = true) {
134
+ if (this.polygonMap.has(id)) {
135
+ const polygon = this.polygonMap.get(id);
136
+ polygon.setPolygonColor(color);
137
+ if (isLoad) {
138
+ this._setZoom();
139
+ }
140
+ }
141
+ },
142
+ // 刷新颜色
143
+ _setZoom() {
144
+ const zoom = this.map.getView().getZoom();
145
+ this.map.getView().setZoom(zoom + 0.00001);
146
+ this.map.getView().setZoom(zoom - 0.0001);
147
+ },
148
+
149
+
150
+
151
+ }
152
+ }
153
+ </script>
154
+
155
+ <style scoped lang="scss">
156
+ .vector-map {
157
+ height: 100%;
158
+ width: 100%;
159
+ position: relative;
160
+ }
161
+ </style>
@@ -9,6 +9,11 @@ Vue.use(VueRouter);
9
9
 
10
10
  // 静态路由
11
11
  const routes = [
12
+ {
13
+ path: '/',
14
+ component: () => import('@/views/vectorMap'),
15
+ meta: { title: '地图' }
16
+ },
12
17
  {
13
18
  path: '/',
14
19
  component: () => import('@/views/map'),
@@ -16,7 +21,7 @@ const routes = [
16
21
  },
17
22
  {
18
23
  path: '*',
19
-    component: () => import('@/views/map'),
24
+    component: () => import('@/views/vectorMap'),
20
25
  }
21
26
  ];
22
27
 
@@ -70,7 +70,8 @@ import {
70
70
  MapLayersEnum,
71
71
  BingLayers,
72
72
  BDLayers,
73
- LRectangle
73
+ LRectangle,
74
+ VectorMap
74
75
  } from 'ry-map';
75
76
 
76
77
  export default class LMapServices {
@@ -225,34 +226,27 @@ export default class LMapServices {
225
226
  // }, 100);
226
227
  }
227
228
 
228
- initVectorMap(el, callback, viewOptions) {
229
- // this.clear();
230
- if (!this.lmap) {
231
- if (this.map) {
232
- this.map = null;
233
- }
234
- this.lmap = new LMap({
235
- controls: MapConfig.Defaults,
236
- interactions: MapConfig.InteractionsDeft
237
- });
238
- }
239
-
240
- setTimeout(() => {
241
- const _async = async () => {
242
- if (this.map) {
243
- this.map = null;
244
- }
245
- const {map,layers} = await this.lmap.onLoad(el);
246
- this.map=map;
247
- this.layers=layers;
248
- this.map.setView(MapConfig.getVectorLayerView);
249
- if (callback) {
250
- callback(this.map);
251
- }
252
- };
253
- _async();
254
- }, 100);
255
- }
229
+ async initVectorMap(opt) {
230
+ const {el,isAnalysisBBOX,isAnalysisCenter,callback,delaytime,isDrag} = opt;
231
+ const vmap = new VectorMap({
232
+ isAnalysisBBOX,
233
+ isAnalysisCenter,
234
+ isDrag,
235
+ callback:r=> {
236
+ if(callback){
237
+ callback(r);
238
+ }
239
+ }
240
+ });
241
+
242
+ return new Promise(r=> {
243
+ setTimeout(async ()=> {
244
+ const map = await vmap.onLoad(el);
245
+ r({map,vmap});
246
+ },delaytime ? delaytime:100);
247
+ });
248
+
249
+ }
256
250
 
257
251
  getVectorLayerView() {
258
252
  return MapConfig.getVectorLayerView;
@@ -925,6 +919,20 @@ export default class LMapServices {
925
919
  return [];
926
920
  }
927
921
 
922
+ getRectangleDataNew(){
923
+ if(!this._lRectangle) return [];
924
+ const coordinates = this._lRectangle.getCoordinates();
925
+ const pointArr= coordinates[0];
926
+ if(pointArr.length){
927
+ const arr= [];
928
+ arr.push([pointArr[0][0], pointArr[1][1]]);
929
+ arr.push([pointArr[1][0], pointArr[2][1]]);
930
+ return arr;
931
+ };
932
+ return [];
933
+ }
934
+
935
+
928
936
  clearRectangle() {
929
937
  if (this.map && this._lRectangle) {
930
938
  const coordinates = this._lRectangle.getCoordinates();
@@ -24,8 +24,8 @@
24
24
  :mapType="1" -->
25
25
  <template #marker="{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,7 +33,7 @@
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)"
@@ -45,11 +45,12 @@
45
45
  :src="src" text="个"
46
46
  fontColor="red"
47
47
  :fontSize="23"
48
+ :distance="200"
48
49
  :gpsType="gpsType"
49
50
  @callback="clusterCallback($event)"
50
51
  :map="mapDto.map"
51
52
  :modelArr="modelArr2"
52
- :offsetY="0"></ry-clusters-marker>
53
+ :offsetY="0"></ry-clusters-marker> -->
53
54
 
54
55
  </template>
55
56