|
@@ -80,7 +80,7 @@ import {defaults as defaultInteractions} from 'ol/interaction'
|
|
|
import Feature from 'ol/Feature'
|
|
|
import * as control from 'ol/control'
|
|
|
import {Style, Icon, Stroke} from 'ol/style'
|
|
|
-import {Vector as VectorSource} from 'ol/source'
|
|
|
+import {Cluster, Vector as VectorSource} from 'ol/source'
|
|
|
import TileSource from 'ol/source/TileWMS'
|
|
|
import XYZ from 'ol/source/XYZ'
|
|
|
import Overlay from 'ol/Overlay'
|
|
@@ -99,7 +99,7 @@ import more from '../assets/icon/more.svg'
|
|
|
import DrawShape from '../../static/js/startDrawShape'
|
|
|
|
|
|
// card
|
|
|
-import phoneCard from './card.vue'
|
|
|
+import phoneCard from './Card.vue'
|
|
|
|
|
|
// slogan
|
|
|
import slogan from './slogan.vue'
|
|
@@ -172,7 +172,7 @@ export default {
|
|
|
image: new Icon({
|
|
|
crossOrigin: 'anonymous',
|
|
|
src: more,
|
|
|
- scale: 0.25
|
|
|
+ scale: 0.15
|
|
|
})
|
|
|
}),
|
|
|
LineString: new Style({
|
|
@@ -282,20 +282,46 @@ export default {
|
|
|
interactions: defaultInteractions({
|
|
|
pinchRotate: false // 移动端禁止地图旋转
|
|
|
}),
|
|
|
+
|
|
|
view: new View({
|
|
|
center: center,
|
|
|
zoom: zoom,
|
|
|
extent: extent,
|
|
|
maxZoom: 18.5
|
|
|
}),
|
|
|
- // controls: control.defaults({
|
|
|
- // // zoom: false
|
|
|
- // }),
|
|
|
- controls: control.defaults().extend([
|
|
|
- new control.MousePosition()
|
|
|
- ])
|
|
|
+
|
|
|
+ controls: control.defaults({
|
|
|
+ zoom: false
|
|
|
+ })
|
|
|
+ // controls: control.defaults().extend([
|
|
|
+ // new control.MousePosition()
|
|
|
+ // ])
|
|
|
})
|
|
|
- map.updateSize()
|
|
|
+ setTimeout(function () { map.updateSize() })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description:开启聚合
|
|
|
+ */
|
|
|
+ addCluster: function (layerName, style) {
|
|
|
+ let layer = map.getLayers().array_
|
|
|
+ for (let i = 0; i < layer.length; i++) {
|
|
|
+ if (layer[i].className_ === layerName) {
|
|
|
+ var targetLayer = layer[i]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (targetLayer) {
|
|
|
+ let features = targetLayer.getSource().getFeatures()
|
|
|
+ let source = new VectorSource({
|
|
|
+ features: features
|
|
|
+ })
|
|
|
+ let clusterSource = new Cluster({
|
|
|
+ distance: 20,
|
|
|
+ source: source
|
|
|
+ })
|
|
|
+ targetLayer.setSource(clusterSource)
|
|
|
+ targetLayer.setStyle(style)
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -374,6 +400,7 @@ export default {
|
|
|
title: title,
|
|
|
class: 'layer',
|
|
|
className: title,
|
|
|
+ // extent: this.extent,
|
|
|
source: new VectorSource({
|
|
|
})
|
|
|
})
|
|
@@ -574,6 +601,7 @@ export default {
|
|
|
res.data.forEach(item => {
|
|
|
that.printFeature('reportLayer', item, 'report')
|
|
|
})
|
|
|
+ this.addCluster('reportLayer', this.reportStyles.Point)
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -592,6 +620,7 @@ export default {
|
|
|
res.data.forEach(item => {
|
|
|
that.printFeature('noticeLayer', item, 'notice')
|
|
|
})
|
|
|
+ this.addCluster('noticeLayer', this.noticeStyles.Point)
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -607,6 +636,7 @@ export default {
|
|
|
res.data.forEach(e => {
|
|
|
that.printFeature('cultureLayer', e, 'culture')
|
|
|
})
|
|
|
+ this.addCluster('cultureLayer', this.cultureStyles.Point)
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -621,6 +651,7 @@ export default {
|
|
|
res.data.forEach(e => {
|
|
|
that.printFeature('otherLayer', e, 'other')
|
|
|
})
|
|
|
+ this.addCluster('otherLayer', this.cultureStyles.Point)
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -855,42 +886,6 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- /**
|
|
|
- * @description:底图切换
|
|
|
- * @param {string} name:识别字符串
|
|
|
- */
|
|
|
- basemapChange: function (name) {
|
|
|
- switch (name) {
|
|
|
- case 'all':
|
|
|
- this.setMapVisible(['cdut', 'tiandi', 'tiandi-label'])
|
|
|
- break
|
|
|
- case 'cdut':
|
|
|
- this.setMapVisible(['cdut'])
|
|
|
- break
|
|
|
- case 'tiandi':
|
|
|
- this.setMapVisible(['tiandi', 'tiandi-label'])
|
|
|
- break
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * @description:设置图层可见性
|
|
|
- * @param {Array} titles:装有图层title的数组
|
|
|
- */
|
|
|
- setMapVisible: function (titles) {
|
|
|
- var layers = map.getLayers().array_
|
|
|
- for (var i = 0; i < layers.length; i++) {
|
|
|
- if (layers[i].values_.class !== 'basemap') {
|
|
|
- continue
|
|
|
- }
|
|
|
- if (titles.indexOf(layers[i].values_.title) > -1) {
|
|
|
- layers[i].setVisible(true)
|
|
|
- } else {
|
|
|
- layers[i].setVisible(false)
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
// LayerSelector related
|
|
|
// 底图选择 和 消息选择 的图层切换
|
|
|
getCheckedMap: function (checkMapList) {
|