amapPow.vue 79 KB

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