dtl.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  1. <template>
  2. <div class="app-container">
  3. <div class="scoped-top-tips" v-show="!isDeal">洪楼plus小程序提示:点击图中区域、楼盘、学校可查看更多</div>
  4. <div class="scoped-bg"></div>
  5. <div v-if="$route.query.id === '95542fdc-b542-4582-9be2-9ab8005728d3' || $route.query.id === '95542ff1-8176-4267-8344-2aa7f1034ac5'" class="scoped-tab">
  6. <div @click="linkChange('95542fdc-b542-4582-9be2-9ab8005728d3')" :class="$route.query.id === '95542fdc-b542-4582-9be2-9ab8005728d3' ? 'op cur' : 'op'">小学</div>
  7. <div @click="linkChange('95542ff1-8176-4267-8344-2aa7f1034ac5')" :class="$route.query.id === '95542ff1-8176-4267-8344-2aa7f1034ac5' ? 'op cur' : 'op'">初中</div>
  8. </div>
  9. <!-- https://img2.honglounews.com/20220111024440-5626.png -->
  10. <div v-show="isDeal" :class="isDbShow ? 'scoped-deal-box' : 'scoped-deal-box t2'">
  11. <div class="sdb-info">
  12. <div class="p1">当前缩放级别:{{mapDiyObj.zoom}}<span class="more" @click="setShowChange">{{isMapSetShow ? '收起设置' : '展开设置'}}></span></div>
  13. <div class="p2" v-show="isMapSetShow">
  14. <base-form ref="ruleForm" :data="formData" :is-inline="false" label-width="80px">
  15. <div slot="footer">
  16. <el-button class="xl-form-btn bgc2" @click="setHandle">设置</el-button>
  17. <div class="scoped-select-center" @click="setCenterHandle">中心坐标<div class="s">{{centerStr}}</div></div>
  18. </div>
  19. </base-form>
  20. </div>
  21. </div>
  22. <div class="sdb-add">
  23. <div class="b t2" @click="openMte('polygonAdd')">添加多边形</div>
  24. <div class="b t2" @click="openMte('textAdd')">添加文字</div>
  25. </div>
  26. <div class="sdb-add">
  27. <div class="b t3" @click="saveHandle()">保 存</div>
  28. </div>
  29. <div class="sdb-list" v-if="polygons.length > 0">
  30. <div class="label t2">多边形列表(选中:{{polygonIndex + 1}})</div>
  31. <div class="ul">
  32. <div class="op" v-for="(polygon, index) in polygons" :key="index">
  33. <p class="p1" @click="openMte('polygonAdd', {obj: polygon, index})">({{index + 1}}){{polygon.text}}</p>
  34. <p class="more">
  35. <span v-if="polygon.editable" class="d d2" @click="textAdd(polygon)">标点</span>
  36. <span v-if="polygon.editable" class="d d1" @click="mapIsEdit(index, 'polygons')">编辑</span>
  37. <span v-else class="d d3" @click="mapIsEdit(index, 'polygons')">只读</span>
  38. <span class="d d4" @click="mapDel(index, 'polygons')">删除</span>
  39. </p>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="sdb-list" v-if="markerData.length > 0">
  44. <div class="label t2">文字列表(选中:{{curMarkersIndex + 1}})</div>
  45. <div class="ul">
  46. <div class="op" v-for="(t, index) in markerData" :key="index">
  47. <p class="p1" @click="openMte('textAdd', {obj: t, index})">({{index + 1}}){{t.content}}</p>
  48. <p class="more">
  49. <span v-if="t.draggable" class="d d1" @click="mapIsEdit(index, 'markerData')">编辑</span>
  50. <span v-else class="d d3" @click="mapIsEdit(index, 'markerData')">只读</span>
  51. <span class="d d4" @click="mapDel(index, 'markerData')">删除</span>
  52. </p>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <el-amap
  58. class="amap-box"
  59. :vid="'amap-vue'"
  60. :amap-manager="amapManager"
  61. :zoom="mapDiyObj.zoom"
  62. :zooms="mapDiyObj.zooms"
  63. :mapStyle="mapDiyObj.mapStyle"
  64. :center="mapDiyObj.center"
  65. :events="mapEvents"
  66. :plugin="plugin"
  67. >
  68. <template v-if="mapDiyObj.zoom > 13">
  69. <template v-if="mapDiyObj.isSchoolShow === '1'">
  70. <el-amap-marker class="scoped-m-box" v-for="(marker, index) in schoolList" :key="3000 + index"
  71. icon="https://img2.honglounews.com/20220110041435-6276.png"
  72. width="20"
  73. height="20"
  74. :position="marker.position"
  75. :events="schoolEvents"
  76. :title="marker.school_name"
  77. :label="{content: marker.school_name, offset: [-10 * marker.school_name.length / 2, -20]}"
  78. :extData="{id: marker.id}"
  79. >
  80. </el-amap-marker>
  81. </template>
  82. <template v-if="mapDiyObj.isEstateShow === '1'">
  83. <el-amap-marker class="scoped-m-box" v-for="(marker, index) in estateList" :key="2000 + index"
  84. icon="https://img2.honglounews.com/20220110041411-6675.png"
  85. :position="marker.position"
  86. :events="estateEvents"
  87. :title="marker.estate_name"
  88. :label="{content: marker.estate_name, offset: [-10 * marker.estate_name.length / 2, -20]}"
  89. :extData="{id: marker.id}"
  90. >
  91. <!-- https://img2.honglounews.com/20220110041534-8330.png -->
  92. <!-- https://img2.honglounews.com/20220110041411-6675.png -->
  93. </el-amap-marker>
  94. </template>
  95. <el-amap-marker v-for="(marker, index) in markerData" :key="9000 + index"
  96. :position="marker.position"
  97. :draggable="marker.draggable"
  98. :animation="marker.animation"
  99. :offset="marker.offset"
  100. :extData="{index}"
  101. :events="markersEvents">
  102. <div class="scoped-marker-text" :style="`color: ${marker.color}`">{{marker.content}}</div>
  103. </el-amap-marker>
  104. </template>
  105. <template v-else>
  106. <template v-if="mapDiyObj.isAreaShow === '1'">
  107. <el-amap-marker class="scoped-m-box" v-for="(marker, index) in areaList" :key="4000 + index"
  108. icon="https://img2.honglounews.com/20220110041435-6276.png"
  109. :position="marker.position"
  110. :events="areaEvents"
  111. :offset="[-40, -40]"
  112. :extData="{areaName: marker.areaName, areaType: marker.area_type}"
  113. >
  114. <div class="scoped-marker-area">
  115. <div class="p1">{{marker.areaName}}</div>
  116. <div class="p2">楼盘:{{marker.estate_total}}</div>
  117. <div class="p2">学校:{{marker.school_total}}</div>
  118. </div>
  119. </el-amap-marker>
  120. </template>
  121. </template>
  122. <el-amap-polygon
  123. v-for="(polygon, index) in polygons"
  124. :key="index"
  125. :path="polygon.path"
  126. :editable="polygon.editable"
  127. :fillColor="polygon.fillColor"
  128. :fillOpacity="polygon.fillOpacity"
  129. :strokeColor="polygon.strokeColor"
  130. :strokeWeight="polygon.strokeWeight"
  131. :strokeOpacity="polygon.strokeOpacity"
  132. :extData="{index}"
  133. :events="polygonEvents">
  134. </el-amap-polygon>
  135. </el-amap>
  136. <MapTextEdit
  137. :isShow="isMteShow"
  138. :mteStr="mteStr"
  139. :curObj="mteObj"
  140. @close="closeMte"/>
  141. </div>
  142. </template>
  143. <script>
  144. import { AMapManager, lazyAMapApiLoaderInstance } from 'vue-amap'
  145. const amapManager = new AMapManager()
  146. import MapTextEdit from './components/popup/MapTextEdit'
  147. import { arrToObj } from '@/utils'
  148. export default {
  149. name: 'map',
  150. components: {},
  151. components: {
  152. MapTextEdit
  153. },
  154. mixins,
  155. data() {
  156. const that = this
  157. return {
  158. estateList: [],
  159. schoolList: [],
  160. medium_school_list: [],
  161. small_school_list: [],
  162. areaList: [],
  163. isDbShow: true,
  164. isMapSetShow: false,
  165. formData: [],
  166. isMteShow: false,
  167. mapDiyObj: {
  168. center: [115.852386, 28.684076],
  169. zoom: 17,
  170. zooms: [15, 19],
  171. },
  172. amapManager,
  173. polygons: [
  174. // {
  175. // path: [[115.823481,28.702359],[115.861933,28.672241],[115.812838,28.629609],[115.793784,28.657179]],
  176. // strokeWeight: 2,
  177. // fillColor: '#f00',
  178. // strokeStyle: 'solid',
  179. // },
  180. // {
  181. // path: [[115.859015,28.654919],[115.93386,28.630212],[115.841849,28.606101]],
  182. // editable: true,
  183. // strokeWeight: 1,
  184. // fillColor: '#ffffff',
  185. // strokeStyle: 'dashed',
  186. // },
  187. ],
  188. markerData: [],
  189. mapEvents: {
  190. init(map) {
  191. // map.setFeatures(['road', 'point', 'bg', 'building']); // 多个种类要素显示
  192. map.setFeatures(['road', 'bg', 'building']); // 多个种类要素显示
  193. // map.setMapStyle('amap://styles/647a4a7f773b3c7143b46e7c3e499f1f');
  194. AMapUI.loadUI(['control/BasicControl'], function(BasicControl) {
  195. //图层切换控件
  196. var layerControl = new BasicControl.LayerSwitcher({
  197. baseLayers: [
  198. {
  199. id: 'basic',//图层id,需唯一
  200. enable: true, //是否启用
  201. name: '基础地图',//显示名称,html
  202. layer: new AMap.TileLayer()
  203. },
  204. {
  205. id: 'Satellite',//图层id,需唯一
  206. enable: false, //是否启用
  207. name: '卫星图',//显示名称,html
  208. layer: new AMap.TileLayer.Satellite()
  209. },
  210. ],
  211. overlayLayers:[
  212. ],
  213. position: {
  214. bottom:'50px',
  215. right:'30px',
  216. },
  217. });
  218. map.addControl(layerControl);
  219. })
  220. },
  221. zoomchange (e) {
  222. const curMap = amapManager.getMap()
  223. that.mapDiyObj.zoom = curMap.getZoom() || 17
  224. },
  225. complete () {
  226. that.setCurFeatures(that.mapDiyObj.features)
  227. },
  228. // click(e) {
  229. // const { lng, lat } = e.lnglat
  230. // console.log(lng, lat)
  231. // },
  232. },
  233. markersEvents: {
  234. dragend(e) {
  235. const { lng, lat } = e.lnglat
  236. let markerData = JSON.parse(JSON.stringify(that.markerData))
  237. markerData[that.curMarkersIndex].position = [lng, lat]
  238. that.markerData = [...markerData]
  239. },
  240. click(e) {
  241. const eData = e.target.getExtData()
  242. that.curMarkersIndex = eData.index
  243. },
  244. },
  245. polygonEvents: {
  246. click(e) {
  247. const eData = e.target.getExtData()
  248. that.polygonIndex = eData.index
  249. // wx.miniProgram.navigateTo({url: '/pagesSchool/indexDtl?id=25'})
  250. },
  251. },
  252. estateEvents: {
  253. click(e) {
  254. const eData = e.target.getExtData()
  255. wx.miniProgram.navigateTo({url: `/pagesHouse/indexDtl?id=${eData.id}`})
  256. },
  257. },
  258. schoolEvents: {
  259. click(e) {
  260. const eData = e.target.getExtData()
  261. wx.miniProgram.navigateTo({url: `/pagesSchool/indexDtl?id=${eData.id}`})
  262. },
  263. },
  264. areaEvents: {
  265. click(e) {
  266. const eData = e.target.getExtData()
  267. wx.miniProgram.navigateTo({url: `/pagesSchool/index?areaName=${eData.areaName}&areaType=${eData.areaType}`})
  268. },
  269. },
  270. polygonIndex: 0,
  271. curMarkersIndex: 0,
  272. plugin: [{
  273. pName: 'MouseTool',
  274. }],
  275. mteStr: 'polygonAdd',
  276. mteObj: {},
  277. dictData: {
  278. sys_yesno: [
  279. {key: '是', val: '1'},
  280. {key: '否', val: '2'},
  281. ],
  282. area_type: [
  283. {
  284. "key": "红谷滩中心区",
  285. "val": "hgt"
  286. },
  287. {
  288. "key": "红角洲",
  289. "val": "hjz"
  290. },
  291. {
  292. "key": "朝阳新城",
  293. "val": "cyxc"
  294. },
  295. {
  296. "key": "九龙湖",
  297. "val": "jlh"
  298. },
  299. {
  300. "key": "凤凰洲",
  301. "val": "fhz"
  302. },
  303. {
  304. "key": "西湖区",
  305. "val": "xhq"
  306. },
  307. {
  308. "key": "东湖区",
  309. "val": "dhq"
  310. },
  311. {
  312. "key": "象湖滨江",
  313. "val": "xhbj"
  314. },
  315. {
  316. "key": "青山湖区",
  317. "val": "qshq"
  318. },
  319. {
  320. "key": "新建区",
  321. "val": "xjq"
  322. },
  323. {
  324. "key": "湾里区",
  325. "val": "wlq"
  326. },
  327. {
  328. "key": "青云谱区",
  329. "val": "qypq"
  330. },
  331. {
  332. "key": "高新区",
  333. "val": "gxq"
  334. },
  335. {
  336. "key": "欣悦湖",
  337. "val": "xyh"
  338. },
  339. {
  340. "key": "经开区",
  341. "val": "jkq"
  342. },
  343. {
  344. "key": "象湖新城",
  345. "val": "xhxc"
  346. },
  347. {
  348. "key": "望城",
  349. "val": "wcxq"
  350. },
  351. {
  352. "key": "南昌县",
  353. "val": "ncx"
  354. },
  355. {
  356. "key": "赣江新区",
  357. "val": "gjxq"
  358. }
  359. ],
  360. map_area_lnglat: [
  361. {
  362. "option1": "望城",
  363. "key": "115.74219,28.622854",
  364. "val": "wcxq"
  365. },
  366. {
  367. "option1": "湾里区",
  368. "key": "115.781385,28.709504",
  369. "val": "wlq"
  370. },
  371. {
  372. "option1": "欣悦湖",
  373. "key": "115.787513,28.685376",
  374. "val": "xyh"
  375. },
  376. {
  377. "option1": "九龙湖",
  378. "key": "115.792951,28.587435",
  379. "val": "jlh"
  380. },
  381. {
  382. "option1": "新建区",
  383. "key": "115.818441,28.692623",
  384. "val": "xjq"
  385. },
  386. {
  387. "option1": "红角洲",
  388. "key": "115.824219,28.63926",
  389. "val": "hjz"
  390. },
  391. {
  392. "option1": "经开区",
  393. "key": "115.830506,28.747641",
  394. "val": "jkq"
  395. },
  396. {
  397. "option1": "象湖滨江",
  398. "key": "115.847217,28.582374",
  399. "val": "xhbj"
  400. },
  401. {
  402. "option1": "红谷滩中心区",
  403. "key": "115.852886,28.683902",
  404. "val": "hgt"
  405. },
  406. {
  407. "option1": "朝阳新城",
  408. "key": "115.858884,28.633789",
  409. "val": "cyxc"
  410. },
  411. {
  412. "option1": "凤凰洲",
  413. "key": "115.875846,28.709236",
  414. "val": "fhz"
  415. },
  416. {
  417. "option1": "西湖区",
  418. "key": "115.889966,28.664366",
  419. "val": "xhq"
  420. },
  421. {
  422. "option1": "东湖区",
  423. "key": "115.901112,28.680259",
  424. "val": "dhq"
  425. },
  426. {
  427. "option1": "青云谱区",
  428. "key": "115.908247,28.623327",
  429. "val": "qypq"
  430. },
  431. {
  432. "option1": "南昌县",
  433. "key": "115.932183,28.550813",
  434. "val": "ncx"
  435. },
  436. {
  437. "option1": "赣江新区",
  438. "key": "115.93303,28.803368",
  439. "val": "gjxq"
  440. },
  441. {
  442. "option1": "青山湖区",
  443. "key": "115.949679,28.701298",
  444. "val": "qshq"
  445. },
  446. {
  447. "option1": "高新区",
  448. "key": "116.033624,28.697981",
  449. "val": "gxq"
  450. }
  451. ]
  452. },
  453. }
  454. },
  455. computed: {
  456. isDeal () {
  457. const query = this.$route.query
  458. if (query.e && query.e === '1') {
  459. return true
  460. } else {
  461. return false
  462. }
  463. },
  464. centerStr () {
  465. const center = this.mapDiyObj.center
  466. if (center && center.length > 0) {
  467. return `${center[0]}, ${center[1]}`
  468. } else {
  469. return '待选取'
  470. }
  471. }
  472. },
  473. created() {
  474. this.getData()
  475. this.$api.base.apiareainfolist().then(areaArr => {
  476. const arr = areaArr.map((a, aIndex) => {
  477. return {
  478. key: aIndex,
  479. val: a.option1,
  480. longitude: a.longitude,
  481. latitude: a.latitude,
  482. areaName: a.area_name,
  483. }
  484. })
  485. this.$api.other.admmapcoordinall().then(res => {
  486. let estateList = res.estate_list || []
  487. estateList.map(item => {
  488. item.position = [item.longitude, item.latitude]
  489. })
  490. this.estateList = [...estateList]
  491. const query = this.$route.query
  492. if (query.id === '95542fdc-b542-4582-9be2-9ab8005728d3') {
  493. let small_school_list = res.small_school_list || []
  494. small_school_list.map(item => {
  495. item.position = [item.longitude, item.latitude]
  496. })
  497. this.schoolList = [...small_school_list]
  498. } else if (query.id === '95542ff1-8176-4267-8344-2aa7f1034ac5') {
  499. let medium_school_list = res.medium_school_list || []
  500. medium_school_list.map(item => {
  501. item.position = [item.longitude, item.latitude]
  502. })
  503. this.schoolList = [...medium_school_list]
  504. } else {
  505. let schoolList = res.school_list || []
  506. schoolList.map(item => {
  507. item.position = [item.longitude, item.latitude]
  508. })
  509. this.schoolList = [...schoolList]
  510. }
  511. let areaList = res.area_total || []
  512. areaList.map(item => {
  513. // let lnglatArr = arrToObj(this.dictData.map_area_lnglat)[item.area_type].split(',')
  514. // item.position = [lnglatArr[0], lnglatArr[1]]
  515. // item.areaName = arrToObj(this.dictData.area_type)[item.area_type]
  516. const areaIndex = arrToObj(arr)[item.area_type]
  517. item.position = [arr[areaIndex].longitude, arr[areaIndex].latitude]
  518. item.areaName = arr[areaIndex].areaName
  519. })
  520. this.areaList = [...areaList]
  521. })
  522. })
  523. },
  524. mounted() {},
  525. methods: {
  526. linkChange (str) {
  527. const query = this.$route.query
  528. if (query.e) {
  529. this.$router.push(`/map/dtl?e=${query.e}&id=${str}`)
  530. } else {
  531. this.$router.push(`/map/dtl?id=${str}`)
  532. }
  533. this.$router.go(0)
  534. },
  535. setShowChange () {
  536. this.isMapSetShow = !this.isMapSetShow
  537. },
  538. getDef () {
  539. let params = {}
  540. params = { ...this.mapDiyObj }
  541. params.zoom1 = params.zooms[0]
  542. params.zoom2 = params.zooms[1]
  543. this.formData = [
  544. { label: '地图标题', key: 'title', rules: 1},
  545. { label: '主题样式', key: 'mapStyle', type: 'select', rules: 1,
  546. options: [
  547. {key: '默认样式', val: 'normal'},
  548. {key: '深色样式', val: 'dark'},
  549. {key: '浅色样式', val: 'light'},
  550. {key: '清新风格osm', val: 'fresh'},
  551. ]
  552. },
  553. { label: '显示内容', key: 'features', type: 'select', multiple: true, rules: 1,
  554. options: [
  555. {key: '区域面', val: 'bg'},
  556. {key: '兴趣点', val: 'point'},
  557. {key: '道路和标注', val: 'road'},
  558. {key: '建筑物', val: 'building'},
  559. ]
  560. },
  561. { label: '默认级别', key: 'zoom', rules: 1},
  562. { label: '最小3+', key: 'zoom1', rules: 1},
  563. { label: '最大19-', key: 'zoom2', rules: 1},
  564. { label: '展示楼盘', key: 'isEstateShow', type: 'select', rules: 1, options: this.dictData.sys_yesno},
  565. { label: '展示学校', key: 'isSchoolShow', type: 'select', rules: 1, options: this.dictData.sys_yesno},
  566. { label: '展示区域', key: 'isAreaShow', type: 'select', rules: 1, options: this.dictData.sys_yesno},
  567. ]
  568. this.setDefaultValue(params)
  569. // this.setCurFeatures(params.features)
  570. },
  571. setCurFeatures (data) {
  572. const curMap = this.amapManager.getMap()
  573. curMap.setFeatures(data)
  574. },
  575. getData () {
  576. const query = this.$route.query
  577. this.$api.other.admmapcoordindetail({
  578. uuid: query.id
  579. }).then(res => {
  580. if (res.data) {
  581. const data = JSON.parse(res.data)
  582. this.polygons = [...data.polygons]
  583. this.markerData = [...data.markerData]
  584. this.mapDiyObj = {
  585. ...data.mapDiyObj,
  586. title: res.title,
  587. }
  588. } else {
  589. this.mapDiyObj = {
  590. mapStyle: 'normal',
  591. zoom: 13,
  592. zooms: [11, 19],
  593. center: [115.852386, 28.684076],
  594. isEstateShow: '2',
  595. isSchoolShow: '2',
  596. isAreaShow: '2',
  597. title: res.title,
  598. features: ['road', 'bg', 'building']
  599. }
  600. }
  601. document.title = res.title || '洪楼地图1'
  602. this.getDef()
  603. })
  604. },
  605. setHandle () {
  606. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  607. if (valid) {
  608. const oldform = this.$refs.ruleForm.baseForm
  609. let newForm = { ...oldform }
  610. let mapDiyObj = { ...this.mapDiyObj }
  611. mapDiyObj.zoom = Number(newForm.zoom)
  612. mapDiyObj.zooms = [Number(newForm.zoom1), Number(newForm.zoom2)]
  613. mapDiyObj.title = newForm.title
  614. mapDiyObj.mapStyle = newForm.mapStyle
  615. mapDiyObj.features = newForm.features
  616. mapDiyObj.isEstateShow = newForm.isEstateShow
  617. mapDiyObj.isSchoolShow = newForm.isSchoolShow
  618. mapDiyObj.isAreaShow = newForm.isAreaShow
  619. this.mapDiyObj = {...mapDiyObj}
  620. this.setCurFeatures(newForm.features)
  621. this.isMapSetShow = false
  622. }
  623. })
  624. },
  625. setCenterHandle () {
  626. const that = this
  627. const curMap = this.amapManager.getMap()
  628. let mouseTool = new AMap.MouseTool(curMap)
  629. mouseTool.marker({
  630. content: ' ',
  631. })
  632. that.isDbShow = false
  633. that.$msgs('请在地图上选择中心点')
  634. AMap.event.addListener(mouseTool,'draw',function(e){
  635. let cPath = e.obj.getPosition()
  636. let mapDiyObj = {...that.mapDiyObj}
  637. mapDiyObj.center = [cPath.lng, cPath.lat]
  638. that.mapDiyObj = {...mapDiyObj}
  639. that.$msg('中心坐标选取成功~如需重新选中心点,请再次点击中心坐标位置')
  640. that.isDbShow = true
  641. window.setTimeout(() => {
  642. mouseTool.close(true)
  643. }, 100)
  644. })
  645. },
  646. saveHandle () {
  647. this.$msg(`您确定要保存该数据(覆盖原来数据)吗?`, 'confirm', () => {
  648. let polygons = JSON.parse(JSON.stringify(this.polygons))
  649. polygons.map(one=> {
  650. // console.log(one.fillColor)
  651. // if (one.fillColor === '#DC9B21') {
  652. // one.fillColor = '#F8A41C'
  653. // one.strokeColor = '#F8A41C'
  654. // one.fillOpacity = '0.4'
  655. // one.strokeOpacity = '0.8'
  656. // }
  657. let tPath = []
  658. one.editable = false
  659. one.path.forEach(sub => {
  660. tPath.push([sub.lng, sub.lat])
  661. })
  662. one.path = tPath
  663. })
  664. let markerData = JSON.parse(JSON.stringify(this.markerData))
  665. markerData.map(one => {
  666. one.draggable = false
  667. })
  668. const data = {
  669. polygons,
  670. markerData,
  671. mapDiyObj: this.mapDiyObj,
  672. }
  673. // console.log(polygons)
  674. // return
  675. const query = this.$route.query
  676. this.$api.other.admmapcoordinedit({
  677. uuid: query.id,
  678. title: this.mapDiyObj.title,
  679. data: JSON.stringify(data)
  680. }).then(res => {
  681. this.getData()
  682. })
  683. })
  684. },
  685. polygonAdd (obj) {
  686. const that = this
  687. const curMap = this.amapManager.getMap()
  688. let mouseTool = new AMap.MouseTool(curMap)
  689. mouseTool.polygon({
  690. fillColor:'#00b0ff',
  691. strokeColor:'#80d8ff',
  692. editable: true,
  693. strokeStyle: 'dashed',
  694. })
  695. AMap.event.addListener(mouseTool,'draw',function(e) {
  696. let cPath = [...e.obj.getPath()]
  697. let tempPath = []
  698. cPath.forEach(item => {
  699. tempPath.push([item.lng, item.lat])
  700. })
  701. let polygons = [...that.polygons]
  702. polygons.push({
  703. path: tempPath,
  704. editable: true,
  705. fillColor: obj.fillColor || '#DC3021', // 填充色
  706. fillOpacity: obj.fillOpacity || 0.4, // 填充透明度
  707. strokeColor: obj.strokeColor || '#DC3021', // 轮廓颜色
  708. strokeWeight: 2, // 轮廓宽度
  709. strokeOpacity: 0.8, // 轮廓透明度
  710. text: obj.text,
  711. })
  712. that.polygons = [...polygons]
  713. mouseTool.close(true)
  714. that.isDbShow = true
  715. })
  716. },
  717. mapIsEdit (index, str) {
  718. this.curMarkersIndex = index
  719. let tempData = [...this[str]]
  720. if (str === 'polygons') {
  721. if (tempData[index].editable) {
  722. tempData[index].editable = false
  723. tempData[index].strokeStyle = 'solid'
  724. } else {
  725. tempData[index].editable = true
  726. tempData[index].strokeStyle = 'dashed'
  727. }
  728. } else {
  729. tempData[index].draggable = !tempData[index].draggable
  730. // tempData[index].animation = tempData[index].draggable ? 'AMAP_ANIMATION_BOUNCE' : 'AMAP_ANIMATION_DROP'
  731. }
  732. this[str] = [...tempData]
  733. this.$storage(`map_${str}`, JSON.stringify(tempData))
  734. },
  735. mapDel (index, str) {
  736. this.$msg(`您确定要删除该数据吗?`, 'confirm', () => {
  737. let tempData = [...this[str]]
  738. tempData.splice(index, 1)
  739. this[str] = [...tempData]
  740. this.$storage(`map_${str}`, JSON.stringify(tempData))
  741. })
  742. },
  743. openMte (str, obj) {
  744. this.mteStr = str
  745. this.isMteShow = true
  746. if (obj) {
  747. this.mteObj = {...obj}
  748. }
  749. },
  750. closeMte (obj, bcStr) {
  751. this.isMteShow = false
  752. if (obj) {
  753. if (bcStr && bcStr === 'edit') {
  754. const index = this.mteObj.index || 0
  755. const str = this.mteStr === 'textAdd' ? 'markerData' : 'polygons'
  756. let tempData = [...this[str]]
  757. if (this.mteStr === 'textAdd') {
  758. tempData[index].content = obj.text
  759. tempData[index].text = obj.text
  760. tempData[index].color = obj.color
  761. } else {
  762. tempData[index].text = obj.text
  763. tempData[index].fillColor = obj.fillColor
  764. tempData[index].fillOpacity = obj.fillOpacity
  765. tempData[index].strokeColor = obj.strokeColor
  766. }
  767. this[str] = [...tempData]
  768. this.$storage(`map_${str}`, JSON.stringify(tempData))
  769. } else {
  770. this[this.mteStr](obj)
  771. this.isDbShow = false
  772. this.$msgs('请在地图上操作')
  773. }
  774. }
  775. this.mteObj = {}
  776. },
  777. textAdd (obj) {
  778. const that = this
  779. const curMap = this.amapManager.getMap()
  780. let mouseTool = new AMap.MouseTool(curMap)
  781. mouseTool.marker({
  782. content: ' ',
  783. })
  784. AMap.event.addListener(mouseTool,'draw',function(e){
  785. let cPath = e.obj.getPosition()
  786. let markerData = [...that.markerData]
  787. markerData.push({
  788. position: [cPath.lng, cPath.lat],
  789. draggable: true,
  790. animation: 'AMAP_ANIMATION_DROP',
  791. content: obj.text,
  792. offset: [0, -10],
  793. text: obj.text,
  794. color: obj.color,
  795. })
  796. that.markerData = [...markerData]
  797. window.setTimeout(() => {
  798. mouseTool.close(true)
  799. that.isDbShow = true
  800. }, 100)
  801. })
  802. },
  803. }
  804. }
  805. </script>
  806. <style lang="scss" scoped>
  807. .app-container {
  808. height: 100%;
  809. padding: 0;
  810. margin: 0;
  811. position: relative;
  812. .amap-box {
  813. height: 100%;
  814. }
  815. }
  816. .scoped-deal-box {
  817. background: #f2f2f2;
  818. box-shadow: 0 0 5px #666;
  819. position: absolute;
  820. z-index: 999;
  821. left: 0;
  822. top: 0;
  823. height: 100%;
  824. width: 220px;
  825. overflow-y: auto;
  826. overflow-x: hidden;
  827. &.t2 {
  828. opacity: 0.5;
  829. }
  830. .sdb-info {
  831. background: #fff;
  832. margin-bottom: 10px;
  833. padding: 10px 10px 0;
  834. .p1 {
  835. font-size: 14px;
  836. user-select: none;
  837. padding-bottom: 10px;
  838. .more {
  839. color: #409eff;
  840. text-decoration: underline;
  841. padding-left: 2px;
  842. cursor: pointer;
  843. }
  844. }
  845. .p2 {
  846. padding-bottom: 6px;
  847. }
  848. }
  849. .sdb-add {
  850. padding: 0 10px 10px;
  851. .b {
  852. display: inline-block;
  853. vertical-align: middle;
  854. border-radius: 0;
  855. background: #0c78b1;
  856. color: #fff;
  857. min-width: 60px;
  858. height: 36px;
  859. line-height: 36px;
  860. cursor: pointer;
  861. outline: none;
  862. padding: 0 10px;
  863. margin-right: 10px;
  864. font-size: 14px;
  865. text-align: center;
  866. &:last-child {
  867. margin-right: 0;
  868. }
  869. &.t2 {
  870. background: #409eff;
  871. }
  872. &.t3 {
  873. width: 177px;
  874. }
  875. }
  876. }
  877. .sdb-list {
  878. background: #fff;
  879. margin-bottom: 10px;
  880. padding-top: 10px;
  881. .label {
  882. margin-left: 10px;
  883. border-left: 4px solid #409eff;
  884. padding-left: 6px;
  885. &.t2 {
  886. border-left-color: #0c78b1;
  887. }
  888. }
  889. .ul {
  890. height: 300px;
  891. overflow-y: auto;
  892. }
  893. .op {
  894. border-bottom: 1px solid #dcdcdc;
  895. padding: 10px;
  896. .p1 {
  897. color: #313131;
  898. font-weight: bold;
  899. padding-bottom: 6px;
  900. }
  901. .more {
  902. .d {
  903. display: inline-block;
  904. vertical-align: middle;
  905. margin-right: 10px;
  906. padding: 0 6px;
  907. line-height: 20px;
  908. height: 20px;
  909. border: 1px solid #0c78b1;
  910. color: #0c78b1;
  911. border-radius: 6px;
  912. font-size: 12px;
  913. font-weight: bold;
  914. cursor: pointer;
  915. &.d2 {
  916. color: #409eff;
  917. border-color: #409eff;
  918. }
  919. &.d3 {
  920. color: #313131;
  921. border-color: #313131;
  922. }
  923. &.d4 {
  924. color: #f00;
  925. border-color: #f00;
  926. }
  927. }
  928. }
  929. }
  930. }
  931. }
  932. .scoped-marker-text {
  933. color: #fff;
  934. min-width: 120px;
  935. font-weight: bold;
  936. box-shadow: 0 0 10px #fff;
  937. text-align: center;
  938. padding: 6px 10px;
  939. border-radius: 6px;
  940. background: #ebad57;
  941. }
  942. .scoped-select-center {
  943. position: absolute;
  944. left: -75px;
  945. top: 0px;
  946. cursor: pointer;
  947. width: 60px;
  948. line-height: 14px;
  949. color: #313131;
  950. .s {
  951. color: #f00;
  952. font-size: 12px;
  953. }
  954. }
  955. ::v-deep .amap-marker-label {
  956. border-color: #dcdcdc;
  957. border-radius: 2px;
  958. padding: 3px 5px;
  959. color: #666;
  960. background: #f0f0f0;
  961. box-shadow: 0 0 3px #ccc;
  962. }
  963. ::v-deep .amap-logo{
  964. display: none!important;;
  965. }
  966. ::v-deep .amap-copyright {
  967. opacity:0;
  968. }
  969. ::v-deep .amap-icon img {
  970. width: 20px !important;
  971. height: 20px !important;
  972. }
  973. .scoped-marker-area {
  974. background: #369af7;
  975. box-shadow: 0 0 5px #369af7;
  976. color: #fff;
  977. width: 80px;
  978. height: 80px;
  979. text-align: center;
  980. font-size: 12px;
  981. border-radius: 50%;
  982. padding-top: 20px;
  983. box-sizing: border-box;
  984. }
  985. .scoped-bg {
  986. width: 180px;
  987. height: 30px;
  988. background: url(./img/bg.png);
  989. background-size: 100%;
  990. position: fixed;
  991. z-index: 999999;
  992. // left: 50%;
  993. // top: 50%;
  994. // margin-left: -150px;
  995. // margin-top: -25px;
  996. // transform: rotate(-45deg);
  997. left: 10px;
  998. bottom: 0;
  999. }
  1000. .scoped-top-tips {
  1001. position: fixed;
  1002. z-index: 999999;
  1003. top: 0;
  1004. left: 0;
  1005. width: 100%;
  1006. color: #5caac1; //#de8c17;
  1007. background: #fcf6ed;
  1008. font-size: 12px;
  1009. padding: 10px;
  1010. opacity: .8;
  1011. font-weight: bold;
  1012. }
  1013. .scoped-tab {
  1014. position: fixed;
  1015. right: 0;
  1016. top: 50%;
  1017. background: #fff;
  1018. z-index: 9999999;
  1019. cursor: pointer;
  1020. padding: 10px;
  1021. border-radius: 20px 0 0 20px;
  1022. box-shadow: 0 0 10px #ccc;
  1023. .op {
  1024. color: #313131;
  1025. height: 30px;
  1026. line-height: 30px;
  1027. padding: 0 2px;
  1028. font-size: 14px;
  1029. &:last-child {
  1030. border-top: 1px solid #dcdcdc;
  1031. }
  1032. &.cur {
  1033. color: #409eff;
  1034. font-weight: bold;
  1035. }
  1036. }
  1037. }
  1038. </style>