Browse Source

地图

shibei_master
jiangyy 4 years ago
parent
commit
15d309730a
  1. 6
      src/views/modules/communityParty/regionalParty/finishList.vue
  2. 115
      src/views/modules/visual/basicinfo/basicInfoMain.vue
  3. 114
      src/views/modules/workSys/mapConfig.vue

6
src/views/modules/communityParty/regionalParty/finishList.vue

@ -258,9 +258,13 @@ export default {
}
this.monthlist = []
for (let i = 1; i < 13; i++) {
let m = i
if (m < 10) {
m = '0' + m
}
let obj = {
label: i + '月',
value: i + '',
value: m,
}
this.monthlist.push(obj)

115
src/views/modules/visual/basicinfo/basicInfoMain.vue

@ -121,6 +121,8 @@ let loading;//加载动画
let map;
let mapView;
let gaodeMapLayer;//
let parentLayer;//
let parentSource;//
let polygonLayer;//
let iconLayer; // icon
let iconSource; // icon
@ -167,8 +169,25 @@ var createTextStyle = function (feature) {
});
};
//
//
var parentStyleFunction = (function () {
return function (feature) {
return new Style({
// fill: new Fill({
// color: [255, 255, 255, 0.3]
// }),
stroke: new Stroke({
color: [0, 103, 182, 1],
width: 2
}),
// text: createTextStyle(feature)
});;
};
})()
//
var polygonStyleFunction = (function () {
return function (feature) {
return new Style({
@ -216,6 +235,7 @@ const vueGis = {
selUserId: '',
center: [],
zoom: null,
parentPolygon: [],
}
@ -227,7 +247,8 @@ const vueGis = {
//
this.initMap()
this.addParentLayer()
this.loadParentPolygon()
//
this.addPolygonLayer()
@ -365,16 +386,17 @@ const vueGis = {
//
await this.loadOrgData()
this.loadParentPolygon()
//
await this.loadPolygon(this.subAgencyArray)
//
if (isRefreshView) {
this.setMapLocation()
mapView.setCenter(this.centerPoint);
mapView.setZoom(this.zoom);
}
// //
// if (isRefreshView) {
// this.setMapLocation()
// mapView.setCenter(this.centerPoint);
// mapView.setZoom(this.zoom);
// }
await this.loadList()
@ -431,7 +453,8 @@ const vueGis = {
this.orgData = data
this.orgId = this.orgData.id
this.orgLevel = this.orgData.level
this.parentPolygon = []
this.parentPolygon.push(data)
if (data.children && data.children.length > 0) {
this.subAgencyArray = data.children
} else {
@ -444,6 +467,63 @@ const vueGis = {
},
//
loadParentPolygon () {
parentSource.clear()//
let featureData = []//
if (this.parentPolygon && this.parentPolygon.length > 0) {//
let oneData = {}
this.parentPolygon.forEach(agencyItem => {
if (agencyItem.coordinates && agencyItem.coordinates !== '') {//
oneData = {
type: 'Feature',
id: agencyItem.id,
properties: {
id: agencyItem.id,
level: agencyItem.level,
name: agencyItem.name
},
geometry: {
type: 'Polygon',
coordinates: [],
},
}
let coorArray = agencyItem.coordinates.split(',')//
let itemArray = []//[lon,lat]
let polygonArray = []//[[lon,lat],[lon,lat],[lon,lat]]
coorArray.forEach((item, index) => {
itemArray.push(item)
if (index % 2 == 0) {//
} else {//
polygonArray.push(itemArray)
itemArray = []
}
});
oneData.geometry.coordinates.push(polygonArray)
featureData.push(oneData)
}
});
}
if (featureData && featureData.length > 0) {
var geojsonObject = {
'type': 'FeatureCollection',
'features': featureData
};
let feature = (new GeoJSON()).readFeatures(geojsonObject)
parentSource.addFeatures(feature)
}
},
//
loadPolygon (subAgencyArray) {
polygonSource.clear()//
@ -626,6 +706,23 @@ const vueGis = {
});
map.removeInteraction(dblClickInteraction);
},
//
addParentLayer () {
parentSource = new VectorSource({
//features: (new GeoJSON()).readFeatures(geojsonObject)
});
parentLayer = new VectorLayer({
source: parentSource,
style: parentStyleFunction,
zIndex: 50
});
map.addLayer(parentLayer)
},
//

114
src/views/modules/workSys/mapConfig.vue

@ -83,6 +83,8 @@ let projection = new Projection({
let map;
let mapView;
let gaodeMapLayer;//
let parentLayer;//
let parentSource;//
let polygonLayer;//
let polygonSource;//
@ -106,7 +108,22 @@ var createTextStyle = function (feature) {
overflow: true,
});
};
//
//
var parentStyleFunction = (function () {
return function (feature) {
return new Style({
// fill: new Fill({
// color: [255, 255, 255, 0.3]
// }),
stroke: new Stroke({
color: [0, 103, 182, 1],
width: 2
}),
// text: createTextStyle(feature)
});;
};
})()
var polygonStyleFunction = (function () {
return function (feature) {
@ -153,6 +170,7 @@ const vueGis = {
runAgency: [],
center: [],
zoom: null,
parentPolygon: [],
}
},
@ -164,6 +182,10 @@ const vueGis = {
//
this.initMap()
//
this.addParentLayer()
this.loadParentPolygon()
//
this.addPolygonLayer()
@ -199,16 +221,16 @@ const vueGis = {
async refreshMap (isRefreshView) {
//
await this.loadOrgData()
this.loadParentPolygon()
//
this.loadPolygon(this.subAgencyArray)
//
if (isRefreshView) {
this.setMapLocation()
mapView.setCenter(this.centerPoint);
mapView.setZoom(this.zoom);
}
// if (isRefreshView) {
// this.setMapLocation()
// mapView.setCenter(this.centerPoint);
// mapView.setZoom(this.zoom);
// }
},
//
@ -250,6 +272,8 @@ const vueGis = {
this.subAgencyArray.push(data)
// this.selAgencyId = data.id
} else {
this.parentPolygon = []
this.parentPolygon.push(data)
if (data.children && data.children.length > 0) {
this.subAgencyArray = data.children
@ -266,6 +290,62 @@ const vueGis = {
},
//
loadParentPolygon () {
parentSource.clear()//
let featureData = []//
if (this.parentPolygon && this.parentPolygon.length > 0) {//
let oneData = {}
this.parentPolygon.forEach(agencyItem => {
if (agencyItem.coordinates && agencyItem.coordinates !== '') {//
oneData = {
type: 'Feature',
id: agencyItem.id,
properties: {
id: agencyItem.id,
level: agencyItem.level,
name: agencyItem.name
},
geometry: {
type: 'Polygon',
coordinates: [],
},
}
let coorArray = agencyItem.coordinates.split(',')//
let itemArray = []//[lon,lat]
let polygonArray = []//[[lon,lat],[lon,lat],[lon,lat]]
coorArray.forEach((item, index) => {
itemArray.push(item)
if (index % 2 == 0) {//
} else {//
polygonArray.push(itemArray)
itemArray = []
}
});
oneData.geometry.coordinates.push(polygonArray)
featureData.push(oneData)
}
});
}
if (featureData && featureData.length > 0) {
var geojsonObject = {
'type': 'FeatureCollection',
'features': featureData
};
let feature = (new GeoJSON()).readFeatures(geojsonObject)
parentSource.addFeatures(feature)
}
},
//
loadPolygon (subAgencyArray) {
polygonSource.clear()//
@ -348,6 +428,7 @@ const vueGis = {
}
if (this.method != 'mAddPolygon' && this.level != 'neighborHood') {
this.selAgencyId = ''
//
this.subAgencyArray.forEach(item => {
@ -366,6 +447,7 @@ const vueGis = {
console.log('center', map.getView().getCenter())
console.log('zoom', map.getView().getZoom())
this.runAgency.push(this.selPolygon)
this.selAgencyIndex = 0
this.refreshMap(true)
@ -373,7 +455,6 @@ const vueGis = {
}
},
//
highlightPolygon () {
@ -467,6 +548,23 @@ const vueGis = {
},
//
addParentLayer () {
parentSource = new VectorSource({
//features: (new GeoJSON()).readFeatures(geojsonObject)
});
parentLayer = new VectorLayer({
source: parentSource,
style: parentStyleFunction,
zIndex: 50
});
map.addLayer(parentLayer)
},
//
addPolygonLayer () {
polygonSource = new VectorSource({

Loading…
Cancel
Save