amapPow.vue 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294
  1. <!--
  2. * @Description:
  3. * @Author: wangcc
  4. * @Date: 2022-10-19 09:32:46
  5. * @LastEditors: wangcc
  6. * @LastEditTime: 2022-11-11 18:00:23
  7. * @FilePath: \castgroup_bigscreen\src\components\amapPow.vue
  8. * @Copyright: Copyright (c) 2016~2022 by wangcc, All Rights Reserved.
  9. -->
  10. <template>
  11. <div class="map-wrap">
  12. <div id="container" tabindex="0"></div>
  13. <div id="mask"></div>
  14. <div class="yun-wrap">
  15. <img class="yun yun1" src="../assets/img/云1.png" alt />
  16. </div>
  17. <div class="yun-wrap">
  18. <img class="yun yun2" src="../assets/img/云2.png" alt />
  19. </div>
  20. <div class="yun-wrap">
  21. <img class="yun yun3" src="../assets/img/云3.png" alt />
  22. </div>
  23. <el-dialog title="查看图片" :modal="false" :visible.sync="imgDialogVisible" width="40%">
  24. <img width="100%" style="height:580px" :src="dialogImageUrl" alt />
  25. </el-dialog>
  26. </div>
  27. </template>
  28. <script>
  29. import AMapLoader from '@amap/amap-jsapi-loader';
  30. import { mapMutations, mapState, mapGetters } from 'vuex';
  31. import {
  32. smallClassMap,
  33. smallClassMapFile,
  34. rightScrollData,
  35. forestSample,
  36. alarmDataApi,
  37. financeBasePlant,
  38. financeBaseDetail,
  39. farmInfo,
  40. smallClassDetail,
  41. treePlant,
  42. projectList,
  43. getProjectIcon
  44. } from '@/service/index.js';
  45. import axios from 'axios';
  46. export default {
  47. name: 'Mapview',
  48. data() {
  49. return {
  50. imgDialogVisible: false,
  51. dialogImageUrl: null,
  52. AMap: null,
  53. map: null,
  54. lngLat: [106.628201, 26.646694],
  55. adName: '贵州省',
  56. mapLevel: 'province',
  57. adcode: '贵州省',
  58. parentId: '520000',
  59. province: '',
  60. zoom: 8,
  61. districtExplorer: null,
  62. tipMarker: null,
  63. $tipMarkerContent: null,
  64. currentAreaNode: null,
  65. cityMarkerArr: [],
  66. eventMarker: null,
  67. baseMarker: null,
  68. streetMarkerArr: [],
  69. leftPage: 'forest',
  70. putPolygonData: [],
  71. //乡镇边界
  72. townPolygons: [],
  73. // 基地详情
  74. baseMarkers: [],
  75. // 小班详情
  76. smallMarkers: [],
  77. // 时间详情
  78. eventMarkers: [],
  79. // 林场
  80. treesMarkerArr: [],
  81. // 小班边界
  82. smallClassMapArr: [],
  83. // 作物
  84. economicsArr: [],
  85. // 基地定位
  86. baseMarkerArr: [],
  87. // 时间信息
  88. eventMarkersArr: [],
  89. // 样地、小班
  90. forestMarkerArr: [],
  91. // 样地号
  92. smallClassNArr: [],
  93. // 森林资源小班边界
  94. smallClassPolygonArr: [],
  95. // 林木结构小班边界
  96. treesPolygonArr: [],
  97. // 项目列表
  98. projectMarkerArr: [],
  99. treeCompMarkers: [],
  100. townPolygonArr: [],
  101. economicsArr: [],
  102. selectData: {},
  103. districtData: {},
  104. streetData: {},
  105. // 项目小班数
  106. projectSmallClassArr: [],
  107. // 项目小班边界
  108. smallClassProject: [],
  109. // 项目小班红点转边界图
  110. projectPolygonArr: [],
  111. projectIcon:
  112. 'http://miniores.hw.hongweisoft.com/mintou/1667460231789_a06fed1519c5e3d206e4ab9148d658e5.png'
  113. // projectIcon: ''
  114. };
  115. },
  116. watch: {
  117. '$store.state.addr.parentId': {
  118. handler(val) {
  119. // 加载小班边界
  120. // this.getSmallClass();
  121. this.parentId = val;
  122. console.log(this.$store.state.addr.selectStreet);
  123. if (this.$store.state.addr.mapLevel == 'street') {
  124. this.parentId = val.substring(0, 6);
  125. if (this.map) {
  126. this.switch2AreaNode(
  127. this.parentId,
  128. this.$store.state.addr.mapLevel,
  129. this.$store.state.addr.selectCity,
  130. this.leftPage
  131. );
  132. }
  133. }
  134. if (this.$store.state.addr.mapLevel == 'province') {
  135. if (this.projectSmallClassArr) {
  136. this.map.remove(this.projectSmallClassArr);
  137. }
  138. }
  139. if (this.$store.state.addr.mapLevel != 'street') {
  140. this.selectData = this.$store.state.addr.selectCity;
  141. this.districtData = this.$store.state.addr.selectDistrict;
  142. this.streetData = this.$store.state.addr.selectStreet;
  143. if (this.map) {
  144. this.switch2AreaNode(
  145. this.parentId,
  146. this.$store.state.addr.mapLevel,
  147. this.$store.state.addr.selectCity,
  148. this.leftPage
  149. );
  150. }
  151. if (this.townPolygonArr) {
  152. this.map.remove(this.townPolygonArr);
  153. }
  154. if (
  155. this.polygon ||
  156. this.streetMarkerArr ||
  157. this.townPolygons ||
  158. this.forestMarkerArr ||
  159. this.smallClassNArr ||
  160. this.forestMarkerArr ||
  161. this.townPolygonArr ||
  162. this.smallClassPolygonArr
  163. ) {
  164. this.map.remove(this.polygon);
  165. this.map.remove(this.streetMarkerArr);
  166. this.map.remove(this.townPolygons);
  167. this.map.remove(this.forestMarkerArr);
  168. this.map.remove(this.smallClassNArr);
  169. this.map.remove(this.forestMarkerArr);
  170. this.map.remove(this.townPolygonArr);
  171. this.map.remove(this.smallClassPolygonArr);
  172. this.townPolygons = [];
  173. }
  174. }
  175. }
  176. },
  177. '$store.state.addr.selectStreet'(val) {
  178. if (val.label && val.value && val.areaId) {
  179. let _this = this;
  180. this.map.remove(this.polygon);
  181. let labelTown = val.label;
  182. console.log(val);
  183. this.map.setCity(labelTown);
  184. }
  185. },
  186. '$store.state.addr.page': {
  187. handler(val) {
  188. this.leftPage = val;
  189. if (!this.parentId) {
  190. this.parentId = '520000';
  191. this.$store.state.addr.parentName = '贵州省';
  192. }
  193. if (this.parentId) {
  194. if (this.$store.state.addr.mapLevel == 'street') {
  195. // this.getSmallClass(val);
  196. }
  197. }
  198. this.mapPolygon();
  199. if (val == 'forest' || val == 'treeSpecies') {
  200. this.getProjectList();
  201. } else {
  202. this.map.remove(this.projectSmallClassArr);
  203. }
  204. if (val != 'forest') {
  205. this.map.remove(this.forestMarkerArr);
  206. this.map.remove(this.smallClassNArr);
  207. this.map.remove(this.smallClassPolygonArr);
  208. this.map.remove(this.projectMarkerArr);
  209. if (this.projectPolygonArr) {
  210. this.map.remove(this.projectPolygonArr);
  211. }
  212. if (this.smallMarkers) {
  213. this.map.remove(this.smallMarkers);
  214. }
  215. }
  216. if (val != 'treeSpecies') {
  217. this.map.remove(this.forestMarkerArr);
  218. this.map.remove(this.treesPolygonArr);
  219. this.map.remove(this.projectMarkerArr);
  220. if (this.treeCompMarkers) {
  221. this.map.remove(this.treeCompMarkers);
  222. }
  223. if (this.treesPolygonArr) {
  224. this.map.remove(this.treesPolygonArr);
  225. }
  226. }
  227. if (val != 'economics') {
  228. this.map.remove(this.economicsArr);
  229. this.map.remove(this.baseMarkerArr);
  230. }
  231. if (val != 'event') {
  232. this.map.remove(this.eventMarkersArr);
  233. if (this.eventMarkers) {
  234. this.map.remove(this.eventMarkers);
  235. }
  236. }
  237. }
  238. },
  239. '$store.state.addr.mapLevel': {
  240. handler(val) {
  241. if (val === 'street') {
  242. // this.getSmallClass();
  243. }
  244. }
  245. },
  246. '$store.state.addr.smallClassSearch': {
  247. deep: true,
  248. immediate: true,
  249. handler: function (val, oldVal) {
  250. let _this = this;
  251. if (val) {
  252. if (val.longitude && val.latitude && !val.name) {
  253. this.map.remove(this.polygon);
  254. if (_this.smallMarkers) {
  255. _this.map.remove(_this.smallMarkers);
  256. }
  257. if (this.smallClassProject) {
  258. this.map.remove(this.smallClassProject);
  259. }
  260. this.setMapLabel(val);
  261. if (
  262. this.$store.state.addr.mapLevel == 'province' ||
  263. this.$store.state.addr.mapLevel == 'city' ||
  264. (this.$store.state.addr.mapLevel == 'district' &&
  265. this.$store.state.addr.selectCity.prop == '1')
  266. ) {
  267. if (val.countyCode) {
  268. // this.switch2AreaNode(val.countyCode.substring(0, 6));
  269. let selectCity = '';
  270. switch (val.cityName) {
  271. case '黔西南州':
  272. selectCity = '黔西南布依族苗族自治州';
  273. break;
  274. case '黔东南州':
  275. selectCity = '黔东南苗族侗族自治州';
  276. break;
  277. case '黔南州':
  278. selectCity = '黔南布依族苗族自治州';
  279. break;
  280. }
  281. this.$store.dispatch('searchArea', {
  282. parentId: val.cityCode.substring(0, 6),
  283. name: selectCity,
  284. mapLevel: 'city'
  285. });
  286. if (val.cityCode) {
  287. this.changeSelectCity({
  288. value: val.cityCode,
  289. label: selectCity,
  290. areaId: val.cityId,
  291. prop: '2'
  292. });
  293. }
  294. if (val.countyCode) {
  295. this.changeSelectDistrict({
  296. value: val.countyCode,
  297. label: val.countyName,
  298. areaId: val.countyId,
  299. prop: '2'
  300. });
  301. }
  302. }
  303. } else {
  304. this.switch2AreaNode(val.countyCode.substring(0, 6));
  305. }
  306. }
  307. if (val.mapInfo) {
  308. let polyData = JSON.parse(val.mapInfo);
  309. let smallClassPolygon = new AMap.Polygon({
  310. map: _this.map,
  311. path: polyData.features[0].geometry.coordinates,
  312. strokeOpacity: 1,
  313. fillOpacity: 0.5,
  314. strokeColor: 'red',
  315. strokeWeight: 2,
  316. zIndex: 999,
  317. cursor: 'pointer',
  318. fillColor: 'red'
  319. });
  320. this.smallClassProject.push(smallClassPolygon);
  321. }
  322. }
  323. }
  324. },
  325. '$store.state.addr.eventData': {
  326. deep: true,
  327. immediate: true,
  328. handler: function (val, oldVal) {
  329. let _this = this;
  330. if (val) {
  331. if (val.longitude && val.latitude && !val.name) {
  332. if (_this.eventMarkers) {
  333. _this.map.remove(_this.eventMarkers);
  334. }
  335. let lanLatArr = [val.longitude, val.latitude];
  336. let baseIcon = '';
  337. let fireIcon = require('@/assets/img/fire.png');
  338. let cutTreeIcon = require('@/assets/img/cutTree.png');
  339. let insectpestIcon = require('@/assets/img/insectpest.png');
  340. let stealIcon = require('@/assets/img/steal.png');
  341. if (val.eventType == 1) {
  342. val.eventContLabel = '火灾';
  343. baseIcon = fireIcon;
  344. } else if (val.eventType == 2) {
  345. val.eventContLabel = '砍伐';
  346. baseIcon = cutTreeIcon;
  347. } else if (val.eventType == 3) {
  348. val.eventContLabel = '病虫害';
  349. baseIcon = insectpestIcon;
  350. } else if (val.eventType == 4) {
  351. val.eventContLabel = '偷盗林木';
  352. baseIcon = stealIcon;
  353. }
  354. let baseIconData = new AMap.Icon({
  355. size: new AMap.Size(35, 35), // 图标尺寸
  356. image: baseIcon,
  357. imageSize: new AMap.Size(35, 35) // 根据所设置的大小拉伸或压缩图片
  358. });
  359. let treeSmallLabel =
  360. "<div class='info-small'>" +
  361. "<h5 class='marker-title'>历史事件" +
  362. '</h5>' +
  363. "<div class='marker-content'>" +
  364. '<p>事件类型:' +
  365. val.eventContLabel +
  366. '</p>' +
  367. '<p>上报时间:' +
  368. val.createTime +
  369. '</p>' +
  370. '<p>上报人:' +
  371. val.createBy +
  372. '</p>' +
  373. '<p>位置:' +
  374. val.cityName +
  375. val.countyName +
  376. val.townName +
  377. val.villageName +
  378. '</p>' +
  379. '</div>' +
  380. '</div>';
  381. this.eventMarker = new AMap.Marker({
  382. map: this.map,
  383. position: lanLatArr,
  384. icon: baseIconData,
  385. anchor: 'bottom-center',
  386. offset: new AMap.Pixel(0, 0),
  387. zIndex: 9999
  388. });
  389. this.eventMarker.setLabel({
  390. direction: 'top',
  391. offset: new AMap.Pixel(-10, 0), //设置文本标注偏移量
  392. content: treeSmallLabel //设置文本标注内容
  393. });
  394. this.eventMarkers.push(this.eventMarker);
  395. // this.map.add(this.eventMarker);
  396. _this.eventMarker.on('click', (e) => {
  397. if (_this.eventMarkers) {
  398. _this.map.remove(_this.eventMarkers);
  399. }
  400. });
  401. } else if (val.name == false && this.eventMarker) {
  402. this.map.on('rightclick', function (e) {
  403. _this.map.remove(_this.eventMarkers);
  404. });
  405. }
  406. }
  407. }
  408. },
  409. '$store.state.addr.baseDetail': {
  410. deep: true,
  411. immediate: true,
  412. handler: function (val, oldVal) {
  413. let _this = this;
  414. if (val) {
  415. if (val.baseLongitude && val.baseLatitude && !val.name) {
  416. if (_this.baseMarkers) {
  417. _this.map.remove(_this.baseMarkers);
  418. }
  419. let lanLatArr = [val.baseLongitude, val.baseLatitude];
  420. let treeSmallLabel =
  421. "<div class='info-small'>" +
  422. "<h5 class='marker-title'>" +
  423. val.baseName +
  424. '</h5>' +
  425. "<div class='marker-content'>" +
  426. '<p>基地名称:' +
  427. val.baseName +
  428. '</p>' +
  429. '<p>种植/养殖/加工作物:' +
  430. val.cropName +
  431. '</p>' +
  432. '<p>占地面积:' +
  433. val.baseArea +
  434. '亩' +
  435. '</p>' +
  436. '<p>位置:' +
  437. val.cityName +
  438. val.countyName +
  439. val.townName +
  440. '</p>' +
  441. '</div>' +
  442. '</div>';
  443. this.baseMarker = new AMap.Marker({
  444. map: this.map,
  445. position: lanLatArr,
  446. icon: require('@/assets/img/small-marker.png'),
  447. anchor: 'bottom-center',
  448. offset: new AMap.Pixel(0, 0),
  449. zIndex: 9999
  450. });
  451. this.baseMarker.setLabel({
  452. direction: 'top',
  453. offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
  454. content: treeSmallLabel //设置文本标注内容
  455. });
  456. this.baseMarkers.push(_this.baseMarker);
  457. this.baseMarker.on('click', (e) => {
  458. _this.map.remove(_this.baseMarkers);
  459. });
  460. } else if (val.name == false && _this.baseMarker) {
  461. this.map.on('rightclick', function (e) {
  462. _this.map.remove(_this.baseMarkers);
  463. });
  464. }
  465. }
  466. }
  467. },
  468. '$store.state.addr.smallClassMap': {
  469. handler(val) {
  470. if (val) {
  471. let _this = this;
  472. if (this.projectSmallClassArr) {
  473. this.map.remove(this.projectSmallClassArr);
  474. }
  475. let capitals = { animations: 'scaless' };
  476. let lngLagArr = [];
  477. val.forEach((element) => {
  478. let lnglat = new AMap.LngLat(element.longitude, element.latitude);
  479. var projectSmallClass = new AMap.Text({
  480. map: this.map,
  481. text: ' ',
  482. textAlign: 'center',
  483. verticalAlign: 'middle', //middle 、bottom
  484. draggable: false,
  485. cursor: 'pointer',
  486. angle: 2,
  487. style: {
  488. width: '2px',
  489. height: '2px',
  490. 'border-radius': '50%',
  491. 'border-width': 0,
  492. 'text-align': 'center',
  493. 'font-size': '12px',
  494. color: 'blue',
  495. 'background-color': 'red',
  496. // '-moz-box-shadow': '0px 0px 20px 2px '+capitals[i].color,
  497. // 'box-shadow': '0px 0px 20px 2px '+capitals[i].color,
  498. animation:
  499. capitals.animations +
  500. '1s infinite cubic-bezier(0, 0, 0.49, 1.02)'
  501. // 'animation': 'myfirst 1s infinite'
  502. },
  503. position: lnglat
  504. });
  505. this.projectSmallClassArr.push(projectSmallClass);
  506. if (this.$store.state.addr.mapLevel == 'district') {
  507. this.map.setFitView(projectSmallClass, false, false, 12);
  508. }
  509. projectSmallClass.on('click', (e) => {
  510. if (_this.projectPolygonArr) {
  511. _this.map.remove(_this.projectPolygonArr);
  512. }
  513. if (_this.smallMarkers) {
  514. _this.map.remove(_this.smallMarkers);
  515. }
  516. if (_this.treeCompMarkers) {
  517. _this.map.remove(_this.treeCompMarkers);
  518. }
  519. if (_this.treesPolygonArr) {
  520. _this.map.remove(_this.treesPolygonArr);
  521. }
  522. if (_this.smallClassProject) {
  523. _this.map.remove(_this.smallClassProject);
  524. }
  525. // _this.map.remove(projectSmallClass);
  526. smallClassDetail({ id: element.id }).then((res) => {
  527. if (res.code == 200) {
  528. let detail = res.data;
  529. if (this.leftPage == 'forest') {
  530. if (detail.mapInfo) {
  531. let polyData = JSON.parse(detail.mapInfo);
  532. let projectPolygon = new AMap.Polygon({
  533. map: _this.map,
  534. path: polyData.features[0].geometry.coordinates,
  535. strokeOpacity: 1,
  536. fillOpacity: 0.5,
  537. strokeColor: 'red',
  538. strokeWeight: 2,
  539. zIndex: 999,
  540. cursor: 'pointer',
  541. fillColor: 'red'
  542. });
  543. this.projectPolygonArr.push(projectPolygon);
  544. }
  545. this.map.on('rightclick', (e) => {
  546. if (_this.projectPolygonArr) {
  547. _this.map.remove(_this.projectPolygonArr);
  548. }
  549. if (_this.smallMarkers) {
  550. _this.map.remove(_this.smallMarkers);
  551. }
  552. });
  553. _this.setMapLabel(detail);
  554. } else if (this.leftPage == 'treeSpecies') {
  555. this.addTreeSpeciesPolygon(detail);
  556. }
  557. }
  558. });
  559. });
  560. });
  561. }
  562. }
  563. }
  564. },
  565. computed: {
  566. ...mapGetters(['vuexCityList', 'vuexDistrictList', 'vuexStreetList']),
  567. ...mapState(['selectCity', 'selectDistrict', 'selectStreet'])
  568. },
  569. created() {
  570. this.getTreePlant();
  571. // this.getIcon();
  572. },
  573. mounted() {
  574. this.initAMap();
  575. // 加载小班边界
  576. // this.getSmallClass();
  577. },
  578. methods: {
  579. ...mapMutations([
  580. 'changeSelectCity',
  581. 'changeSelectDistrict',
  582. 'changeSelectStreet',
  583. 'changeSelectAddr'
  584. ]),
  585. getIcon() {
  586. getProjectIcon('project_icon').then((res) => {
  587. if (res.code == 200) {
  588. this.projectIcon = res.data[0].dictValue;
  589. }
  590. });
  591. },
  592. setMapLabel(val) {
  593. let _this = this;
  594. let lanLatArr = [val.longitude, val.latitude];
  595. let imgList = [];
  596. if (val.imageList.length > 0) {
  597. val.imageList.forEach((element) => {
  598. imgList.push(`<img id="markerLabel" src="${element.image}"/>`);
  599. });
  600. } else {
  601. imgList.push('暂无图片');
  602. }
  603. this.imgClick();
  604. let smallLabel =
  605. "<div class='info-details'>" +
  606. "<h5 class='marker-title'>" +
  607. val.countyName +
  608. '-' +
  609. val.smallNumber +
  610. '</h5>' +
  611. "<div class='marker-content'>" +
  612. '<div>' +
  613. '<p>小班号:' +
  614. val.smallNumber +
  615. '</p>' +
  616. '<p>样地数:' +
  617. val.sampleCount +
  618. '</p>' +
  619. '<p>小班蓄积量:' +
  620. val.smallClassStock +
  621. '(立方米)' +
  622. '</p>' +
  623. '<p>小班占地面积:' +
  624. val.landArea +
  625. '(亩)' +
  626. '</p>' +
  627. '<p>小班树种组成:' +
  628. val.treeComp +
  629. '</p>' +
  630. '<p>地类:' +
  631. val.landType +
  632. '</p>' +
  633. '<p>林地权属:' +
  634. val.landOwner +
  635. '</p>' +
  636. '<p>林木权属:' +
  637. val.forestOwner +
  638. '</p>' +
  639. '<p>林种:' +
  640. val.forestClass +
  641. '</p>' +
  642. '<p>树种结构:' +
  643. val.treeStruct +
  644. '</p>' +
  645. '</div>' +
  646. '<div>' +
  647. '<p>起源:' +
  648. val.origin +
  649. '</p>' +
  650. '<p>优势树种:' +
  651. val.superTree +
  652. '</p>' +
  653. '<p>主要灌木名称:' +
  654. val.shrubName +
  655. '</p>' +
  656. '<p>地貌:' +
  657. val.landForm +
  658. '</p>' +
  659. '<p>海拔:' +
  660. val.altitude +
  661. '</p>' +
  662. '<p>坡位:' +
  663. val.slopePosit +
  664. '</p>' +
  665. '<p>坡向:' +
  666. val.slopeDirect +
  667. '</p>' +
  668. '<p>坡形:' +
  669. val.slopeForm +
  670. '</p>' +
  671. '<p>坡度:' +
  672. val.slope +
  673. '</p>' +
  674. '<p>森林健康度:' +
  675. val.forestHealth +
  676. '</p>' +
  677. '</div>' +
  678. '</div>' +
  679. '<div class="imgList">' +
  680. "<span class='marker-span'>图片:</span>" +
  681. '<div class="marker-imgs">' +
  682. imgList +
  683. '</div>' +
  684. '</div>' +
  685. '</div>';
  686. let infoIcon = new AMap.Icon({
  687. size: new AMap.Size(40, 25), // 图标尺寸
  688. image: require('@/assets/img/small-marker.png'),
  689. imageSize: new AMap.Size(40, 25) // 根据所设置的大小拉伸或压缩图片
  690. });
  691. this.smallMarker = new AMap.Marker({
  692. map: this.map,
  693. position: lanLatArr,
  694. icon: infoIcon,
  695. anchor: 'bottom-center',
  696. offset: new AMap.Pixel(0, -6),
  697. zIndex: 9999
  698. });
  699. this.smallMarker.setLabel({
  700. direction: 'right',
  701. offset: new AMap.Pixel(-230, -150), //设置文本标注偏移量
  702. content: smallLabel //设置文本标注内容
  703. });
  704. if (this.$store.state.addr.mapLevel == 'street') {
  705. this.map.setFitView(this.smallMarker, false, false, 12);
  706. }
  707. this.smallMarkers.push(_this.smallMarker);
  708. this.smallMarker.on('click', (e) => {
  709. if (_this.smallMarkers) {
  710. _this.map.remove(_this.smallMarkers);
  711. }
  712. if (_this.projectPolygonArr) {
  713. _this.map.remove(_this.projectPolygonArr);
  714. }
  715. if (_this.smallClassProject) {
  716. _this.map.remove(_this.smallClassProject);
  717. }
  718. // _this.smallMarker.setLabel({
  719. // direction: 'right',
  720. // offset: new AMap.Pixel(-230, -160), //设置文本标注偏移量
  721. // content: smallLabel //设置文本标注内容
  722. // });
  723. });
  724. },
  725. initAMap() {
  726. window._AMapSecurityConfig = {
  727. securityJsCode: 'e6666dfe93e7d3c6f3a5dc35cad6befb' // 密钥
  728. };
  729. let _this = this;
  730. AMapLoader.load({
  731. key: 'f79d862df9288710e3dce6591af9dff1', //设置您的key
  732. version: '2.0',
  733. plugins: [
  734. 'AMap.ToolBar',
  735. 'AMap.Driving',
  736. 'AMap.DistrictSearch',
  737. 'AMap.MapboxVectorTileLayer'
  738. ],
  739. Loca: {
  740. version: '2.0'
  741. },
  742. AMapUI: {
  743. version: '1.1',
  744. plugins: ['overlay/SimpleMarker']
  745. },
  746. features: ['road', 'bg', 'building']
  747. }).then((AMap) => {
  748. _this.AMap = AMap;
  749. _this.map = new AMap.Map('container', {
  750. viewMode: '3D',
  751. zoom: _this.zoom,
  752. center: _this.lngLat,
  753. pitch: 45,
  754. terrain: true,
  755. features: ['road', 'bg', 'building'],
  756. layers: [new AMap.TileLayer.Satellite()]
  757. });
  758. AMapUI.load(
  759. ['ui/geo/DistrictExplorer', 'ui/geo/DistrictCluster', 'lib/$'],
  760. function (DistrictExplorer, DistrictCluster, $) {
  761. window.DistrictCluster = DistrictCluster;
  762. _this.loadMapData(DistrictExplorer, $);
  763. }
  764. );
  765. _this.map.on('rightclick', function (e) {
  766. if (_this.smallMarkers.length > 0) {
  767. _this.map.remove(_this.smallMarkers);
  768. }
  769. if (_this.smallClassProject) {
  770. _this.map.remove(_this.smallClassProject);
  771. }
  772. if (_this.projectPolygonArr) {
  773. _this.map.remove(_this.projectPolygonArr);
  774. }
  775. // if (_this.treeCompMarkers.length > 0) {
  776. // _this.map.remove(_this.treeCompMarkers);
  777. // }
  778. });
  779. let wms = new AMap.TileLayer.WMTS({
  780. url: 'http://t4.tianditu.gov.cn/img_w/wmts',
  781. blend: false,
  782. tileSize: 256,
  783. params: {
  784. Layer: 'img',
  785. Version: '1.0.0',
  786. Format: 'tiles',
  787. TileMatrixSet: 'w',
  788. STYLE: 'default',
  789. tk: '064688075f565aa463866b915c378e00'
  790. }
  791. });
  792. wms.setMap(_this.map);
  793. this.map.on('mousewheel', (e) => {
  794. var zoom = this.map.getZoom(); //获取当前地图级别
  795. if (
  796. zoom > '10.5' &&
  797. zoom < '11' &&
  798. this.$store.state.addr.mapLevel == 'street'
  799. ) {
  800. if (this.districtData.value) {
  801. let districtCode = this.districtData.value.substring(0, 6);
  802. this.$store.dispatch('searchArea', {
  803. parentId: districtCode,
  804. name: this.districtData.label,
  805. mapLevel: 'district'
  806. });
  807. }
  808. }
  809. // if (
  810. // zoom > '9' &&
  811. // zoom < '9.5' &&
  812. // this.$store.state.addr.mapLevel == 'district'
  813. // ) {
  814. // if (this.selectData.value) {
  815. // let districtCode = this.selectData.value.substring(0, 6);
  816. // this.$store.dispatch('searchArea', {
  817. // parentId: districtCode,
  818. // name: this.selectData.label,
  819. // mapLevel: 'city'
  820. // });
  821. // }
  822. // }
  823. // if (
  824. // zoom > '7.6' &&
  825. // zoom < '7.9' &&
  826. // this.$store.state.addr.mapLevel == 'city'
  827. // ) {
  828. // this.$store.dispatch('searchArea', {
  829. // parentId: '520000',
  830. // name: '贵州省',
  831. // mapLevel: 'province'
  832. // });
  833. // }
  834. });
  835. });
  836. },
  837. loadMapData(DistrictExplorer, $) {
  838. let that = this;
  839. //创建一个实例
  840. that.districtExplorer = window.districtExplorer = new DistrictExplorer({
  841. eventSupport: true, //打开事件支持
  842. bubble: true,
  843. map: that.map
  844. });
  845. //当前聚焦的区域
  846. // this.$tipMarkerContent = $('<div class="tipMarker top"></div>');
  847. this.$tipMarkerContent = $('<div class="tipMarker top"></div>');
  848. this.tipMarker = new AMap.Marker({
  849. content: this.$tipMarkerContent.get(0),
  850. offset: new AMap.Pixel(0, 0),
  851. bubble: true
  852. });
  853. //监听feature的hover事件
  854. this.districtExplorer.on(
  855. 'featureMouseout featureMouseover',
  856. (e, feature) => {
  857. this.toggleHoverFeature(
  858. feature,
  859. e.type === 'featureMouseover',
  860. e.originalEvent ? e.originalEvent.lnglat : null
  861. );
  862. }
  863. );
  864. //监听鼠标在feature上滑动
  865. this.districtExplorer.on('featureMousemove', (e) => {
  866. //更新提示位置
  867. this.tipMarker.setPosition(e.originalEvent.lnglat);
  868. });
  869. let adName = that.adName; //贵州省
  870. let mapLevel = that.mapLevel;
  871. let adcode = '520000';
  872. //feature被点击
  873. this.districtExplorer.on('featureClick', (e, feature) => {
  874. const props = feature.properties;
  875. if (props.subFeatureIndex != null) {
  876. adName = props.name;
  877. adcode = props.adcode;
  878. mapLevel = props.level;
  879. // for (let item of this.forestFarmData) {
  880. // if (props.name == item.cityName || props.name == item.countyName) {
  881. mapLevel = props.level;
  882. adName = props.name;
  883. this.$store.dispatch('searchArea', {
  884. parentId: props.adcode,
  885. name: props.name,
  886. mapLevel: props.level
  887. });
  888. let valCode = props.adcode + '000000';
  889. let areaId = '';
  890. this.vuexCityList.forEach((item) => {
  891. if (valCode == item.areaCode) {
  892. areaId = item.areaId;
  893. }
  894. });
  895. this.vuexDistrictList.forEach((item) => {
  896. if (valCode == item.areaCode) {
  897. areaId = item.areaId;
  898. }
  899. });
  900. if (props.level == 'city') {
  901. this.changeSelectCity({
  902. value: valCode,
  903. label: props.name,
  904. areaId: areaId,
  905. prop: '1'
  906. });
  907. } else if (props.level == 'district') {
  908. this.changeSelectDistrict({
  909. value: valCode,
  910. label: props.name,
  911. areaId: areaId,
  912. prop: '1'
  913. });
  914. }
  915. if (this.projectMarkerArr) {
  916. this.map.remove(this.projectMarkerArr);
  917. }
  918. if (this.economicsArr) {
  919. this.map.remove(this.economicsArr);
  920. }
  921. if (this.baseMarkerArr) {
  922. this.map.remove(this.baseMarkerArr);
  923. }
  924. if (this.eventMarkersArr) {
  925. this.map.remove(this.eventMarkersArr);
  926. }
  927. if (this.treesMarkerArr) {
  928. this.map.remove(this.treesMarkerArr);
  929. }
  930. }
  931. // }
  932. // }
  933. });
  934. this.switch2AreaNode(adcode);
  935. // this.getProjectList();
  936. },
  937. //根据Hover状态设置相关样式
  938. toggleHoverFeature(feature, isHover, position) {
  939. if (feature.properties.subFeatureIndex != null) {
  940. // this.tipMarker.setMap(isHover ? this.map : null);
  941. // this.tipMarker.setMap(isHover ? this.map : null);
  942. if (!feature) {
  943. return;
  944. }
  945. const props = feature.properties;
  946. // if (isHover) {
  947. // //更新提示内容
  948. // this.$tipMarkerContent.html(props.name);
  949. // //更新位置
  950. // this.tipMarker.setPosition(position || props.center);
  951. // }
  952. //更新相关多边形的样式
  953. const polys = this.districtExplorer.findFeaturePolygonsByAdcode(
  954. props.adcode
  955. );
  956. polys.forEach((elemnt) => {
  957. elemnt.setOptions({
  958. fillColor: '#0dbc79',
  959. fillOpacity: isHover ? 0.5 : 0
  960. });
  961. });
  962. }
  963. },
  964. //绘制某个区域的边界
  965. renderAreaPolygons(areaNode) {
  966. // 加载小班边界
  967. // this.getSmallClass();
  968. let _this = this;
  969. //更新地图视野
  970. if (
  971. (this.$store.state.addr.selectCity.prop == '1' &&
  972. this.$store.state.addr.mapLevel != 'street') ||
  973. this.$store.state.addr.mapLevel == 'province'
  974. ) {
  975. this.map.setBounds(areaNode.getBounds(), null, null, false);
  976. } else if (
  977. this.$store.state.addr.selectCity.prop == '2' &&
  978. this.$store.state.addr.mapLevel != 'province'
  979. ) {
  980. this.map.setFitView(this.smallMarker, false, false, 14);
  981. }
  982. // 加载相关标识
  983. this.mapPolygon();
  984. //清除已有的绘制内容
  985. this.districtExplorer.clearFeaturePolygons();
  986. // 清除已绘制的省市县名称
  987. this.map.remove(this.cityMarkerArr);
  988. //绘制子区域
  989. this.districtExplorer.renderSubFeatures(areaNode, () => {
  990. return {
  991. cursor: 'default',
  992. bubble: true,
  993. strokeColor: 'yellow', //线颜色
  994. strokeOpacity: 1, //线透明度
  995. strokeWeight: 2, //线宽
  996. fillOpacity: 0 //填充透明度
  997. };
  998. });
  999. //绘制父区域
  1000. this.districtExplorer.renderParentFeature(areaNode, {
  1001. cursor: 'default',
  1002. bubble: true,
  1003. strokeColor: '#00eeff', //线颜色
  1004. strokeOpacity: 1, //线透明度
  1005. strokeWeight: 2, //线宽
  1006. fillOpacity: 0 //填充透明度
  1007. });
  1008. let areaPolygon = areaNode.getParentFeature();
  1009. // 绘制父级蒙版
  1010. // if (this.$store.state.addr.mapLevel == 'province' || this.$store.state.addr.mapLevel == 'city') {
  1011. let outer = [
  1012. new AMap.LngLat(-360, 90, true),
  1013. new AMap.LngLat(-360, -90, true),
  1014. new AMap.LngLat(360, -90, true),
  1015. new AMap.LngLat(360, 90, true)
  1016. ];
  1017. let areaPolygonArr = [];
  1018. areaPolygon.geometry.coordinates.forEach((element) => {
  1019. areaPolygonArr.push(element[0]);
  1020. });
  1021. let holes = areaPolygonArr;
  1022. let pathArray = [outer];
  1023. pathArray.push.apply(pathArray, holes);
  1024. this.polygon = new AMap.Polygon({
  1025. pathL: pathArray,
  1026. map: this.map,
  1027. strokeColor: '#00eeff',
  1028. strokeWeight: 1,
  1029. fillColor: '#0c1b05', // 遮罩背景色
  1030. fillOpacity: 0.8,
  1031. height: 10000
  1032. });
  1033. this.polygon.setPath(pathArray);
  1034. // }
  1035. if (this.leftPage == 'forest' || this.leftPage == 'treeSpecies') {
  1036. if (this.map) {
  1037. this.getProjectList();
  1038. }
  1039. }
  1040. if (areaPolygon.properties.level != 'district') {
  1041. // this.setMarker();
  1042. } else {
  1043. this.map.remove(this.treesMarkerArr);
  1044. }
  1045. //查询乡镇 标识
  1046. if (areaPolygon.properties.level == 'district') {
  1047. if (
  1048. this.$store.state.addr.mapLevel != 'street' &&
  1049. this.townPolygons.length == 0
  1050. ) {
  1051. this.getrjx(areaPolygon.properties.name);
  1052. }
  1053. AMap.plugin(['AMap.DistrictSearch'], function () {
  1054. let district = new AMap.DistrictSearch({
  1055. // 返回行政区边界坐标等具体信息
  1056. extensions: 'all',
  1057. // 设置查询行政区级别为 区 (district)
  1058. level: areaPolygon.properties.level,
  1059. // 显示下级行政区级数,1表示返回下一级行政区
  1060. subdistrict: 1
  1061. });
  1062. let areaCode = areaPolygon.properties.name;
  1063. district.search(areaCode, function (status, result) {
  1064. console.log(status);
  1065. console.log(result);
  1066. let streetArr = result.districtList[0].districtList;
  1067. _this.zoom = result.districtList[0]
  1068. for (let elementLs in streetArr) {
  1069. _this.streetMarker = new AMap.Text({
  1070. //c城市指示标
  1071. text: streetArr[elementLs].name,
  1072. zIndex: 1,
  1073. map: _this.map,
  1074. anchor: 'center', // 设置文本标记锚点
  1075. style: {
  1076. padding: '0px 6px',
  1077. color: '#fff',
  1078. border: 'none',
  1079. fontSize: '12px',
  1080. 'background-color': '#E6810C'
  1081. },
  1082. position: [
  1083. streetArr[elementLs].center.lng,
  1084. streetArr[elementLs].center.lat
  1085. ]
  1086. });
  1087. _this.streetMarkerArr.push(_this.streetMarker);
  1088. }
  1089. });
  1090. });
  1091. }
  1092. // 添加城市标识
  1093. let cityArr = areaNode.getSubFeatures();
  1094. if (cityArr) {
  1095. for (let i = 0; i < cityArr.length; i++) {
  1096. this.cityMarker = new AMap.Text({
  1097. //c城市指示标
  1098. text: cityArr[i].properties.name,
  1099. zIndex: 1,
  1100. map: this.map,
  1101. anchor: 'center', // 设置文本标记锚点
  1102. style: {
  1103. padding: '0px 6px',
  1104. color: '#fff',
  1105. border: 'none',
  1106. fontSize: '12px',
  1107. 'background-color': '#E6810C'
  1108. },
  1109. position: cityArr[i].properties.centroid
  1110. });
  1111. this.cityMarkerArr.push(this.cityMarker);
  1112. }
  1113. }
  1114. },
  1115. //切换区域后刷新显示内容
  1116. refreshAreaNode(areaNode) {
  1117. this.districtExplorer.setHoverFeature(null);
  1118. this.renderAreaPolygons(areaNode);
  1119. },
  1120. //切换区域
  1121. switch2AreaNode(adcode, mapLevel, selectStreet, page, callback) {
  1122. // if (
  1123. // this.currentAreaNode &&
  1124. // '' + this.currentAreaNode.getAdcode() === '' + adcode
  1125. // ) {
  1126. // return;
  1127. // }
  1128. this.loadAreaNode(adcode, (error, areaNode) => {
  1129. if (error) {
  1130. if (callback) {
  1131. callback(error);
  1132. }
  1133. return;
  1134. }
  1135. this.currentAreaNode = areaNode;
  1136. //设置当前使用的定位用节点
  1137. this.districtExplorer.setAreaNodesForLocating([this.currentAreaNode]);
  1138. this.refreshAreaNode(areaNode);
  1139. if (callback) {
  1140. callback(null, areaNode);
  1141. }
  1142. });
  1143. },
  1144. // 加载区域
  1145. loadAreaNode(adcode, callback) {
  1146. this.districtExplorer.loadAreaNode(adcode, (error, areaNode) => {
  1147. if (error) {
  1148. if (callback) {
  1149. callback(error);
  1150. }
  1151. window.console.error(error);
  1152. return;
  1153. }
  1154. if (callback) {
  1155. callback(null, areaNode);
  1156. }
  1157. });
  1158. },
  1159. // 加载林场
  1160. // setMarker() {
  1161. // this.forestFarmData = [];
  1162. // if (this.treesMarkerArr.length > 0) {
  1163. // this.map.remove(this.treesMarkerArr);
  1164. // }
  1165. // farmInfo().then((res) => {
  1166. // this.forestFarmData = res.rows;
  1167. // let parentMarker = require('@/assets/img/pre-marker.png');
  1168. // this.forestFarmData.forEach((item) => {
  1169. // let selectCity = this.$store.state.addr.selectCity.label;
  1170. // switch (this.$store.state.addr.selectCity.label) {
  1171. // case '黔西南州':
  1172. // selectCity = '黔西南布依族苗族自治州';
  1173. // break;
  1174. // case '黔东南州':
  1175. // selectCity = '黔东南苗族侗族自治州';
  1176. // break;
  1177. // case '黔南州':
  1178. // selectCity = '黔南布依族苗族自治州';
  1179. // break;
  1180. // }
  1181. // if (this.$store.state.addr.selectCity.label) {
  1182. // if (selectCity == item.cityName) {
  1183. // let lngLat = [item.longitude, item.latitude];
  1184. // this.treesMarker = new AMap.Marker({
  1185. // map: this.map,
  1186. // position: lngLat,
  1187. // icon: parentMarker,
  1188. // anchor: 'bottom-center',
  1189. // offset: new AMap.Pixel(0, 0)
  1190. // });
  1191. // this.treesMarker.setLabel({
  1192. // direction: 'bottom',
  1193. // offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
  1194. // content: `<div>${item.forestName}</div>` //设置文本标注内容
  1195. // });
  1196. // this.treesMarkerArr.push(this.treesMarker);
  1197. // }
  1198. // } else {
  1199. // let lngLat = [item.longitude, item.latitude];
  1200. // this.treesMarker = new AMap.Marker({
  1201. // map: this.map,
  1202. // position: lngLat,
  1203. // icon: parentMarker,
  1204. // anchor: 'bottom-center',
  1205. // offset: new AMap.Pixel(0, 0)
  1206. // });
  1207. // this.treesMarker.setLabel({
  1208. // direction: 'bottom',
  1209. // offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
  1210. // content: `<div>${item.forestName}</div>` //设置文本标注内容
  1211. // });
  1212. // this.treesMarkerArr.push(this.treesMarker);
  1213. // }
  1214. // });
  1215. // });
  1216. // },
  1217. // 查询项目列表
  1218. getProjectList() {
  1219. let params = {
  1220. cityId: this.$store.state.addr.selectCity.areaId,
  1221. countyId: this.$store.state.addr.selectDistrict.areaId,
  1222. townId: this.$store.state.addr.selectStreet.areaId
  1223. };
  1224. // image: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
  1225. projectList(params).then((res) => {
  1226. if (res.code == 200) {
  1227. let infoIcon = new AMap.Icon({
  1228. size: new AMap.Size(20, 25), // 图标尺寸
  1229. image: this.projectIcon,
  1230. imageSize: new AMap.Size(20, 25) // 根据所设置的大小拉伸或压缩图片
  1231. });
  1232. res.rows.forEach((element) => {
  1233. if (element.longitude && element.latitude) {
  1234. let lnglat = new AMap.LngLat(element.longitude, element.latitude);
  1235. var projectMarker = new AMap.Marker({
  1236. map: this.map,
  1237. position: lnglat,
  1238. offset: new AMap.Pixel(0, -30),
  1239. icon: infoIcon,
  1240. zIndex: 999,
  1241. topWhenClick: true
  1242. });
  1243. this.projectMarkerArr.push(projectMarker);
  1244. }
  1245. });
  1246. }
  1247. });
  1248. },
  1249. // 加载乡镇边界
  1250. getrjx(cityName) {
  1251. if (cityName == '榕江县') {
  1252. axios.get('/static/rongjangintown.json').then((res) => {
  1253. this.putPolygonData = res.data.features;
  1254. this.putPolygon();
  1255. });
  1256. } else if (cityName == '清镇市') {
  1257. axios.get('/static/qingzhenzhen.json').then((res) => {
  1258. this.putPolygonData = res.data.features;
  1259. this.putPolygon();
  1260. });
  1261. }
  1262. },
  1263. putPolygon() {
  1264. let that = this;
  1265. this.putPolygonData.forEach((element) => {
  1266. this.boundaryPolygon = new AMap.Polygon({
  1267. map: that.map,
  1268. path: element.geometry.coordinates,
  1269. strokeOpacity: 1,
  1270. fillOpacity: 0,
  1271. strokeColor: 'yellow',
  1272. strokeWeight: 1,
  1273. zIndex: 999,
  1274. cursor: 'pointer'
  1275. });
  1276. that.townPolygons.push(this.boundaryPolygon);
  1277. this.boundaryPolygon.on('click', (e) => {
  1278. let centerLanLatArr = [e.lnglat.lng, e.lnglat.lat];
  1279. that.map.remove(that.townPolygons);
  1280. // that.districtExplorer.clearFeaturePolygons();
  1281. let valCode = element.properties.XIANG;
  1282. let areaId = '';
  1283. let label = element.properties.XIANG_NAME;
  1284. this.vuexStreetList.forEach((item) => {
  1285. if (valCode == item.areaCode) {
  1286. areaId = item.areaId;
  1287. }
  1288. });
  1289. this.changeSelectStreet({
  1290. value: valCode,
  1291. label: label,
  1292. areaId: areaId,
  1293. prop: '1'
  1294. });
  1295. this.changeSelectAddr('street');
  1296. this.$store.dispatch('searchArea', {
  1297. parentId: valCode,
  1298. name: label,
  1299. mapLevel: 'street'
  1300. });
  1301. let townPolygon = new AMap.Polygon({
  1302. map: that.map,
  1303. path: element.geometry.coordinates,
  1304. strokeColor: 'yellow',
  1305. strokeWeight: 3,
  1306. fillOpacity: 0
  1307. });
  1308. this.townPolygonArr.push(townPolygon);
  1309. that.map.setZoomAndCenter(14, centerLanLatArr, false, 13);
  1310. });
  1311. that.boundaryPolygon.on('rightclick', function (e) {
  1312. if (
  1313. that.smallMarkers ||
  1314. that.baseMarkers ||
  1315. that.eventMarkers ||
  1316. that.smallClassProject ||
  1317. that.projectPolygonArr
  1318. ) {
  1319. that.map.remove(that.smallMarkers);
  1320. that.map.remove(that.baseMarkers);
  1321. that.map.remove(that.eventMarkers);
  1322. that.map.remove(that.smallClassProject);
  1323. that.map.remove(that.projectPolygonArr);
  1324. }
  1325. });
  1326. });
  1327. },
  1328. async getSmallClass() {
  1329. let that = this;
  1330. that.smallClassMapArr = [];
  1331. let params = {
  1332. // cityId: that.$store.state.addr.selectCity.areaId,
  1333. // countyId: that.$store.state.addr.selectDistrict.areaId,
  1334. townId: this.$store.state.addr.selectStreet.areaId
  1335. };
  1336. if (that.smallClassPolygonArr.length > 0) {
  1337. that.map.remove(that.smallClassPolygonArr);
  1338. }
  1339. if (that.treesPolygonArr.length > 0) {
  1340. that.map.remove(that.treesPolygonArr);
  1341. }
  1342. // let pageData = {
  1343. // pageNum: 0,
  1344. // pageSize: 25
  1345. // };
  1346. let mapLevel = that.$store.state.addr.mapLevel;
  1347. let res = await smallClassMap({ ...params });
  1348. if (res.code == 200) {
  1349. res.rows.forEach((item) => {
  1350. // if (item.smallId != null) {
  1351. // }
  1352. // this.smallClassMapArr.push(item);
  1353. if (that.leftPage === 'forest') {
  1354. this.addForestPolygon(item);
  1355. } else if (this.leftPage === 'treeSpecies') {
  1356. this.addTreeSpeciesPolygon(item);
  1357. }
  1358. });
  1359. }
  1360. // if (res.code == 200 && res.total > 25) {
  1361. // const total = res.total;
  1362. // const totalPage = Math.ceil(total / pageData.pageSize);
  1363. // const render = (page, mapLevel) => {
  1364. // if (page >= totalPage) return;
  1365. // requestAnimationFrame(() => {
  1366. // render(page + 1, mapLevel);
  1367. // pageData.pageNum = page;
  1368. // smallClassMap({ ...params, ...pageData }).then((response) => {
  1369. // if (response.code == 200) {
  1370. // response.rows.forEach((item) => {
  1371. // // if (item.smallId != null) {
  1372. // // }
  1373. // // this.smallClassMapArr.push(item);
  1374. // if (that.leftPage === 'forest') {
  1375. // this.addForestPolygon(item);
  1376. // } else if (this.leftPage === 'treeSpecies') {
  1377. // this.addTreeSpeciesPolygon(item);
  1378. // }
  1379. // });
  1380. // }
  1381. // });
  1382. // });
  1383. // };
  1384. // render(pageData.pageNum, mapLevel);
  1385. // } else {
  1386. // res.rows.forEach((item) => {
  1387. // if (that.leftPage === 'forest') {
  1388. // this.addForestPolygon(item);
  1389. // } else if (this.leftPage === 'treeSpecies') {
  1390. // this.addTreeSpeciesPolygon(item);
  1391. // }
  1392. // });
  1393. // }
  1394. },
  1395. mapPolygon() {
  1396. // if (this.smallClassMapArr) {
  1397. // if (this.leftPage === 'forest') {
  1398. // // this.addForestPolygon(this.smallClassMapArr);
  1399. // if (
  1400. // // this.$store.state.addr.mapLevel == 'district' ||
  1401. // this.$store.state.addr.mapLevel == 'street'
  1402. // ) {
  1403. // this.getForestSample(this.leftPage);
  1404. // }
  1405. // } else if (this.leftPage === 'treeSpecies') {
  1406. // // this.addTreeSpeciesPolygon();
  1407. // if (
  1408. // // this.$store.state.addr.mapLevel == 'district' ||
  1409. // this.$store.state.addr.mapLevel == 'street'
  1410. // ) {
  1411. // this.getRightScrollData(this.leftPage);
  1412. // }
  1413. // } else
  1414. if (this.leftPage === 'economics') {
  1415. this.getEconomics();
  1416. } else if (this.leftPage === 'event') {
  1417. this.getEven();
  1418. }
  1419. // }
  1420. },
  1421. addForestPolygon(item) {
  1422. let that = this;
  1423. if (item) {
  1424. // console.log(item);
  1425. // smallClassMapArr.forEach((item) => {
  1426. let polyData = JSON.parse(item.mapInfo);
  1427. for (let elementLs in polyData.features) {
  1428. let smallClassPolygon = new AMap.Polygon({
  1429. map: that.map,
  1430. path: polyData.features[elementLs].geometry.coordinates,
  1431. strokeOpacity: 1,
  1432. fillOpacity: 0,
  1433. strokeColor: 'red',
  1434. strokeWeight: 2,
  1435. zIndex: 999,
  1436. cursor: 'pointer',
  1437. fillColor: ''
  1438. });
  1439. this.smallClassPolygonArr.push(smallClassPolygon);
  1440. smallClassPolygon.on('click', (e) => {
  1441. let imgList = [];
  1442. if (item.imageList.length > 0) {
  1443. item.imageList.forEach((element) => {
  1444. imgList.push(`<img id="markerLabel" src="${element.image}"/>`);
  1445. });
  1446. } else {
  1447. imgList.push('暂无图片');
  1448. }
  1449. this.imgClick();
  1450. let smallLabel =
  1451. "<div class='info-details'>" +
  1452. "<h5 class='marker-title'>" +
  1453. item.countyName +
  1454. '-' +
  1455. item.smallNumber +
  1456. '</h5>' +
  1457. "<div class='marker-content'>" +
  1458. '<div>' +
  1459. '<p>小班号:' +
  1460. item.smallNumber +
  1461. '</p>' +
  1462. '<p>样地数:' +
  1463. item.sampleCount +
  1464. '</p>' +
  1465. '<p>小班蓄积量:' +
  1466. item.smallClassStock +
  1467. '(立方米)' +
  1468. '</p>' +
  1469. '<p>小班占地面积:' +
  1470. item.landArea +
  1471. '(亩)' +
  1472. '</p>' +
  1473. '<p>小班树种组成:' +
  1474. item.treeComp +
  1475. '</p>' +
  1476. '<p>地类:' +
  1477. item.landType +
  1478. '</p>' +
  1479. '<p>林地权属:' +
  1480. item.landOwner +
  1481. '</p>' +
  1482. '<p>林木权属:' +
  1483. item.forestOwner +
  1484. '</p>' +
  1485. '<p>林种:' +
  1486. item.forestClass +
  1487. '</p>' +
  1488. '<p>树种结构:' +
  1489. item.treeStruct +
  1490. '</p>' +
  1491. '</div>' +
  1492. '<div>' +
  1493. '<p>起源:' +
  1494. item.origin +
  1495. '</p>' +
  1496. '<p>优势树种:' +
  1497. item.superTree +
  1498. '</p>' +
  1499. '<p>主要灌木名称:' +
  1500. item.shrubName +
  1501. '</p>' +
  1502. '<p>地貌:' +
  1503. item.landForm +
  1504. '</p>' +
  1505. '<p>海拔:' +
  1506. item.altitude +
  1507. '</p>' +
  1508. '<p>坡位:' +
  1509. item.slopePosit +
  1510. '</p>' +
  1511. '<p>坡向:' +
  1512. item.slopeDirect +
  1513. '</p>' +
  1514. '<p>坡形:' +
  1515. item.slopeForm +
  1516. '</p>' +
  1517. '<p>坡度:' +
  1518. item.slope +
  1519. '</p>' +
  1520. '<p>森林健康度:' +
  1521. item.forestHealth +
  1522. '</p>' +
  1523. '</div>' +
  1524. '</div>' +
  1525. '<div class="imgList">' +
  1526. "<span class='marker-span'>图片:</span>" +
  1527. '<div class="marker-imgs">' +
  1528. imgList +
  1529. '</div>' +
  1530. '</div>' +
  1531. '</div>';
  1532. that.smallMarker = new AMap.Marker({
  1533. map: that.map,
  1534. position: lanLatArr,
  1535. icon: require('@/assets/img/small-marker.png'),
  1536. anchor: 'bottom-center',
  1537. offset: new AMap.Pixel(-5, -6)
  1538. });
  1539. that.smallMarker.setLabel({
  1540. direction: 'right',
  1541. offset: new AMap.Pixel(-230, -160), //设置文本标注偏移量
  1542. content: smallLabel //设置文本标注内容
  1543. });
  1544. // that.smallMarker.setMap(that.map);
  1545. that.smallMarkers.push(that.smallMarker);
  1546. smallClassPolygon.setOptions({
  1547. fillOpacity: 0.7,
  1548. fillColor: 'yellow'
  1549. });
  1550. });
  1551. smallClassPolygon.on('mouseout', () => {
  1552. smallClassPolygon.setOptions({
  1553. fillOpacity: 0,
  1554. fillColor: '#ccebc5'
  1555. });
  1556. });
  1557. }
  1558. if (item.longitude && item.latitude) {
  1559. var lanLatArr = [];
  1560. lanLatArr = [item.longitude, item.latitude];
  1561. if (
  1562. this.$store.state.addr.mapLevel == 'district' ||
  1563. this.$store.state.addr.mapLevel == 'street'
  1564. ) {
  1565. this.smallClassN = new AMap.Text({
  1566. map: this.map,
  1567. position: lanLatArr,
  1568. text: item.smallNumber,
  1569. anchor: 'bottom-center',
  1570. offset: new AMap.Pixel(0, 8),
  1571. style: {
  1572. 'background-color': 'transparent',
  1573. border: 'none',
  1574. color: '#05dfff',
  1575. fontSize: '12px'
  1576. }
  1577. });
  1578. this.smallClassNArr.push(this.smallClassN);
  1579. }
  1580. }
  1581. // this.map.add(that.smallClassPolygon);
  1582. // });
  1583. }
  1584. },
  1585. imgClick() {
  1586. document.getElementsByTagName('div')[0].addEventListener('click', (e) => {
  1587. if (e.target.id === 'markerLabel') {
  1588. this.imgDialogVisible = true;
  1589. this.dialogImageUrl = e.target.currentSrc;
  1590. }
  1591. });
  1592. },
  1593. // 获取样地数据
  1594. getForestSample(page) {
  1595. forestSample({
  1596. // cityId: this.$store.state.addr.selectCity.areaId,
  1597. // countyId: this.$store.state.addr.selectDistrict.areaId,
  1598. townId: this.$store.state.addr.selectStreet.areaId
  1599. }).then((res) => {
  1600. let sampleMarker = require('@/assets/img/sample-marker.png');
  1601. let iconMeta = [28, 28];
  1602. this.setMarkers(res, sampleMarker, iconMeta, page);
  1603. });
  1604. },
  1605. // 添加地图标注(样地、树种)
  1606. setMarkers(res, sampleMarker, iconMeta, page) {
  1607. let _this = this;
  1608. if (this.forestMarker) {
  1609. this.forestMarker.setMap(null);
  1610. this.forestMarker = null;
  1611. }
  1612. this.markerData = res;
  1613. let iconMarker = sampleMarker;
  1614. let iconMetaSet = iconMeta;
  1615. let sampleIcon = new AMap.Icon({
  1616. size: new AMap.Size(iconMetaSet[0], iconMetaSet[1]), // 图标尺寸
  1617. image: iconMarker,
  1618. imageSize: new AMap.Size(iconMetaSet[0], iconMetaSet[1]) // 根据所设置的大小拉伸或压缩图片
  1619. });
  1620. this.markerData.rows.forEach((item) => {
  1621. let lngLat = [item.longitude, item.latitude];
  1622. if (item.longitude && item.latitude) {
  1623. this.forestMarker = new AMap.Marker({
  1624. map: _this.map,
  1625. position: lngLat,
  1626. icon: sampleIcon,
  1627. anchor: 'bottom-center',
  1628. offset: new AMap.Pixel(0, -18)
  1629. });
  1630. if (page === 'forest') {
  1631. this.forestMarker.setLabel({
  1632. direction: 'right',
  1633. offset: new AMap.Pixel(-8, 0), //设置文本标注偏移量
  1634. content: `<div style="color:#05dfff">${item.smallNumber}-${item.sampleNumber}</div>` //设置文本标注内容
  1635. });
  1636. let clickLabel =
  1637. "<div class='info-small'>" +
  1638. "<h5 class='marker-title'>" +
  1639. item.smallNumber +
  1640. '-' +
  1641. item.sampleNumber +
  1642. '</h5>' +
  1643. "<div class='marker-content'>" +
  1644. '<p>样地号:' +
  1645. item.sampleNumber +
  1646. '</p>' +
  1647. '<p>所属小班:' +
  1648. item.smallNumber +
  1649. '</p>' +
  1650. '<p>样地蓄积:' +
  1651. item.landStock +
  1652. '</p>' +
  1653. '<p>样地株数:' +
  1654. item.landNumber +
  1655. '</p>' +
  1656. '</div>' +
  1657. '</div>';
  1658. let lastMarker = new AMap.Marker({
  1659. position: lngLat,
  1660. icon: sampleIcon,
  1661. anchor: 'bottom-center',
  1662. offset: new AMap.Pixel(0, -18)
  1663. });
  1664. lastMarker.setLabel({
  1665. zIndex: 120,
  1666. direction: 'top',
  1667. offset: new AMap.Pixel(-4, 0), //设置文本标注偏移量
  1668. content: clickLabel //设置文本标注内容
  1669. });
  1670. this.forestMarker.on('click', function (e) {
  1671. _this.map.add(lastMarker);
  1672. });
  1673. this.forestMarker.on('mouseout', function (e) {
  1674. _this.map.remove(lastMarker);
  1675. });
  1676. } else if (page === 'treeSpecies') {
  1677. this.forestMarker.setLabel({
  1678. direction: 'top',
  1679. offset: new AMap.Pixel(0, 8), //设置文本标注偏移量
  1680. content: `<div class="label-treecomp">${item.treeComp}<span class="smallH">${item.smallNumber}</span></div>` //设置文本标注内容
  1681. });
  1682. }
  1683. // this.map.add(this.forestMarker);
  1684. // forestMarker
  1685. this.forestMarkerArr.push(this.forestMarker);
  1686. }
  1687. });
  1688. },
  1689. addTreeSpeciesPolygon(item) {
  1690. let that = this;
  1691. // that.smallClassMapArr.forEach((item) => {
  1692. let polyData = JSON.parse(item.mapInfo);
  1693. for (let elementLs in polyData.features) {
  1694. let polygonColor = '';
  1695. this.treePlant.forEach((tree) => {
  1696. if (tree.plantName == item.superTree && item.superTree == '硬阔') {
  1697. polygonColor = '#00da85';
  1698. } else if (
  1699. tree.plantName == item.superTree &&
  1700. item.superTree == '软阔'
  1701. ) {
  1702. polygonColor = '#009bfd';
  1703. } else if (
  1704. tree.plantName == item.superTree &&
  1705. item.superTree == '杉木'
  1706. ) {
  1707. polygonColor = '#eca62d';
  1708. } else if (
  1709. tree.plantName == item.superTree &&
  1710. item.superTree == '马尾松'
  1711. ) {
  1712. polygonColor = '#b82dec';
  1713. }
  1714. });
  1715. let polygon = new AMap.Polygon({
  1716. map: that.map,
  1717. path: polyData.features[elementLs].geometry.coordinates,
  1718. strokeOpacity: 1,
  1719. fillOpacity: 0.6,
  1720. strokeColor: 'red',
  1721. strokeWeight: 2,
  1722. zIndex: 999,
  1723. cursor: 'pointer',
  1724. fillColor: polygonColor
  1725. });
  1726. this.treesPolygonArr.push(polygon);
  1727. if (item.longitude && item.latitude) {
  1728. var lanLatArr = [];
  1729. // polygon.on('click', (e) => {
  1730. lanLatArr = [item.longitude, item.latitude];
  1731. let treeSmallLabel =
  1732. "<div class='info-small'>" +
  1733. "<h5 class='marker-title'>小班" +
  1734. item.smallNumber +
  1735. '</h5>' +
  1736. "<div class='marker-content'>" +
  1737. '<p>树种组成:' +
  1738. item.treeComp +
  1739. '</p>' +
  1740. '<p>树种结构:' +
  1741. item.treeStruct +
  1742. '</p>' +
  1743. '<p>优势树种:' +
  1744. item.superTree +
  1745. '</p>' +
  1746. '<p>优势树种平均胸径:' +
  1747. item.superTreeDbh +
  1748. '厘米' +
  1749. '</p>' +
  1750. '<p>优势树种平均高:' +
  1751. item.superTreeHigh +
  1752. '米' +
  1753. '</p>' +
  1754. '<p>位置:' +
  1755. item.countyName +
  1756. item.townName +
  1757. item.villageName +
  1758. '</p>' +
  1759. '</div>' +
  1760. '</div>';
  1761. that.smallMarker = new AMap.Marker({
  1762. map: that.map,
  1763. position: lanLatArr,
  1764. icon: require('@/assets/img/small-marker.png'),
  1765. anchor: 'bottom-center',
  1766. offset: new AMap.Pixel(0, 0)
  1767. });
  1768. that.smallMarker.setLabel({
  1769. direction: 'top',
  1770. offset: new AMap.Pixel(-10, 0), //设置文本标注偏移量
  1771. content: treeSmallLabel //设置文本标注内容
  1772. });
  1773. that.treeCompMarkers.push(that.smallMarker);
  1774. if (
  1775. this.$store.state.addr.mapLevel == 'street' ||
  1776. this.$store.state.addr.mapLevel == 'district'
  1777. ) {
  1778. this.map.setFitView(this.smallMarker, false, false, 14);
  1779. }
  1780. // });
  1781. that.smallMarker.on('click', (e) => {
  1782. if (that.treesPolygonArr) {
  1783. that.map.remove(that.treesPolygonArr);
  1784. }
  1785. if (that.treeCompMarkers) {
  1786. that.map.remove(that.treeCompMarkers);
  1787. }
  1788. });
  1789. that.map.on('rightclick', function (e) {
  1790. if (that.treeCompMarkers) {
  1791. that.map.remove(that.treeCompMarkers);
  1792. }
  1793. if (that.treesPolygonArr) {
  1794. that.map.remove(that.treesPolygonArr);
  1795. }
  1796. });
  1797. }
  1798. }
  1799. // });
  1800. },
  1801. // 获取小班列表
  1802. getRightScrollData(page) {
  1803. rightScrollData({
  1804. // cityId: this.$store.state.addr.selectCity.areaId,
  1805. // countyId: this.$store.state.addr.selectDistrict.areaId,
  1806. townId: this.$store.state.addr.selectStreet.areaId
  1807. }).then((res) => {
  1808. let sampleMarker = require('@/assets/img/sanjiaod.png');
  1809. let iconMeta = [16, 10];
  1810. this.setMarkers(res, sampleMarker, iconMeta, page);
  1811. });
  1812. },
  1813. // 事件信息
  1814. getEven() {
  1815. let _this = this;
  1816. alarmDataApi({
  1817. cityId: this.$store.state.addr.selectCity.areaId,
  1818. countyId: this.$store.state.addr.selectDistrict.areaId,
  1819. townId: this.$store.state.addr.selectStreet.areaId
  1820. }).then((res) => {
  1821. res.data.forEach((item) => {
  1822. let lanLatArr = [item.longitude, item.latitude];
  1823. let baseIcon = '';
  1824. let fireIcon = require('@/assets/img/fire.png');
  1825. let cutTreeIcon = require('@/assets/img/cutTree.png');
  1826. let insectpestIcon = require('@/assets/img/insectpest.png');
  1827. let stealIcon = require('@/assets/img/steal.png');
  1828. if (item.eventType == 1) {
  1829. item.eventContLabel = '火灾';
  1830. baseIcon = fireIcon;
  1831. } else if (item.eventType == 2) {
  1832. item.eventContLabel = '砍伐';
  1833. baseIcon = cutTreeIcon;
  1834. } else if (item.eventType == 3) {
  1835. item.eventContLabel = '病虫害';
  1836. baseIcon = insectpestIcon;
  1837. } else if (item.eventType == 4) {
  1838. item.eventContLabel = '偷盗林木';
  1839. baseIcon = stealIcon;
  1840. }
  1841. let baseIconData = new AMap.Icon({
  1842. size: new AMap.Size(35, 35), // 图标尺寸
  1843. image: baseIcon,
  1844. imageSize: new AMap.Size(35, 35) // 根据所设置的大小拉伸或压缩图片
  1845. });
  1846. let treeSmallLabel =
  1847. "<div class='info-small'>" +
  1848. "<h5 class='marker-title'>最新事件" +
  1849. '</h5>' +
  1850. "<div class='marker-content'>" +
  1851. '<p>事件类型:' +
  1852. item.eventContLabel +
  1853. '</p>' +
  1854. '<p>上报时间:' +
  1855. item.createTime +
  1856. '</p>' +
  1857. '<p>上报人:' +
  1858. item.createBy +
  1859. '</p>' +
  1860. '<p>位置:' +
  1861. item.cityName +
  1862. item.countyName +
  1863. item.townName +
  1864. item.villageName +
  1865. '</p>' +
  1866. '</div>' +
  1867. '</div>';
  1868. _this.smallMarker = new AMap.Marker({
  1869. map: _this.map,
  1870. position: lanLatArr,
  1871. icon: baseIconData,
  1872. anchor: 'bottom-center',
  1873. offset: new AMap.Pixel(0, 0),
  1874. zIndex: 999
  1875. });
  1876. _this.eventMarkersArr.push(_this.smallMarker);
  1877. _this.smallMarker.on('click', function (e) {
  1878. let infoWindow = new AMap.InfoWindow({
  1879. isCustom: true,
  1880. offset: new AMap.Pixel(0, -20),
  1881. content: treeSmallLabel,
  1882. position: lanLatArr
  1883. });
  1884. infoWindow.open(_this.map, lanLatArr);
  1885. });
  1886. _this.smallMarker.on('mouseout', function (e) {
  1887. _this.map.clearInfoWindow();
  1888. });
  1889. });
  1890. });
  1891. },
  1892. // 林业经济
  1893. getEconomics() {
  1894. let _this = this;
  1895. financeBasePlant({
  1896. cityId: this.$store.state.addr.selectCity.areaId,
  1897. countyId: this.$store.state.addr.selectDistrict.areaId
  1898. // townId: this.$store.state.addr.selectStreet.areaId
  1899. }).then((res) => {
  1900. let economicsList = [];
  1901. let baseList = [];
  1902. res.rows.forEach((element) => {
  1903. economicsList.push({
  1904. longitude: element.cateLongitude,
  1905. latitude: element.cateLatitude,
  1906. icon: element.image
  1907. });
  1908. baseList.push({
  1909. baseId: element.baseId,
  1910. baseName: element.baseName,
  1911. longitude: element.baseLongitude,
  1912. latitude: element.baseLatitude
  1913. });
  1914. });
  1915. economicsList.forEach((item) => {
  1916. let lanLatArr = [item.longitude, item.latitude];
  1917. let beeIcon = item.icon;
  1918. let iconMeta = [35, 26];
  1919. let sampleIcon = new AMap.Icon({
  1920. size: new AMap.Size(iconMeta[0], iconMeta[1]), // 图标尺寸
  1921. image: beeIcon,
  1922. imageSize: new AMap.Size(iconMeta[0], iconMeta[1]) // 根据所设置的大小拉伸或压缩图片
  1923. });
  1924. this.smallMarker = new AMap.Marker({
  1925. map: _this.map,
  1926. position: lanLatArr,
  1927. icon: sampleIcon,
  1928. anchor: 'bottom-center',
  1929. offset: new AMap.Pixel(0, 0)
  1930. });
  1931. this.economicsArr.push(this.smallMarker);
  1932. // this.smallMarker.setMap(this.map);
  1933. });
  1934. baseList.forEach((element) => {
  1935. let lanLatArr = [element.longitude, element.latitude];
  1936. let baseIcon = require('@/assets/img/postion.png');
  1937. let iconMeta = [20, 29];
  1938. let sampleIcon = new AMap.Icon({
  1939. size: new AMap.Size(iconMeta[0], iconMeta[1]), // 图标尺寸
  1940. image: baseIcon,
  1941. imageSize: new AMap.Size(iconMeta[0], iconMeta[1]) // 根据所设置的大小拉伸或压缩图片
  1942. });
  1943. this.baseMarker = new AMap.Marker({
  1944. map: this.map,
  1945. position: lanLatArr,
  1946. icon: sampleIcon,
  1947. anchor: 'bottom-center',
  1948. offset: new AMap.Pixel(0, 0)
  1949. });
  1950. this.baseMarker.setLabel({
  1951. direction: 'right',
  1952. offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
  1953. content: `<div>${element.baseName}</div>` //设置文本标注内容
  1954. });
  1955. this.baseMarkerArr.push(this.baseMarker);
  1956. this.baseMarker.on('click', function (e) {
  1957. financeBaseDetail({ baseId: element.baseId }).then((res) => {
  1958. if (res.code == 200) {
  1959. let treeSmallLabel =
  1960. "<div class='info-small'>" +
  1961. "<h5 class='marker-title'>" +
  1962. res.data.baseName +
  1963. '</h5>' +
  1964. "<div class='marker-content'>" +
  1965. '<p>基地名称:' +
  1966. res.data.baseName +
  1967. '</p>' +
  1968. '<p>种植/养殖/加工作物:' +
  1969. res.data.cropName +
  1970. '</p>' +
  1971. '<p>占地面积:' +
  1972. res.data.baseArea +
  1973. '亩' +
  1974. '</p>' +
  1975. '<p>位置:' +
  1976. res.data.cityName +
  1977. res.data.countyName +
  1978. res.data.townName +
  1979. '</p>' +
  1980. '</div>' +
  1981. '</div>';
  1982. let infoWindow = new AMap.InfoWindow({
  1983. isCustom: true,
  1984. offset: new AMap.Pixel(0, -20),
  1985. content: treeSmallLabel,
  1986. position: lanLatArr
  1987. });
  1988. infoWindow.open(_this.map, lanLatArr);
  1989. }
  1990. });
  1991. });
  1992. this.baseMarker.on('mouseout', function (e) {
  1993. _this.map.clearInfoWindow();
  1994. });
  1995. });
  1996. });
  1997. },
  1998. getTreePlant() {
  1999. treePlant().then((res) => {
  2000. this.treePlant = res.rows;
  2001. });
  2002. }
  2003. }
  2004. };
  2005. </script>
  2006. <style lang='scss' scoped>
  2007. #container {
  2008. width: 100%;
  2009. height: 100vh;
  2010. /deep/ .tdt-pane {
  2011. z-index: auto;
  2012. }
  2013. }
  2014. /deep/ .amap-marker-content {
  2015. .tipMarker {
  2016. color: #555;
  2017. background-color: rgba(255, 254, 239, 0.8);
  2018. border: 1px solid #7e7e7e;
  2019. padding: 2px 6px;
  2020. font-size: 12px;
  2021. white-space: nowrap;
  2022. display: inline-block;
  2023. &:before,
  2024. &:after {
  2025. content: '';
  2026. display: block;
  2027. position: absolute;
  2028. margin: auto;
  2029. width: 0;
  2030. height: 0;
  2031. border: solid transparent;
  2032. border-width: 5px 5px;
  2033. }
  2034. &.top {
  2035. transform: translate(-50%, -110%);
  2036. &:before,
  2037. &:after {
  2038. bottom: -9px;
  2039. left: 0;
  2040. right: 0;
  2041. border-top-color: rgba(255, 254, 239, 0.8);
  2042. }
  2043. &:before {
  2044. bottom: -10px;
  2045. border-top-color: #7e7e7e;
  2046. }
  2047. }
  2048. }
  2049. }
  2050. /deep/ .amap-logo,
  2051. .amap-copyright {
  2052. display: block !important;
  2053. visibility: inherit !important;
  2054. }
  2055. /deep/ .amap-icon {
  2056. overflow: unset !important;
  2057. }
  2058. /deep/ .info-small {
  2059. background-image: url('../assets/img/small-label.png');
  2060. background-repeat: no-repeat;
  2061. background-size: 100% 100%;
  2062. width: 18rem;
  2063. // height: 10rem;
  2064. color: #fff;
  2065. .marker-title {
  2066. margin: 0 auto;
  2067. line-height: 30px;
  2068. }
  2069. .marker-content {
  2070. padding: 0 20px 10px 20px;
  2071. p {
  2072. text-align: left;
  2073. font-size: 12px;
  2074. margin: 0;
  2075. line-height: 28px;
  2076. }
  2077. }
  2078. }
  2079. /deep/ .info-details {
  2080. background-image: url('../assets/img/small-label.png');
  2081. background-repeat: no-repeat;
  2082. background-size: 100% 100%;
  2083. width: 26rem;
  2084. padding-bottom: 13px;
  2085. // height: 10rem;
  2086. color: #fff;
  2087. .marker-title {
  2088. margin: 0 auto;
  2089. line-height: 50px;
  2090. }
  2091. .marker-content {
  2092. display: flex;
  2093. justify-content: space-between;
  2094. padding: 0 20px 0 20px;
  2095. .marker-span {
  2096. display: block;
  2097. }
  2098. p {
  2099. text-align: left;
  2100. font-size: 12px;
  2101. margin: 0;
  2102. line-height: 18px;
  2103. }
  2104. }
  2105. .imgList {
  2106. display: block;
  2107. text-align: left;
  2108. padding: 0 20px;
  2109. .marker-span {
  2110. display: block;
  2111. }
  2112. .marker-imgs {
  2113. display: block;
  2114. line-height: 18px !important;
  2115. width: 376px;
  2116. overflow: auto;
  2117. img {
  2118. width: 40px;
  2119. height: 40px;
  2120. margin: 0 4px;
  2121. cursor: pointer;
  2122. }
  2123. }
  2124. .marker-imgs::-webkit-scrollbar {
  2125. background: transparent;
  2126. opacity: 0.6px;
  2127. width: 10px;
  2128. height: 8px;
  2129. }
  2130. .marker-imgs::-webkit-scrollbar-thumb {
  2131. background: rgba($color: #07a2eb8e, $alpha: 0.6);
  2132. border-radius: 20px;
  2133. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  2134. }
  2135. .marker-imgs::-webkit-scrollbar-track {
  2136. /*滚动条里面轨道*/
  2137. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  2138. border-radius: 10px;
  2139. background: transparent;
  2140. }
  2141. }
  2142. }
  2143. /deep/ .amap-marker-label {
  2144. border: 0;
  2145. background-color: transparent;
  2146. }
  2147. #mask {
  2148. width: 100%;
  2149. height: 100vh;
  2150. box-shadow: inset 0px 0px 10vw 8vw rgba(0, 10, 34, 0.54);
  2151. position: fixed;
  2152. left: 0;
  2153. right: 0;
  2154. bottom: 0;
  2155. top: 0;
  2156. pointer-events: none;
  2157. }
  2158. @keyframes imageAnimation_32630606 {
  2159. 0% {
  2160. // opacity: 0;
  2161. transform: none;
  2162. }
  2163. 34% {
  2164. // opacity: 1;
  2165. transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1)
  2166. translate3d(34vw, 0px, 0px);
  2167. }
  2168. 67% {
  2169. // opacity: 1;
  2170. transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1)
  2171. translate3d(67vw, 0px, 0px);
  2172. }
  2173. 100% {
  2174. // opacity: 0;
  2175. transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1)
  2176. translate3d(160vw, 0px, 0px);
  2177. }
  2178. }
  2179. .yun-wrap {
  2180. position: fixed;
  2181. left: 0;
  2182. top: 350px;
  2183. width: 100vw;
  2184. pointer-events: none;
  2185. }
  2186. .yun {
  2187. position: fixed;
  2188. left: -500px;
  2189. animation-name: imageAnimation_32630606;
  2190. animation-iteration-count: infinite;
  2191. animation-timing-function: linear;
  2192. animation-duration: 110s;
  2193. animation-delay: 0s;
  2194. -webkit-user-drag: none;
  2195. filter: none;
  2196. pointer-events: none;
  2197. }
  2198. .yun2 {
  2199. bottom: 20px;
  2200. animation-duration: 90s;
  2201. animation-delay: 10s;
  2202. }
  2203. .yun3 {
  2204. top: 100px;
  2205. animation-duration: 120s;
  2206. animation-delay: 15s;
  2207. }
  2208. /deep/ .label-treecomp {
  2209. position: relative;
  2210. background-color: #05dfff;
  2211. color: #fff;
  2212. padding: 6px 10px;
  2213. border-radius: 8px;
  2214. font-size: 14px;
  2215. text-align: center;
  2216. &::before {
  2217. position: absolute;
  2218. top: 26px;
  2219. left: 42%;
  2220. content: '';
  2221. width: 0px;
  2222. height: 0px;
  2223. border: 6px solid transparent;
  2224. border-top-color: #05dfff;
  2225. }
  2226. .smallH {
  2227. position: absolute;
  2228. top: 34px;
  2229. z-index: 99;
  2230. display: block;
  2231. color: #05dfff;
  2232. text-align: center;
  2233. font-size: 14px;
  2234. // left: 38%;
  2235. left: 0;
  2236. width: 100%;
  2237. }
  2238. }
  2239. </style>