|
@@ -1,13 +1,15 @@
|
|
|
import { GeoJSON } from 'ol/format'
|
|
|
import { fromLonLat } from 'ol/proj'
|
|
|
-import { Vector as SourceVector } from 'ol/source'
|
|
|
-import { Vector as LayerVector } from 'ol/layer'
|
|
|
+import { Vector as VectorySource } from 'ol/source'
|
|
|
+import { Vector as VectoryLayer } from 'ol/layer'
|
|
|
import { getCenter, boundingExtent } from 'ol/extent'
|
|
|
import Overlay from 'ol/Overlay'
|
|
|
import { Select, Pointer, Draw, Modify, Snap, Translate } from 'ol/interaction'
|
|
|
import { createRegularPolygon, createBox } from 'ol/interaction/Draw'
|
|
|
import { Style, Fill, Stroke, Circle } from 'ol/style'
|
|
|
import Feature from 'ol/Feature'
|
|
|
+import { Polygon, MultiPolygon } from 'ol/geom';
|
|
|
+import { fromExtent } from 'ol/geom/Polygon';
|
|
|
import {
|
|
|
Logo,
|
|
|
TileSuperMapRest,
|
|
@@ -47,39 +49,64 @@ export default {
|
|
|
defaultExpand: true,
|
|
|
resourceCheckedKey: [],
|
|
|
selectCount: 0,
|
|
|
- chart: null
|
|
|
+ chart: null,
|
|
|
+ vectorLayer: null,
|
|
|
+ overlays: []
|
|
|
}
|
|
|
},
|
|
|
- created() {},
|
|
|
+ created() { },
|
|
|
computed: {},
|
|
|
watch: {
|
|
|
- statisticMode(nextvalue, preValue) {
|
|
|
- nextvalue == '1'
|
|
|
- ? (this.titleCondition = '条件筛选')
|
|
|
- : (this.titleCondition = '区域绘制类型选择')
|
|
|
- this.selectFeatures = []
|
|
|
- this.removeInteraction()
|
|
|
- },
|
|
|
drawType(nextvalue, preValue) {
|
|
|
- nextvalue == '1'
|
|
|
- ? this.initDrawHandler('Square')
|
|
|
- : this.initDrawHandler('Polygon')
|
|
|
+ if (!nextvalue) return
|
|
|
+ this.selectFeatures = []
|
|
|
+ this.initDrawHandler(nextvalue == 1 ? 'Square' : 'Polygon')
|
|
|
},
|
|
|
selectRegion(nextvalue, preValue) {
|
|
|
+ if (!nextvalue) return
|
|
|
+ this.selectFeatures = []
|
|
|
let feature = this.regions.find(item => item.regionCode == nextvalue)
|
|
|
- if (feature && feature.feature) this.highLightFeature(feature.feature)
|
|
|
- this.queryBulidNumByRegion(nextvalue)
|
|
|
+ const geo = new GeoJSON().readGeometry(feature.feature.geometry)
|
|
|
+ this.drawArea(geo)
|
|
|
+ if (feature && feature.feature) this.flyToFeature(feature.feature, null)
|
|
|
+ console.log(new GeoJSON().readFeature(feature.feature));
|
|
|
+ this.queryBulidNumByFeature(new Feature({ geometry: geo }))
|
|
|
+ },
|
|
|
+ statisticMode(val, oldVal) {
|
|
|
+ this.selectFeatures = []
|
|
|
+ if (this.drawTool) this.map.removeInteraction(this.drawTool)
|
|
|
+ this.vectorLayer.getSource().clear()
|
|
|
+ this.selectRegion = null
|
|
|
+ this.drawType = null
|
|
|
+ this.clearOverlays()
|
|
|
}
|
|
|
},
|
|
|
destroyed() {
|
|
|
- this.removeInteraction()
|
|
|
- this.clearSource()
|
|
|
+ if (this.vectorLayer) this.map.removeLayer(this.vectorLayer)
|
|
|
+ if (this.drawTool) this.map.removeInteraction(this.drawTool)
|
|
|
this.clearOverlays()
|
|
|
},
|
|
|
mounted() {
|
|
|
this.config = this.data.that.config
|
|
|
this.map = this.data.that.map
|
|
|
this.chart = this.$refs.chart
|
|
|
+
|
|
|
+ this.vectorLayer = new VectoryLayer({
|
|
|
+ source: new VectorySource(),
|
|
|
+ style: new Style({
|
|
|
+
|
|
|
+ fill: new Fill({
|
|
|
+ color: 'rgba(255, 255, 255)'
|
|
|
+ }),
|
|
|
+
|
|
|
+ stroke: new Stroke({
|
|
|
+ color: '#4e71f2',
|
|
|
+ lineDash: [3, 4, 3, 4],
|
|
|
+ width: 3,
|
|
|
+ }),
|
|
|
+ })
|
|
|
+ })
|
|
|
+ this.map.addLayer(this.vectorLayer)
|
|
|
this.queryRegionServer()
|
|
|
this.getSecurityLevel()
|
|
|
},
|
|
@@ -94,7 +121,6 @@ export default {
|
|
|
let useLayers = layers.filter(item => {
|
|
|
return item.get('securityClass') && item.getVisible()
|
|
|
})
|
|
|
- console.log('筛选图层:', useLayers)
|
|
|
let securityLeves = useLayers.map(item => {
|
|
|
return parseInt(item.get('securityClass'))
|
|
|
})
|
|
@@ -108,45 +134,35 @@ export default {
|
|
|
},
|
|
|
|
|
|
* 查询所有行政区划数据
|
|
|
- * @id 行政区ID
|
|
|
*/
|
|
|
- queryRegionServer(id) {
|
|
|
- let attributeFilter = '1=1'
|
|
|
- if (id) {
|
|
|
- attributeFilter = 'AREANUMBER = ' + id
|
|
|
- }
|
|
|
+ queryRegionServer() {
|
|
|
if (!this.config) return
|
|
|
|
|
|
let url = this.config.iServerUrl.basicGISDataServer.url
|
|
|
- if (!url || url == '') {
|
|
|
- this.$message(
|
|
|
- 'info',
|
|
|
- '请在配置文件中配置行政区划数据服务在map.config.js下的iServerUrl下面'
|
|
|
- )
|
|
|
+ if (!url) {
|
|
|
+ this.$message.error('未找到行政区服务配置,请联系管理员查看配置是否有误或无权限!')
|
|
|
return
|
|
|
}
|
|
|
let dataSet = this.config.iServerUrl.basicGISDataServer.dataSetInfo.find(
|
|
|
dataSetinfo => dataSetinfo.label == '区域'
|
|
|
)
|
|
|
- if (!dataSet || !dataSet.name) return
|
|
|
- let queryName =
|
|
|
- dataSet.name +
|
|
|
- '@' +
|
|
|
- this.config.iServerUrl.basicGISDataServer.dataSource
|
|
|
- let datasetNames =
|
|
|
- this.config.iServerUrl.basicGISDataServer.dataSource +
|
|
|
- ':' +
|
|
|
- dataSet.name
|
|
|
+ if (!dataSet || !dataSet.name) {
|
|
|
+ this.$message.error('未找到行政区服务配置,请联系管理员查看配置是否有误或无权限!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let queryName = `${dataSet.name}@${this.config.iServerUrl.basicGISDataServer.dataSource}`
|
|
|
+ let datasetName = `${this.config.iServerUrl.basicGISDataServer.dataSource}:${dataSet.name}`
|
|
|
|
|
|
var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
|
|
|
- queryParameter: {
|
|
|
- name: queryName,
|
|
|
- attributeFilter: attributeFilter
|
|
|
- },
|
|
|
- datasetNames: [datasetNames]
|
|
|
+ queryParameter: { name: queryName },
|
|
|
+ datasetNames: [datasetName]
|
|
|
})
|
|
|
|
|
|
new FeatureService(url).getFeaturesBySQL(sqlParam, serviceResult => {
|
|
|
+ if (serviceResult.type == 'processFailed') {
|
|
|
+ this.$message.error('查询行政区数据失败!')
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
if (serviceResult.result.features) {
|
|
|
let features = serviceResult.result.features.features
|
|
@@ -182,37 +198,9 @@ export default {
|
|
|
* @drawType String 绘制类型(Point、LineString、Polygon、Circle,Square,Box)
|
|
|
*/
|
|
|
initDrawHandler(drawType) {
|
|
|
- this.removeInteraction()
|
|
|
-
|
|
|
- if (this.vectorSource) {
|
|
|
- this.vectorSource.clear()
|
|
|
- console.log('清理已绘制图形....', drawType)
|
|
|
- }
|
|
|
- console.log('开始编辑图形数据....')
|
|
|
- let feature = null
|
|
|
- this.vectorSource = new SourceVector({ wrapX: false })
|
|
|
- let vectorLayer = new LayerVector({
|
|
|
- source: this.vectorSource,
|
|
|
- style: new Style({
|
|
|
-
|
|
|
- fill: new Fill({
|
|
|
- color: 'rgba(255, 255, 255, 0.2)'
|
|
|
- }),
|
|
|
-
|
|
|
- stroke: new Stroke({
|
|
|
- color: '#1E90FF',
|
|
|
- width: 3
|
|
|
- }),
|
|
|
-
|
|
|
- image: new Circle({
|
|
|
- radius: 7,
|
|
|
- fill: new Fill({
|
|
|
- color: '#ffcc33'
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
- this.map.addLayer(vectorLayer)
|
|
|
+ if (this.drawTool) this.map.removeInteraction(this.drawTool)
|
|
|
+ this.vectorLayer.getSource().clear()
|
|
|
+
|
|
|
let geometryFunction = null
|
|
|
let maxPoint
|
|
|
|
|
@@ -226,7 +214,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
this.drawTool = new Draw({
|
|
|
- source: this.vectorSource,
|
|
|
+ source: this.vectorLayer.getSource(),
|
|
|
wrapX: false,
|
|
|
maxPoints: maxPoint,
|
|
|
type: drawType,
|
|
@@ -234,17 +222,17 @@ export default {
|
|
|
})
|
|
|
this.drawTool.on('drawstart', evt => {
|
|
|
|
|
|
- if (this.vectorSource) {
|
|
|
- this.vectorSource.clear()
|
|
|
- console.log('清理已绘制图形....')
|
|
|
- }
|
|
|
- feature = evt.feature
|
|
|
+ this.vectorLayer.getSource().clear()
|
|
|
+
|
|
|
})
|
|
|
- this.drawTool.on('drawend', () => {
|
|
|
- let geometry = feature.getGeometry()
|
|
|
- this.drawFeature = feature
|
|
|
-
|
|
|
- this.queryBulidNumByFeature(this.drawFeature)
|
|
|
+ this.drawTool.on('drawend', evt => {
|
|
|
+ this.drawType = null
|
|
|
+ this.map.removeInteraction(this.drawTool)
|
|
|
+ setTimeout(() => {
|
|
|
+ this.drawArea(evt.feature.getGeometry())
|
|
|
+ this.flyToFeature(null, evt.feature.getGeometry())
|
|
|
+ this.queryBulidNumByFeature(evt.feature)
|
|
|
+ }, 100);
|
|
|
})
|
|
|
this.map.addInteraction(this.drawTool)
|
|
|
},
|
|
@@ -255,32 +243,36 @@ export default {
|
|
|
*/
|
|
|
queryBulidNumByFeature(feature) {
|
|
|
let url = this.config.iServerUrl.publicHouseDataServer.url
|
|
|
- if (!url || url == '') {
|
|
|
- this.$message(
|
|
|
- 'info',
|
|
|
- '请在配置文件中配置楼建筑服务在map.config.js下的iServerUrl下面'
|
|
|
- )
|
|
|
+ if (!url) {
|
|
|
+ this.$message.error('未找到公房服务配置,请联系管理员查看配置是否有误或无权限!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let datasetNames = []
|
|
|
+ this.config.iServerUrl.publicHouseDataServer.houseDataSets.forEach(item => {
|
|
|
+ datasetNames.push(`${this.config.iServerUrl.publicHouseDataServer.dataSource}:${item.name}`)
|
|
|
+ });
|
|
|
+ if (datasetNames.length == 0) {
|
|
|
+ this.$message.error('未找到公房服务配置,请联系管理员查看配置是否有误或无权限!')
|
|
|
return
|
|
|
}
|
|
|
- let datasetName =
|
|
|
- this.config.iServerUrl.publicHouseDataServer.dataSource +
|
|
|
- ':' +
|
|
|
- this.config.iServerUrl.publicHouseDataServer.dataSetBataSet
|
|
|
|
|
|
let polygon = feature.getGeometry()
|
|
|
|
|
|
- let boundsParam = new SuperMap.GetFeaturesByBoundsParameters({
|
|
|
- datasetNames: [datasetName],
|
|
|
- bounds: polygon.getExtent()
|
|
|
+ let geometryParameters = new SuperMap.GetFeaturesByGeometryParameters({
|
|
|
+ datasetNames: datasetNames,
|
|
|
+ geometry: polygon,
|
|
|
+ spatialQueryMode: "CONTAIN"
|
|
|
})
|
|
|
- new FeatureService(url).getFeaturesByBounds(
|
|
|
- boundsParam,
|
|
|
- serviceResult => {
|
|
|
- if (serviceResult.result.features) {
|
|
|
- let features = serviceResult.result.features.features
|
|
|
- this.getBulidStatistic(features, null)
|
|
|
- }
|
|
|
+ new FeatureService(url).getFeaturesByGeometry(geometryParameters, serviceResult => {
|
|
|
+ if (serviceResult.type == 'processFailed') {
|
|
|
+ this.$message.error('查询数据集失败!')
|
|
|
+ return
|
|
|
}
|
|
|
+ if (serviceResult.result.features) {
|
|
|
+ let features = serviceResult.result.features.features
|
|
|
+ this.getBulidStatistic(features, null)
|
|
|
+ }
|
|
|
+ }
|
|
|
)
|
|
|
},
|
|
|
|
|
@@ -288,49 +280,57 @@ export default {
|
|
|
* 根据行政区划查询楼房幢号
|
|
|
* @regionCode 行政区编号
|
|
|
*/
|
|
|
- queryBulidNumByRegion(regionCode) {
|
|
|
- if (regionCode) {
|
|
|
- let attributeFilter = 'AREANUMBER = ' + regionCode
|
|
|
- if (!this.config) return
|
|
|
-
|
|
|
- let url = this.config.iServerUrl.publicHouseDataServer.url
|
|
|
- if (!url || url == '') {
|
|
|
- this.$message(
|
|
|
- 'info',
|
|
|
- '请在配置文件中配置楼建筑服务在map.config.js下的iServerUrl下面'
|
|
|
- )
|
|
|
- return
|
|
|
- }
|
|
|
- let dataSet = this.config.iServerUrl.publicHouseDataServer.dataSetInfo.find(
|
|
|
- dataSetInfo => dataSetInfo.label == '公房'
|
|
|
- )
|
|
|
- if (!dataSet || !dataSet.name) return
|
|
|
- let queryName =
|
|
|
- dataSet.name +
|
|
|
- '@' +
|
|
|
- this.config.iServerUrl.publicHouseDataServer.dataSource
|
|
|
- let datasetNames =
|
|
|
- this.config.iServerUrl.publicHouseDataServer.dataSource +
|
|
|
- ':' +
|
|
|
- dataSet.name
|
|
|
-
|
|
|
- var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
|
|
|
- queryParameter: {
|
|
|
- name: queryName,
|
|
|
- attributeFilter: attributeFilter
|
|
|
- },
|
|
|
- datasetNames: [datasetNames]
|
|
|
- })
|
|
|
-
|
|
|
- new FeatureService(url).getFeaturesBySQL(sqlParam, serviceResult => {
|
|
|
-
|
|
|
- if (serviceResult.result.features) {
|
|
|
- let features = serviceResult.result.features.features
|
|
|
- this.getBulidStatistic(features, regionCode)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
* 初始化幢号楼房显示结果
|
|
@@ -386,29 +386,14 @@ export default {
|
|
|
},
|
|
|
|
|
|
checkChange(data, checked) {
|
|
|
-
|
|
|
- this.treeNodeSelectData = this.$refs.featureTree.getCheckedNodes()
|
|
|
- if (this.treeNodeSelectData.length == 0) this.selectCount = 0
|
|
|
-
|
|
|
- let flag = false
|
|
|
- let nodeSelectData = []
|
|
|
- this.treeNodeSelectData.forEach(treeNode => {
|
|
|
- if (treeNode.hasOwnProperty('children')) flag = true
|
|
|
- else {
|
|
|
- nodeSelectData.push(treeNode)
|
|
|
- }
|
|
|
+ let treeNodeSelectData = this.$refs.featureTree.getCheckedNodes()
|
|
|
+ console.log("OOPP", data, checked, treeNodeSelectData);
|
|
|
+ this.clearOverlays()
|
|
|
+
|
|
|
+ const nodes = treeNodeSelectData.filter(item => {
|
|
|
+ return !item.hasOwnProperty('children')
|
|
|
})
|
|
|
- if (flag) {
|
|
|
- this.selectCount = this.selectCount + 1
|
|
|
- if (this.selectCount == this.treeNodeSelectData.length) {
|
|
|
- this.getBuildNumArr(nodeSelectData)
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.getBuildNumArr(nodeSelectData)
|
|
|
- }
|
|
|
- if (!checked && this.treeNodeSelectData.length > 0) {
|
|
|
- this.selectCount = this.selectCount - 1
|
|
|
- }
|
|
|
+ this.getBuildNumArr(nodes)
|
|
|
},
|
|
|
|
|
|
|
|
@@ -439,9 +424,7 @@ export default {
|
|
|
.catch(msg => {
|
|
|
this.$message('查询失败!失败原因:' + msg)
|
|
|
})
|
|
|
- .finally(() => {
|
|
|
- console.log('调用完成!')
|
|
|
- })
|
|
|
+ .finally(() => { })
|
|
|
},
|
|
|
|
|
|
|
|
@@ -453,7 +436,6 @@ export default {
|
|
|
*/
|
|
|
getEchartData(records, treeNodes) {
|
|
|
let echartData = treeNodes
|
|
|
- console.log('ddddddd', records, treeNodes)
|
|
|
if (!treeNodes || treeNodes.length < 1) return []
|
|
|
if (records && records.length > 0) {
|
|
|
}
|
|
@@ -498,7 +480,6 @@ export default {
|
|
|
*/
|
|
|
showThemic(records, treeNodes) {
|
|
|
let echartData = this.getEchartData(records, treeNodes)
|
|
|
- console.log('输出情况:', echartData)
|
|
|
this.clearOverlays()
|
|
|
for (let i = 0; i < echartData.length; i++) {
|
|
|
|
|
@@ -531,7 +512,7 @@ export default {
|
|
|
},
|
|
|
itemStyle: {
|
|
|
normal: {
|
|
|
- color: function(params) {
|
|
|
+ color: function (params) {
|
|
|
|
|
|
var colorList = ['red', 'green']
|
|
|
return colorList[params.dataIndex]
|
|
@@ -551,7 +532,7 @@ export default {
|
|
|
fontSize: 10,
|
|
|
itemStyle: {
|
|
|
normal: {
|
|
|
- color: function(params) {
|
|
|
+ color: function (params) {
|
|
|
|
|
|
var colorList = ['#FE8463', '#FAC858', '#91CC75']
|
|
|
return colorList[params.dataIndex]
|
|
@@ -568,14 +549,14 @@ export default {
|
|
|
}
|
|
|
myChart.setOption(option)
|
|
|
siteDiv.onclick = () => {
|
|
|
- console.log('parm', echartData[i])
|
|
|
+
|
|
|
}
|
|
|
const lonlat = [
|
|
|
parseFloat(echartData[i].x),
|
|
|
parseFloat(echartData[i].y)
|
|
|
]
|
|
|
-
|
|
|
- let marker = new Overlay({
|
|
|
+
|
|
|
+ let overlay = new Overlay({
|
|
|
id: domid,
|
|
|
position: lonlat,
|
|
|
positioning: 'center',
|
|
@@ -583,28 +564,67 @@ export default {
|
|
|
stopEvent: false,
|
|
|
offset: [-90, -70]
|
|
|
})
|
|
|
- this.map.addOverlay(marker)
|
|
|
+ this.map.addOverlay(overlay)
|
|
|
+ this.overlays.push(overlay)
|
|
|
}
|
|
|
},
|
|
|
|
|
|
guid() {
|
|
|
|
|
|
- var d = new Date().getTime()
|
|
|
- var guid = 'xxxx-xxxx-xxxx-xxxx'.replace(/[xy]/g, function(c) {
|
|
|
- var r = (d + Math.random() * 16) % 16 | 0
|
|
|
+ let d = new Date().getTime()
|
|
|
+ let guid = 'xxxx-xxxx-xxxx-xxxx'.replace(/[xy]/g, function (c) {
|
|
|
+ let r = (d + Math.random() * 16) % 16 | 0
|
|
|
d = Math.floor(d / 16)
|
|
|
return (c == 'x' ? r : (r & 0x7) | 0x8).toString(16)
|
|
|
})
|
|
|
return guid
|
|
|
},
|
|
|
+
|
|
|
+ * 只显示目标区域
|
|
|
+ */
|
|
|
+ drawArea(geometry) {
|
|
|
+ let coordinates = null
|
|
|
+ if (geometry instanceof MultiPolygon) {
|
|
|
+ coordinates = geometry.getCoordinates()[0]
|
|
|
+ } else if (geometry instanceof Polygon) {
|
|
|
+ coordinates = geometry.getCoordinates()
|
|
|
+ }
|
|
|
+ if (!coordinates) return
|
|
|
+ let linearRing = new Polygon(coordinates);
|
|
|
+ let extent = this.map.getView().calculateExtent();
|
|
|
+ for (let i = 0; i < extent.length; i++) {
|
|
|
+ extent[0] = extent[0] - 0.04
|
|
|
+ extent[1] = extent[1] - 0.04
|
|
|
+ extent[2] = extent[2] + 0.04
|
|
|
+ extent[3] = extent[3] + 0.04
|
|
|
+ }
|
|
|
+ let polygonRing = fromExtent(extent);
|
|
|
+ polygonRing.appendLinearRing(linearRing);
|
|
|
+ let polygonsFeature = new Feature({
|
|
|
+ geometry: polygonRing
|
|
|
+ });
|
|
|
+ polygonsFeature.setStyle(new Style({
|
|
|
+ fill: new Fill({
|
|
|
+ color: 'rgba(255, 255, 255)'
|
|
|
+ }),
|
|
|
+
|
|
|
+ stroke: new Stroke({
|
|
|
+ color: '#4e71f2',
|
|
|
+ lineDash: [3, 4, 3, 4],
|
|
|
+ width: 3,
|
|
|
+ })
|
|
|
+ }))
|
|
|
+ this.vectorLayer.getSource().clear()
|
|
|
+ this.vectorLayer.getSource().addFeature(polygonsFeature)
|
|
|
+ },
|
|
|
|
|
|
|
|
|
* 导出地图图片
|
|
|
*/
|
|
|
pdfExport() {
|
|
|
- this.map.once('postcompose', function(event) {
|
|
|
+ this.map.once('postcompose', function (event) {
|
|
|
let canvas = event.context.canvas
|
|
|
- canvas.toBlob(function(blob) {
|
|
|
+ canvas.toBlob(function (blob) {
|
|
|
saveAs(blob, 'map.png')
|
|
|
})
|
|
|
})
|
|
@@ -640,81 +660,27 @@ export default {
|
|
|
* 点击树节点事件
|
|
|
*/
|
|
|
handleNodeClick(data) {
|
|
|
- if (data && data.hasOwnProperty('feature')) {
|
|
|
- console.log('结点点击事件:', data)
|
|
|
- }
|
|
|
+
|
|
|
},
|
|
|
|
|
|
|
|
|
- * 高亮显示
|
|
|
+ * 定位显示
|
|
|
* @features 要素
|
|
|
*/
|
|
|
- highLightFeature(features) {
|
|
|
- let geometry = features.geometry
|
|
|
+ flyToFeature(jsonFeature = null, geometry) {
|
|
|
let feature = new Feature({
|
|
|
- geometry: new GeoJSON().readGeometry(geometry)
|
|
|
- })
|
|
|
- this.clearSource()
|
|
|
- this.queryVectorSource = new SourceVector({
|
|
|
- features: new GeoJSON().readFeatures(features),
|
|
|
- wrapX: false
|
|
|
- })
|
|
|
- this.queryResultLayer = new LayerVector({
|
|
|
- source: this.queryVectorSource,
|
|
|
- style: new Style({
|
|
|
-
|
|
|
- fill: new Fill({
|
|
|
- color: 'rgba(255, 255, 255, 0.2)'
|
|
|
- }),
|
|
|
-
|
|
|
- stroke: new Stroke({
|
|
|
- color: '#1E90FF',
|
|
|
- width: 3
|
|
|
- }),
|
|
|
-
|
|
|
- image: new Circle({
|
|
|
- radius: 5,
|
|
|
- fill: new Fill({
|
|
|
- color: '#ffcc33'
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
+ geometry: jsonFeature ? new GeoJSON().readGeometry(jsonFeature.geometry) : geometry
|
|
|
})
|
|
|
- this.map.addLayer(this.queryResultLayer)
|
|
|
setTimeout(() => {
|
|
|
- this.map
|
|
|
- .getView()
|
|
|
- .fit(feature.getGeometry().getExtent(), { duration: 600 })
|
|
|
+ this.map.getView().fit(feature.getGeometry().getExtent(), { duration: 600 })
|
|
|
}, 200)
|
|
|
},
|
|
|
|
|
|
- queryStatistic() {},
|
|
|
-
|
|
|
-
|
|
|
- * 移除清理
|
|
|
- */
|
|
|
- removeInteraction() {
|
|
|
- this.drawFeature = null
|
|
|
- if (this.drawTool) {
|
|
|
- this.map.removeInteraction(this.drawTool)
|
|
|
- }
|
|
|
- if (this.vectorSource) {
|
|
|
- this.vectorSource.clear()
|
|
|
- }
|
|
|
- this.clearSource()
|
|
|
- },
|
|
|
|
|
|
clearOverlays() {
|
|
|
- this.map.getOverlays().clear()
|
|
|
+ this.overlays.forEach(overlay => {
|
|
|
+ this.map.removeOverlay(overlay)
|
|
|
+ });
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
- * 清理区县要素类图形
|
|
|
- */
|
|
|
- clearSource() {
|
|
|
- if (this.queryVectorSource) {
|
|
|
- this.queryVectorSource.clear()
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|