index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. :inline="true"
  7. v-show="showSearch"
  8. label-width="100px"
  9. >
  10. <el-form-item label="标记物类型" prop="markerType">
  11. <el-select
  12. v-model="queryParams.markerType"
  13. placeholder="请选择标记物类型"
  14. clearable
  15. size="small"
  16. >
  17. <el-option
  18. v-for="dict in markerTypeOptions"
  19. :key="dict.dictValue"
  20. :label="dict.dictLabel"
  21. :value="dict.dictValue"
  22. />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="标记物名称" prop="markerName">
  26. <el-input
  27. v-model="queryParams.markerName"
  28. placeholder="请输入标记物名称"
  29. clearable
  30. size="small"
  31. @keyup.enter.native="handleQuery"
  32. />
  33. </el-form-item>
  34. <el-form-item>
  35. <el-button
  36. type="primary"
  37. icon="el-icon-search"
  38. @click="handleQuery"
  39. >搜索</el-button
  40. >
  41. <el-button icon="el-icon-refresh" @click="resetQuery"
  42. >重置</el-button
  43. >
  44. </el-form-item>
  45. </el-form>
  46. <el-row :gutter="10" class="mb8">
  47. <el-col :span="1.5">
  48. <el-button
  49. type="primary"
  50. icon="el-icon-plus"
  51. @click="handleAdd"
  52. v-hasPermi="['management:marker:add']"
  53. >新增</el-button
  54. >
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-button
  58. type="success"
  59. icon="el-icon-edit"
  60. :disabled="single"
  61. @click="handleUpdate"
  62. v-hasPermi="['management:marker:edit']"
  63. >修改</el-button
  64. >
  65. </el-col>
  66. <el-col :span="1.5">
  67. <el-button
  68. type="danger"
  69. icon="el-icon-delete"
  70. :disabled="multiple"
  71. @click="handleDelete"
  72. v-hasPermi="['management:marker:remove']"
  73. >删除</el-button
  74. >
  75. </el-col>
  76. <!-- <el-col :span="1.5">
  77. <el-button
  78. type="warning"
  79. plain
  80. icon="el-icon-download"
  81. size="mini"
  82. :loading="exportLoading"
  83. @click="handleExport"
  84. v-hasPermi="['management:marker:export']"
  85. >导出</el-button
  86. >
  87. </el-col> -->
  88. <right-toolbar
  89. :showSearch.sync="showSearch"
  90. @queryTable="getList"
  91. ></right-toolbar>
  92. </el-row>
  93. <el-table
  94. v-loading="loading"
  95. :data="markerList"
  96. @selection-change="handleSelectionChange"
  97. >
  98. <el-table-column type="selection" width="55" align="center" />
  99. <!-- <el-table-column label="标记物id" align="center" prop="markerId" /> -->
  100. <el-table-column
  101. label="类型"
  102. align="center"
  103. prop="markerType"
  104. width="55"
  105. :formatter="markerTypeFormat"
  106. />
  107. <el-table-column label="名称" align="center" prop="markerName" />
  108. <el-table-column label="地址" align="center" prop="address" />
  109. <!-- <el-table-column label="展示图片" align="center" prop="showPictures" /> -->
  110. <el-table-column label="展示图片" align="center" prop="showPictures">
  111. <template slot-scope="scope">
  112. <img
  113. v-if="scope.row.showPictures"
  114. :src="baseUrl + scope.row.showPictures"
  115. style="width: 30px; height: 30px"
  116. />
  117. <span v-else>-</span>
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="icon图片" align="center" prop="iconPictures">
  121. <template slot-scope="scope">
  122. <img
  123. v-if="scope.row.iconPictures"
  124. :src="baseUrl + scope.row.iconPictures"
  125. style="width: 30px; height: 30px"
  126. />
  127. <span v-else>-</span>
  128. </template>
  129. </el-table-column>
  130. <!-- <el-table-column label="坐标lat" align="center" prop="lat" />
  131. <el-table-column label="坐标lng" align="center" prop="lng" /> -->
  132. <el-table-column label="标签" align="center" prop="labelText" />
  133. <el-table-column label="营业时间" align="center" prop="businessHours" />
  134. <el-table-column
  135. label="画图形状"
  136. align="center"
  137. prop="shapeType"
  138. :formatter="shapeTypeFormat"
  139. />
  140. <!-- <el-table-column label="坐标集合" align="center" prop="locationSet" />
  141. <el-table-column label="圆形的半径" align="center" prop="radius" /> -->
  142. <el-table-column label="简介" align="center" prop="briefContent" />
  143. <!-- <el-table-column label="详情" align="center" prop="content" /> -->
  144. <el-table-column
  145. label="操作"
  146. align="center"
  147. class-name="small-padding fixed-width"
  148. >
  149. <template slot-scope="scope">
  150. <el-button
  151. size="mini"
  152. type="text"
  153. icon="el-icon-edit"
  154. @click="handleUpdate(scope.row)"
  155. v-hasPermi="['management:marker:edit']"
  156. >修改</el-button
  157. >
  158. <el-button
  159. size="mini"
  160. type="text"
  161. icon="el-icon-delete"
  162. @click="handleDelete(scope.row)"
  163. v-hasPermi="['management:marker:remove']"
  164. >删除</el-button
  165. >
  166. </template>
  167. </el-table-column>
  168. </el-table>
  169. <pagination
  170. v-show="total > 0"
  171. :total="total"
  172. :page.sync="queryParams.pageNum"
  173. :limit.sync="queryParams.pageSize"
  174. @pagination="getList"
  175. />
  176. <!-- 添加或修改标记物管理对话框 -->
  177. <el-dialog :title="title" :visible.sync="open" width="80%" @close="closeDialog" append-to-body>
  178. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  179. <el-tabs v-model="activeName" @tab-click="handleClick">
  180. <el-tab-pane label="基础信息" name="first">
  181. <el-form-item label="标记物名称" prop="markerName">
  182. <el-input
  183. v-model="form.markerName"
  184. placeholder="请输入标记物名称"
  185. />
  186. </el-form-item>
  187. <el-form-item label="标记物地址" prop="address">
  188. <el-input v-model="form.address" placeholder="请输入标记物地址" />
  189. </el-form-item>
  190. <el-form-item label="展示图片">
  191. <imageUpload
  192. :limit="1"
  193. :file-size="2"
  194. v-model="form.showPictures"
  195. />
  196. </el-form-item>
  197. <el-form-item label="营业时间" prop="businessHours">
  198. <el-input
  199. v-model="form.businessHours"
  200. placeholder="请输入营业时间"
  201. />
  202. </el-form-item>
  203. <el-form-item label="标记物类型" prop="markerType">
  204. <el-select
  205. v-model="form.markerType"
  206. placeholder="请选择标记物类型"
  207. @change="markerTypeChange"
  208. >
  209. <el-option
  210. v-for="dict in markerTypeOptions"
  211. :key="dict.dictValue"
  212. :label="dict.dictLabel"
  213. :value="dict.dictValue"
  214. ></el-option>
  215. </el-select>
  216. </el-form-item>
  217. <el-form-item label="标签" prop="labelText">
  218. <!-- <el-input v-model="form.labelText" placeholder="请输入标签" /> -->
  219. <el-select v-model="form.labelText" multiple placeholder="请选择">
  220. <el-option
  221. v-for="item in labelList"
  222. :key="item.name"
  223. :label="item.name"
  224. :value="item.name"
  225. >
  226. </el-option>
  227. </el-select>
  228. </el-form-item>
  229. <el-form-item label="所属景区">
  230. <el-checkbox-group v-model="contentIdsList">
  231. <el-checkbox
  232. v-for="(item, index) in contentList"
  233. :key="'jq' + index"
  234. :label="item.contentId"
  235. >{{ item.title }}</el-checkbox
  236. >
  237. </el-checkbox-group>
  238. </el-form-item>
  239. </el-tab-pane>
  240. <el-tab-pane label="地图" name="second">
  241. <el-row>
  242. <el-col :span="12">
  243. <el-form-item label="坐标lat" prop="lat">
  244. <el-input
  245. disabled
  246. v-model="form.lat"
  247. placeholder="请输入坐标lat"
  248. />
  249. </el-form-item>
  250. </el-col>
  251. <el-col :span="12">
  252. <el-form-item label="坐标lng" prop="lng">
  253. <el-input
  254. disabled
  255. v-model="form.lng"
  256. placeholder="请输入坐标lng"
  257. />
  258. </el-form-item>
  259. </el-col>
  260. <el-col :span="12">
  261. <el-form-item label="画图形状">
  262. <el-radio-group
  263. v-model="form.shapeType"
  264. @change="shapeChange"
  265. >
  266. <el-radio
  267. v-for="dict in shapeTypeOptions"
  268. :key="dict.dictValue"
  269. :label="dict.dictValue"
  270. >{{ dict.dictLabel }}</el-radio
  271. >
  272. </el-radio-group>
  273. </el-form-item>
  274. </el-col>
  275. <el-col :span="12">
  276. <el-form-item
  277. label="圆形的半径"
  278. prop="radius"
  279. v-if="form.shapeType == 'circle'"
  280. >
  281. <el-input
  282. v-model="form.radius"
  283. placeholder="请输入圆形的半径"
  284. />
  285. </el-form-item>
  286. <el-form-item
  287. label="icon图片"
  288. v-if="form.shapeType == 'marker'"
  289. >
  290. <imageUpload
  291. v-model="form.iconPictures"
  292. :limit="1"
  293. :file-size="2"
  294. />
  295. </el-form-item>
  296. </el-col>
  297. </el-row>
  298. <!-- <el-form-item label="坐标集合" prop="locationSet">
  299. <el-input
  300. v-model="form.locationSet"
  301. type="textarea"
  302. placeholder="请输入内容"
  303. />
  304. </el-form-item> -->
  305. <div id="container" ref="containerRef" style="height: 500px"></div>
  306. </el-tab-pane>
  307. <el-tab-pane label="简介详情" name="third">
  308. <el-form-item label="简介">
  309. <editor v-model="form.briefContent" :min-height="192" />
  310. </el-form-item>
  311. <el-form-item label="详情">
  312. <editor v-model="form.content" :min-height="192" />
  313. </el-form-item>
  314. </el-tab-pane>
  315. </el-tabs>
  316. </el-form>
  317. <div slot="footer" class="dialog-footer">
  318. <el-button type="primary" @click="submitForm">确 定</el-button>
  319. <el-button @click="cancel">取 消</el-button>
  320. </div>
  321. </el-dialog>
  322. </div>
  323. </template>
  324. <script>
  325. import { listMarker, getMarker, delMarker, addMarker, updateMarker, exportMarker } from "@/api/management/marker";
  326. import { selectLabel } from "@/api/management/label";
  327. export default {
  328. name: "Marker",
  329. data () {
  330. return {
  331. // 遮罩层
  332. loading: true,
  333. // 导出遮罩层
  334. exportLoading: false,
  335. // 选中数组
  336. ids: [],
  337. // 非单个禁用
  338. single: true,
  339. // 非多个禁用
  340. multiple: true,
  341. // 显示搜索条件
  342. showSearch: true,
  343. // 总条数
  344. total: 0,
  345. // 标记物管理表格数据
  346. markerList: [],
  347. // 弹出层标题
  348. title: "",
  349. // 是否显示弹出层
  350. open: false,
  351. // 画图形状字典
  352. shapeTypeOptions: [],
  353. // 标记物类型字典
  354. markerTypeOptions: [],
  355. // 查询参数
  356. queryParams: {
  357. pageNum: 1,
  358. pageSize: 10,
  359. markerName: null,
  360. },
  361. // 表单参数
  362. form: {},
  363. // 表单校验
  364. rules: {
  365. },
  366. activeName: 'first',
  367. centerLat: 29.42700230,
  368. centerLng: 88.26060954,
  369. tmap: undefined,
  370. map: undefined,
  371. baseUrl: process.env.VUE_APP_BASE_API,
  372. labelList: undefined,
  373. contentList: [],
  374. contentIdsList: [],
  375. positionList: []
  376. };
  377. },
  378. created () {
  379. this.getList();
  380. this.getDicts("shape_type").then(response => {
  381. this.shapeTypeOptions = response.data;
  382. });
  383. this.getDicts("marker_type").then(response => {
  384. this.markerTypeOptions = response.data;
  385. });
  386. },
  387. methods: {
  388. /** 查询标记物管理列表 */
  389. getList () {
  390. this.loading = true;
  391. listMarker(this.queryParams).then(response => {
  392. this.markerList = response.rows;
  393. this.total = response.total;
  394. this.loading = false;
  395. });
  396. },
  397. // 标记物类型字典翻译
  398. markerTypeFormat (row, column) {
  399. return this.selectDictLabel(this.markerTypeOptions, row.markerType);
  400. },
  401. // 画图形状字典翻译
  402. shapeTypeFormat (row, column) {
  403. return this.selectDictLabel(this.shapeTypeOptions, row.shapeType);
  404. },
  405. // 取消按钮
  406. cancel () {
  407. this.open = false;
  408. if (this.map) {
  409. this.map.destroy()
  410. this.map = null
  411. }
  412. this.reset();
  413. },
  414. // 表单重置
  415. reset () {
  416. this.form = {
  417. markerId: null,
  418. markerType: null,
  419. markerName: null,
  420. address: null,
  421. showPictures: null,
  422. iconPictures: null,
  423. lat: null,
  424. lng: null,
  425. labelText: null,
  426. businessHours: null,
  427. shapeType: null,
  428. locationSet: null,
  429. radius: null,
  430. briefContent: null,
  431. content: null
  432. };
  433. this.form.shapeType = "marker"
  434. this.activeName = 'first',
  435. this.shapeChange()
  436. this.resetForm("form");
  437. },
  438. /** 搜索按钮操作 */
  439. handleQuery () {
  440. this.queryParams.pageNum = 1;
  441. this.getList();
  442. },
  443. /** 重置按钮操作 */
  444. resetQuery () {
  445. this.resetForm("queryForm");
  446. this.handleQuery();
  447. },
  448. // 多选框选中数据
  449. handleSelectionChange (selection) {
  450. this.ids = selection.map(item => item.markerId)
  451. this.single = selection.length !== 1
  452. this.multiple = !selection.length
  453. },
  454. /** 新增按钮操作 */
  455. handleAdd () {
  456. this.reset();
  457. this.open = true;
  458. this.title = "添加标记物管理";
  459. this.contentIdsList = [];
  460. this.contentList = [];
  461. getMarker(0).then(response => {
  462. this.contentList = response.data.contentList;
  463. });
  464. },
  465. /** 修改按钮操作 */
  466. handleUpdate (row) {
  467. this.reset();
  468. const markerId = row.markerId || this.ids
  469. getMarker(markerId).then(response => {
  470. this.form = response.data.info;
  471. this.open = true;
  472. this.title = "修改标记物管理";
  473. if (response.data.info.labelText) {
  474. this.form.labelText = response.data.info.labelText.split(",")
  475. }
  476. this.contentList = response.data.contentList;
  477. this.contentIdsList = response.data.contentIdsList;
  478. });
  479. },
  480. /** 提交按钮 */
  481. submitForm () {
  482. this.$refs["form"].validate(valid => {
  483. if (valid) {
  484. if (this.form.labelText) {
  485. this.form.labelText = this.form.labelText.join(",")
  486. }
  487. this.form.contentIdsList = this.contentIdsList
  488. if (this.form.markerId != null) {
  489. updateMarker(this.form).then(response => {
  490. this.msgSuccess("修改成功");
  491. this.open = false;
  492. if (this.map) {
  493. this.map.destroy()
  494. this.map = null
  495. }
  496. this.getList();
  497. });
  498. } else {
  499. addMarker(this.form).then(response => {
  500. this.msgSuccess("新增成功");
  501. this.open = false;
  502. if (this.map) {
  503. this.map.destroy()
  504. this.map = null
  505. }
  506. this.getList();
  507. });
  508. }
  509. }
  510. });
  511. },
  512. /** 删除按钮操作 */
  513. handleDelete (row) {
  514. const markerIds = row.markerId || this.ids;
  515. this.$confirm('是否确认删除标记物管理编号为"' + markerIds + '"的数据项?', "警告", {
  516. confirmButtonText: "确定",
  517. cancelButtonText: "取消",
  518. type: "warning"
  519. }).then(function () {
  520. return delMarker(markerIds);
  521. }).then(() => {
  522. this.getList();
  523. this.msgSuccess("删除成功");
  524. }).catch(() => { });
  525. },
  526. /** 导出按钮操作 */
  527. handleExport () {
  528. const queryParams = this.queryParams;
  529. this.$confirm('是否确认导出所有标记物管理数据项?', "警告", {
  530. confirmButtonText: "确定",
  531. cancelButtonText: "取消",
  532. type: "warning"
  533. }).then(() => {
  534. this.exportLoading = true;
  535. return exportMarker(queryParams);
  536. }).then(response => {
  537. this.download(response.msg);
  538. this.exportLoading = false;
  539. }).catch(() => { });
  540. },
  541. /**初始化地图 */
  542. initMap () {
  543. this.positionList = []
  544. this.TMap().then(_tmap => {
  545. this.tmap = _tmap
  546. console.log(this.$refs.containerRef)
  547. // 初始化地图
  548. var center = new _tmap.LatLng(this.centerLat, this.centerLng) // 设置地图中心点坐标
  549. if (this.form.lat && this.form.lng) {
  550. center = new _tmap.LatLng(this.form.lat, this.form.lng)
  551. }
  552. this.map = new _tmap.Map(this.$refs.containerRef, {
  553. zoom: 15, // 设置地图缩放级别
  554. center: center
  555. })
  556. this.marker = new _tmap.MultiMarker({
  557. map: this.map
  558. });
  559. this.polyline = new _tmap.MultiPolyline({
  560. map: this.map
  561. })
  562. this.polygon = new _tmap.MultiPolygon({
  563. map: this.map
  564. })
  565. this.circle = new _tmap.MultiCircle({
  566. map: this.map
  567. })
  568. if (this.form.shapeType == "marker" && this.form.lat && this.form.lng) {
  569. // 点标签
  570. //添加自定图标
  571. if (this.form.iconPictures) {
  572. var style = new _tmap.MarkerStyle({
  573. "width": 40,
  574. "height": 40,
  575. "anchor": { x: 16, y: 32 },
  576. "src": this.baseUrl + this.form.iconPictures
  577. })
  578. this.marker.setStyles({ "default": style })
  579. }
  580. // var centerMarker = new _tmap.LatLng(this.form.lat, this.form.lng)
  581. // console.log(center)
  582. // var geometrie = {
  583. // position: centerMarker
  584. // }
  585. var locationSet = JSON.parse(this.form.locationSet)
  586. var geometries = []
  587. locationSet.forEach((item,index) => {
  588. this.positionList.push(item)
  589. var position = {
  590. "position": new TMap.LatLng(item.lat, item.lng)
  591. }
  592. geometries.push(position)
  593. });
  594. console.log(geometries)
  595. this.marker.setGeometries(geometries)
  596. } else if (this.form.shapeType == "polyline" && this.form.lat && this.form.lng) {
  597. //线
  598. // var centerPolyline = new _tmap.LatLng(this.form.lat, this.form.lng)
  599. var locationSet = JSON.parse(this.form.locationSet)
  600. var geometries = []
  601. locationSet.forEach(item => {
  602. geometries.push(new _tmap.LatLng(item.lat, item.lng))
  603. });
  604. this.polyline.setGeometries([{
  605. paths: geometries
  606. }])
  607. } else if (this.form.shapeType == "polygon" && this.form.lat && this.form.lng) {
  608. //线
  609. // var centerPolyline = new _tmap.LatLng(this.form.lat, this.form.lng)
  610. var locationSet = JSON.parse(this.form.locationSet)
  611. var geometries = []
  612. locationSet.forEach(item => {
  613. geometries.push(new _tmap.LatLng(item.lat, item.lng))
  614. });
  615. this.polygon.setGeometries([{
  616. paths: geometries
  617. }])
  618. }
  619. else if (this.form.shapeType == "circle" && this.form.lat && this.form.lng) {
  620. //线
  621. // var centerPolyline = new _tmap.LatLng(this.form.lat, this.form.lng)
  622. var geometry = { center: new _tmap.LatLng(this.form.lat, this.form.lng), radius: this.form.radius }
  623. console.log(geometry)
  624. this.circle.setGeometries([geometry])
  625. }
  626. // 初始化几何图形及编辑器
  627. this.editor = new _tmap.tools.GeometryEditor({
  628. map: this.map, // 编辑器绑定的地图对象
  629. overlayList: [ // 可编辑图层
  630. {
  631. overlay: this.marker,
  632. id: 'marker'
  633. },
  634. {
  635. overlay: this.polyline,
  636. id: 'polyline'
  637. },
  638. {
  639. overlay: this.polygon,
  640. id: 'polygon'
  641. }, ,
  642. {
  643. overlay: this.circle,
  644. id: 'circle'
  645. }
  646. ],
  647. actionMode: _tmap.tools.constants.EDITOR_ACTION.DRAW, // 编辑器的工作模式
  648. activeOverlayId: this.form.shapeType, // 激活图层
  649. selectable: true, // 开启点选功能
  650. snappable: true // 开启吸附
  651. })
  652. // 监听绘制结束事件,获取绘制几何图形
  653. this.editor.on('draw_complete', (geometry) => {
  654. console.log(geometry)
  655. var position = undefined;
  656. var geometries = [geometry]
  657. if (this.form.shapeType === "marker") {
  658. position = geometry.position
  659. this.positionList.push(position);
  660. this.form.locationSet = JSON.stringify(this.positionList);
  661. console.log(this.form.locationSet)
  662. //this.marker.setGeometries(geometries)
  663. } else if (this.form.shapeType === "polyline") {
  664. position = geometry.paths[0]
  665. this.form.locationSet = JSON.stringify(geometry.paths);
  666. this.polyline.setGeometries(geometries)
  667. } else if (this.form.shapeType === "polygon") {
  668. position = geometry.paths[0]
  669. this.form.locationSet = JSON.stringify(geometry.paths);
  670. this.polygon.setGeometries(geometries)
  671. } else if (this.form.shapeType === "circle") {
  672. position = geometry.center
  673. this.form.radius = geometry.radius.toFixed(2)
  674. this.form.locationSet = JSON.stringify(geometry.center);
  675. this.circle.setGeometries(geometries)
  676. }
  677. if (position) {
  678. this.form.lat = position.lat
  679. this.form.lng = position.lng
  680. }
  681. })
  682. // this.editor.disable()
  683. })
  684. },
  685. handleClick () {
  686. if (this.activeName = "second") {
  687. if (!this.map) {
  688. setTimeout(() => {
  689. this.initMap()
  690. }, 500);
  691. }
  692. }
  693. },
  694. shapeChange () {
  695. this.form.radius = 0
  696. this.form.locationSet = "";
  697. if (this.map && this.editor) {
  698. this.marker.setGeometries([])
  699. this.polyline.setGeometries([])
  700. this.polygon.setGeometries([])
  701. this.circle.setGeometries([])
  702. this.editor.setActiveOverlay(this.form.shapeType)
  703. }
  704. },
  705. markerTypeChange (val) {
  706. selectLabel(val).then(res => {
  707. console.log(res)
  708. this.labelList = res.data;
  709. })
  710. // selectLabel(this.form.markerType).then(res=>{
  711. // console.log(res);
  712. // })
  713. },
  714. closeDialog(){
  715. this.open = false;
  716. if (this.map) {
  717. this.map.destroy()
  718. this.map = null
  719. }
  720. this.getList();
  721. }
  722. }
  723. };
  724. </script>
  725. <style scoped>
  726. html,
  727. body {
  728. height: 100%;
  729. margin: 0px;
  730. padding: 0px;
  731. }
  732. #container {
  733. width: 100%;
  734. height: 550px;
  735. }
  736. #toolControl {
  737. position: absolute;
  738. top: 10px;
  739. left: 0px;
  740. right: 0px;
  741. margin: auto;
  742. width: 168px;
  743. z-index: 1001;
  744. }
  745. .toolItem {
  746. width: 40px;
  747. height: 40px;
  748. float: left;
  749. margin: 1px;
  750. padding: 4px;
  751. border-radius: 3px;
  752. background-size: 30px 30px;
  753. background-position: 4px 4px;
  754. background-repeat: no-repeat;
  755. box-shadow: 0 1px 2px 0 #e4e7ef;
  756. background-color: #ffffff;
  757. border: 1px solid #ffffff;
  758. }
  759. .toolItem:hover {
  760. border-color: #789cff;
  761. }
  762. .active {
  763. border-color: #d5dff2;
  764. background-color: #d5dff2;
  765. }
  766. #polygon {
  767. background-image: url("https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/polygon.png");
  768. }
  769. #circle {
  770. background-image: url("https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/circle.png");
  771. }
  772. </style>