| | |
| | | import { CURRENT_CONFIG } from '/@/api/http/config' |
| | | import { load } from '@amap/amap-jsapi-loader' |
| | | import { getRoot } from '/@/root' |
| | | import kmz from '/@/assets/kmz/test.kmz' |
| | | import togeojson from '@mapbox/togeojson' |
| | | |
| | | const loading = ref(false) |
| | | const store = useMyStore() |
| | |
| | | |
| | | function selectRoute (wayline: WaylineFile) { |
| | | store.commit('SET_SELECT_WAYLINE_INFO', wayline) |
| | | console.log(wayline, 'wayline') |
| | | downloadWaylineFile(workspaceId, wayline.id).then(async res => { |
| | | if (!res) { |
| | | return |
| | | } |
| | | console.log(res, 'res') |
| | | const data = new Blob([res], { type: 'application/kmz' }) |
| | | // downloadFile(data, fileName + '.kmz') |
| | | await analysisKMLFile(data) |
| | | }).finally(() => { |
| | | loading.value = false |
| | | }) |
| | | } |
| | | |
| | | function onScroll (e: any) { |
| | |
| | | if (element.scrollTop + element.clientHeight >= element.scrollHeight - 5 && Math.ceil(pagination.total / pagination.page_size) > pagination.page && canRefresh.value) { |
| | | pagination.page++ |
| | | getWaylines() |
| | | } |
| | | } |
| | | // 解析kml文件 |
| | | const analysisKMLFile = file => { |
| | | const reader = new FileReader() |
| | | reader.readAsText(file, 'utf-8') |
| | | reader.onload = function (e) { |
| | | const xml = new DOMParser().parseFromString(e.target.result, 'text/xml') |
| | | const geojson = togeojson.kml(xml, { |
| | | style: true |
| | | }) |
| | | console.log(geojson, 'geojson') |
| | | } |
| | | } |
| | | interface FileItem { |