|
@@ -64,7 +64,11 @@ export default {
|
|
|
putPolygonData: [],
|
|
|
townPolygons: [],
|
|
|
treeCompMarkers: [],
|
|
|
- forestFarmData: []
|
|
|
+ forestFarmData: [],
|
|
|
+ districtList: [],
|
|
|
+ selectData: {},
|
|
|
+ districtData: {},
|
|
|
+ streetData: {}
|
|
|
};
|
|
|
},
|
|
|
|
|
@@ -75,9 +79,9 @@ export default {
|
|
|
watch: {
|
|
|
'$store.state.addr.parentId': {
|
|
|
handler(val) {
|
|
|
- if (this.$store.state.addr.smallClassSearch) {
|
|
|
-
|
|
|
- }
|
|
|
+ this.selectData = this.$store.state.addr.selectCity;
|
|
|
+ this.districtData = this.$store.state.addr.selectDistrict;
|
|
|
+ this.streetData = this.$store.state.addr.selectStreet;
|
|
|
if (this.map) {
|
|
|
this.parentId = val;
|
|
|
this.switch2AreaNode(
|
|
@@ -96,13 +100,13 @@ export default {
|
|
|
'$store.state.addr.page': {
|
|
|
handler(val) {
|
|
|
this.leftPage = val;
|
|
|
- console.log(this.parentId);
|
|
|
+ console.losmallClassMapArr(this.parentId);
|
|
|
if (this.parentId) {
|
|
|
// this.getrjx()
|
|
|
this.switch2AreaNode(
|
|
|
this.parentId,
|
|
|
this.$store.state.addr.mapLevel,
|
|
|
- this.$store.state.addr.selectCity,
|
|
|
+ this.$store.state.addr.selectStreet,
|
|
|
this.leftPage
|
|
|
);
|
|
|
this.getDistrict(
|
|
@@ -112,79 +116,31 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- '$store.state.addr.smallClassMapArr'(val) {
|
|
|
- console.log(val);
|
|
|
- if (this.map) {
|
|
|
- if (val.code == 200) {
|
|
|
- // this.smallClassMapArr = [];
|
|
|
- this.smallClassMapArr = val.rows;
|
|
|
- console.log(val.rows);
|
|
|
- // smallClassPolygon
|
|
|
- // this.map.setLayers(this.smallClassPolygon);
|
|
|
+ '$store.state.addr.smallClassMapArr': {
|
|
|
+ deep: true,
|
|
|
+ immediate: true,
|
|
|
+ handler(val) {
|
|
|
+ console.log(val);
|
|
|
+ this.smallClassMapArr = val.rows;
|
|
|
+ if (this.smallClassMapArr) {
|
|
|
if (this.$store.state.addr.mapLevel === 'district') {
|
|
|
if (this.leftPage === 'forest') {
|
|
|
- this.addForestPolygon();
|
|
|
+ this.addForestPolygon(this.smallClassMapArr);
|
|
|
} else if (this.leftPage === 'treeSpecies') {
|
|
|
- this.addTreeSpeciesPolygon();
|
|
|
+ this.addTreeSpeciesPolygon(this.smallClassMapArr);
|
|
|
} else if (this.leftPage === 'event') {
|
|
|
- this.getEven();
|
|
|
+ this.getEven(this.smallClassMapArr);
|
|
|
} else if (this.leftPage === 'economics') {
|
|
|
- this.getEconomics();
|
|
|
+ this.getEconomics(this.smallClassMapArr);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
- // '$store.state.addr.smallClassSearch': {
|
|
|
- // handler(val) {
|
|
|
- // console.log(val);
|
|
|
- // this.areaData = val;
|
|
|
- // let valCode = '';
|
|
|
- // let level = '';
|
|
|
- // if (val.cityId && val.cityName) {
|
|
|
- // this.vuexCityList.forEach((item) => {
|
|
|
- // if (val.cityId == item.areaId) {
|
|
|
- // valCode = item.areaCode;
|
|
|
- // }
|
|
|
- // });
|
|
|
- // this.vuexDistrictList.forEach((item) => {
|
|
|
- // if (val.countyId == item.areaId) {
|
|
|
- // valCode = item.areaCode;
|
|
|
- // }
|
|
|
- // });
|
|
|
- // this.vuexStreetList.forEach((item) => {
|
|
|
- // if (val.townId == item.areaId) {
|
|
|
- // valCode = item.areaCode;
|
|
|
- // }
|
|
|
- // });
|
|
|
- // this.selectCity = {
|
|
|
- // areaId: val.cityId,
|
|
|
- // label: val.cityName,
|
|
|
- // value: valCode
|
|
|
- // };
|
|
|
- // this.selectDistrict = {
|
|
|
- // areaId: val.countyId,
|
|
|
- // label: val.countyName,
|
|
|
- // value: valCode
|
|
|
- // };
|
|
|
- // this.selectStreet = {
|
|
|
- // areaId: val.townId,
|
|
|
- // label: val.townName,
|
|
|
- // value: valCode
|
|
|
- // };
|
|
|
- // level = 'city';
|
|
|
- // // this.cityChange(this.selectCity, level);
|
|
|
- // this.$store.dispatch('searchArea', {
|
|
|
- // parentId: valCode,
|
|
|
- // name: val.cityName,
|
|
|
- // mapLevel: level
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
+ }
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapGetters(['vuexCityList', 'vuexDistrictList', 'vuexStreetList'])
|
|
|
+ ...mapGetters(['vuexCityList', 'vuexDistrictList', 'vuexStreetList']),
|
|
|
+ ...mapState(['selectCity', 'selectDistrict', 'selectStreet'])
|
|
|
},
|
|
|
created() {},
|
|
|
methods: {
|
|
@@ -221,6 +177,7 @@ export default {
|
|
|
// ],
|
|
|
features: ['road', 'bg', 'building'] //地图要素
|
|
|
});
|
|
|
+
|
|
|
AMapUI.load(
|
|
|
['ui/geo/DistrictExplorer', 'lib/$'],
|
|
|
function (DistrictExplorer) {
|
|
@@ -294,6 +251,7 @@ export default {
|
|
|
that.polygon.setPath(pathArray);
|
|
|
// that.map.add(that.polygon);
|
|
|
var cityArr = result.districtList[0].districtList;
|
|
|
+ that.districtList = cityArr;
|
|
|
for (let i = 0; i < cityArr.length; i++) {
|
|
|
that.cityMarker = new AMap.Text({
|
|
|
//c城市指示标
|
|
@@ -393,6 +351,22 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ console.log(this.$store.state.addr.selectCity);
|
|
|
+ this.map.on('mousewheel', (e) => {
|
|
|
+ console.log(e.lnglat.lng, e.lnglat.lat);
|
|
|
+ var zoom = this.map.getZoom(); //获取当前地图级别
|
|
|
+ console.log(zoom);
|
|
|
+ if (zoom > '11.8' && zoom < '12.1') {
|
|
|
+ console.log('开始检测');
|
|
|
+ console.log(this.districtData);
|
|
|
+ let districtCode = this.districtData.value.substring(0, 6);
|
|
|
+ this.$store.dispatch('searchArea', {
|
|
|
+ parentId: districtCode,
|
|
|
+ name: this.districtData.label,
|
|
|
+ mapLevel: 'district'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
that.getDistrict(adName, mapLevel);
|
|
|
this.switch2AreaNode(adcode);
|
|
|
},
|
|
@@ -425,7 +399,7 @@ export default {
|
|
|
//绘制某个区域的边界
|
|
|
renderAreaPolygons(areaNode) {
|
|
|
//更新地图视野
|
|
|
- this.map.setBounds(areaNode.getBounds(), null, null, true);
|
|
|
+ this.map.setBounds(areaNode.getBounds(), null, null, false);
|
|
|
//清除已有的绘制内容
|
|
|
this.districtExplorer.clearFeaturePolygons();
|
|
|
//绘制子区域
|
|
@@ -456,7 +430,7 @@ export default {
|
|
|
this.renderAreaPolygons(areaNode);
|
|
|
},
|
|
|
//切换区域
|
|
|
- switch2AreaNode(adcode, mapLevel, selectCity, page, callback) {
|
|
|
+ switch2AreaNode(adcode, mapLevel, selectStreet, page, callback) {
|
|
|
// if (
|
|
|
// this.currentAreaNode &&'' + this.currentAreaNode.getAdcode() === '' + adcode
|
|
|
// ) {
|
|
@@ -478,7 +452,7 @@ export default {
|
|
|
this.setMarker();
|
|
|
}
|
|
|
if (mapLevel === 'district') {
|
|
|
- this.getrjx(adcode);
|
|
|
+ this.getrjx(adcode, selectStreet);
|
|
|
if (page === 'event') {
|
|
|
this.getEven();
|
|
|
}
|
|
@@ -511,76 +485,78 @@ export default {
|
|
|
// let that = this;
|
|
|
// this.smallClassMapArr = this.$store.state.addr.smallClassMapArr;
|
|
|
// },
|
|
|
- addForestPolygon() {
|
|
|
+ addForestPolygon(smallClassMapArr) {
|
|
|
let that = this;
|
|
|
- this.smallClassMapArr.forEach((item) => {
|
|
|
- let polyData = JSON.parse(item.mapInfo);
|
|
|
- that.smallClassPolygon = new AMap.Polygon({
|
|
|
- map: this.map,
|
|
|
- path: polyData.features[0].geometry.coordinates,
|
|
|
- strokeOpacity: 1,
|
|
|
- fillOpacity: 0,
|
|
|
- strokeColor: 'red',
|
|
|
- strokeWeight: 2,
|
|
|
- zIndex: 999,
|
|
|
- cursor: 'pointer'
|
|
|
- });
|
|
|
- var lanLatArr = [];
|
|
|
- that.smallClassPolygon.on('click', (e) => {
|
|
|
- lanLatArr = [e.lnglat.lng, e.lnglat.lat];
|
|
|
- let smallLabel =
|
|
|
- "<div class='info-small'>" +
|
|
|
- "<h5 class='marker-title'>" +
|
|
|
- item.countyName +
|
|
|
- '-' +
|
|
|
- item.smallNumber +
|
|
|
- '</h5>' +
|
|
|
- "<div class='marker-content'>" +
|
|
|
- '<p>小班号:' +
|
|
|
- item.smallNumber +
|
|
|
- '</p>' +
|
|
|
- '<p>样地数:' +
|
|
|
- item.sampleCount +
|
|
|
- '</p>' +
|
|
|
- '<p>村(林班):' +
|
|
|
- polyData.features[0].properties.CUN +
|
|
|
- '</p>' +
|
|
|
- '<p>乡镇(林场):' +
|
|
|
- item.townName +
|
|
|
- '</p>' +
|
|
|
- '</div>' +
|
|
|
- '</div>';
|
|
|
- this.smallMarker = new AMap.Marker({
|
|
|
- position: lanLatArr,
|
|
|
- icon: require('@/assets/img/small-marker.png'),
|
|
|
- anchor: 'bottom-center',
|
|
|
- offset: new AMap.Pixel(0, 0)
|
|
|
+ if (smallClassMapArr) {
|
|
|
+ smallClassMapArr.forEach((item) => {
|
|
|
+ let polyData = JSON.parse(item.mapInfo);
|
|
|
+ that.smallClassPolygon = new AMap.Polygon({
|
|
|
+ map: this.map,
|
|
|
+ path: polyData.features[0].geometry.coordinates,
|
|
|
+ strokeOpacity: 1,
|
|
|
+ fillOpacity: 0,
|
|
|
+ strokeColor: 'red',
|
|
|
+ strokeWeight: 2,
|
|
|
+ zIndex: 999,
|
|
|
+ cursor: 'pointer'
|
|
|
});
|
|
|
- this.smallMarker.setLabel({
|
|
|
- direction: 'right',
|
|
|
- offset: new AMap.Pixel(-150, -90), //设置文本标注偏移量
|
|
|
- content: smallLabel //设置文本标注内容
|
|
|
+ var lanLatArr = [];
|
|
|
+ that.smallClassPolygon.on('click', (e) => {
|
|
|
+ lanLatArr = [e.lnglat.lng, e.lnglat.lat];
|
|
|
+ let smallLabel =
|
|
|
+ "<div class='info-small'>" +
|
|
|
+ "<h5 class='marker-title'>" +
|
|
|
+ item.countyName +
|
|
|
+ '-' +
|
|
|
+ item.smallNumber +
|
|
|
+ '</h5>' +
|
|
|
+ "<div class='marker-content'>" +
|
|
|
+ '<p>小班号:' +
|
|
|
+ item.smallNumber +
|
|
|
+ '</p>' +
|
|
|
+ '<p>样地数:' +
|
|
|
+ item.sampleCount +
|
|
|
+ '</p>' +
|
|
|
+ '<p>村(林班):' +
|
|
|
+ polyData.features[0].properties.CUN +
|
|
|
+ '</p>' +
|
|
|
+ '<p>乡镇(林场):' +
|
|
|
+ item.townName +
|
|
|
+ '</p>' +
|
|
|
+ '</div>' +
|
|
|
+ '</div>';
|
|
|
+ this.smallMarker = new AMap.Marker({
|
|
|
+ position: lanLatArr,
|
|
|
+ icon: require('@/assets/img/small-marker.png'),
|
|
|
+ anchor: 'bottom-center',
|
|
|
+ offset: new AMap.Pixel(0, 0)
|
|
|
+ });
|
|
|
+ this.smallMarker.setLabel({
|
|
|
+ direction: 'right',
|
|
|
+ offset: new AMap.Pixel(-150, -90), //设置文本标注偏移量
|
|
|
+ content: smallLabel //设置文本标注内容
|
|
|
+ });
|
|
|
+ this.smallMarker.setMap(this.map);
|
|
|
});
|
|
|
- this.smallMarker.setMap(this.map);
|
|
|
- });
|
|
|
- that.smallClassPolygon.on('mouseover', () => {
|
|
|
- that.smallClassPolygon.setOptions({
|
|
|
- fillOpacity: 0.7,
|
|
|
- fillColor: 'yellow'
|
|
|
+ that.smallClassPolygon.on('mouseover', () => {
|
|
|
+ that.smallClassPolygon.setOptions({
|
|
|
+ fillOpacity: 0.7,
|
|
|
+ fillColor: 'yellow'
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
- that.smallClassPolygon.on('mouseout', () => {
|
|
|
- if (this.smallMarker) {
|
|
|
- this.smallMarker.setMap(null);
|
|
|
- this.smallMarker = null;
|
|
|
- }
|
|
|
- that.smallClassPolygon.setOptions({
|
|
|
- fillOpacity: 0,
|
|
|
- fillColor: '#ccebc5'
|
|
|
+ that.smallClassPolygon.on('mouseout', () => {
|
|
|
+ if (this.smallMarker) {
|
|
|
+ this.smallMarker.setMap(null);
|
|
|
+ this.smallMarker = null;
|
|
|
+ }
|
|
|
+ that.smallClassPolygon.setOptions({
|
|
|
+ fillOpacity: 0,
|
|
|
+ fillColor: '#ccebc5'
|
|
|
+ });
|
|
|
});
|
|
|
+ this.map.add(that.smallClassPolygon);
|
|
|
});
|
|
|
- this.map.add(that.smallClassPolygon);
|
|
|
- });
|
|
|
+ }
|
|
|
},
|
|
|
// 获取样地数据
|
|
|
getForestSample(page) {
|
|
@@ -995,8 +971,20 @@ export default {
|
|
|
this.forestFarmData = res.rows;
|
|
|
let parentMarker = require('@/assets/img/pre-marker.png');
|
|
|
this.forestFarmData.forEach((item) => {
|
|
|
+ let selectCity = this.$store.state.addr.selectCity.label;
|
|
|
+ switch (this.$store.state.addr.selectCity.label) {
|
|
|
+ case '黔西南州':
|
|
|
+ selectCity = '黔西南布依族苗族自治州';
|
|
|
+ break;
|
|
|
+ case '黔东南州':
|
|
|
+ selectCity = '黔东南苗族侗族自治州';
|
|
|
+ break;
|
|
|
+ case '黔南州':
|
|
|
+ selectCity = '黔南布依族苗族自治州';
|
|
|
+ break;
|
|
|
+ }
|
|
|
if (this.$store.state.addr.selectCity.label) {
|
|
|
- if (this.$store.state.addr.selectCity.label == item.cityName) {
|
|
|
+ if (selectCity == item.cityName) {
|
|
|
let lngLat = [item.longitude, item.latitude];
|
|
|
var marker = new AMap.Marker({
|
|
|
position: lngLat,
|
|
@@ -1029,22 +1017,22 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- getrjx(adcode) {
|
|
|
+ getrjx(adcode, selectStreet) {
|
|
|
if (adcode == '522632') {
|
|
|
axios.get('/static/rongjangintown.json').then((res) => {
|
|
|
let putPolygonData = [];
|
|
|
putPolygonData = res.data.features;
|
|
|
- this.putPolygon(putPolygonData);
|
|
|
+ this.putPolygon(putPolygonData, selectStreet);
|
|
|
});
|
|
|
} else if (adcode == '520181') {
|
|
|
axios.get('/static/qingzhenzhen.json').then((res) => {
|
|
|
let qingzhenputPolygonData = [];
|
|
|
qingzhenputPolygonData = res.data.features;
|
|
|
- this.putPolygon(qingzhenputPolygonData);
|
|
|
+ this.putPolygon(qingzhenputPolygonData, selectStreet);
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- putPolygon(putPolygonData) {
|
|
|
+ putPolygon(putPolygonData, selectStreet) {
|
|
|
let that = this;
|
|
|
putPolygonData.forEach((element) => {
|
|
|
this.boundaryPolygon = new AMap.Polygon({
|
|
@@ -1080,6 +1068,7 @@ export default {
|
|
|
label: label,
|
|
|
areaId: areaId
|
|
|
});
|
|
|
+ console.log(this.streetData);
|
|
|
var outer = [
|
|
|
new AMap.LngLat(-360, 90, true),
|
|
|
new AMap.LngLat(-360, -90, true),
|
|
@@ -1100,8 +1089,13 @@ export default {
|
|
|
townPolygon.setPath(holes);
|
|
|
// that.map.add(townPolygon);
|
|
|
that.map.setZoomAndCenter(13, centerLanLatArr, false, 12);
|
|
|
-
|
|
|
+ this.$store.dispatch('getSmallClassMap', {
|
|
|
+ cityId: this.$store.state.addr.selectCity.areaId,
|
|
|
+ countyId: this.$store.state.addr.selectDistrict.areaId,
|
|
|
+ townId: this.$store.state.addr.selectStreet.areaId
|
|
|
+ });
|
|
|
// that.map.setBounds(townPolygon.getBounds(), null, null, true);
|
|
|
+ console.log(this.leftPage);
|
|
|
if (this.leftPage === 'forest') {
|
|
|
this.addForestPolygon();
|
|
|
this.getForestSample(this.leftPage);
|
|
@@ -1111,11 +1105,6 @@ export default {
|
|
|
} else if (this.leftPage === 'economics') {
|
|
|
this.getEconomics();
|
|
|
}
|
|
|
- this.$store.dispatch('getSmallClassMap', {
|
|
|
- cityId: this.$store.state.addr.selectCity.areaId,
|
|
|
- countyId: this.$store.state.addr.selectDistrict.areaId,
|
|
|
- townId: this.$store.state.addr.selectStreet.areaId
|
|
|
- });
|
|
|
});
|
|
|
});
|
|
|
}
|