diff --git a/src/Global/FlyRoam/index.js b/src/Global/FlyRoam/index.js index 576c3e8..24ecc9e 100644 --- a/src/Global/FlyRoam/index.js +++ b/src/Global/FlyRoam/index.js @@ -322,11 +322,12 @@ const close = () => { // _DialogObject = null // } let contentElm = document.getElementsByClassName('fly-roam')[0] - - let tableBody = contentElm.getElementsByClassName('table-body')[0]; - let trList = tableBody.getElementsByClassName('tr') - for (let i = trList.length - 1; i >= 0; i--) { - tableBody.removeChild(trList[i]) + if(contentElm) { + let tableBody = contentElm.getElementsByClassName('table-body')[0]; + let trList = tableBody.getElementsByClassName('tr') + for (let i = trList.length - 1; i >= 0; i--) { + tableBody.removeChild(trList[i]) + } } repeat = 0 diff --git a/src/Obj/Base/BaseSource/BaseLayer/ArcgisImagery/index.js b/src/Obj/Base/BaseSource/BaseLayer/ArcgisImagery/index.js index 69ac8c9..a71ec29 100644 --- a/src/Obj/Base/BaseSource/BaseLayer/ArcgisImagery/index.js +++ b/src/Obj/Base/BaseSource/BaseLayer/ArcgisImagery/index.js @@ -28,8 +28,8 @@ class ArcgisLayer extends BaseLayer { url }); } - if (this.options.hasOwnProperty("layer_index")) { - this.entity = this.sdk.viewer.imageryLayers.addImageryProvider(imageryProvider, this.options.layer_index) + if (this.options.hasOwnProperty("layerIndex")) { + this.entity = this.sdk.viewer.imageryLayers.addImageryProvider(imageryProvider, this.options.layerIndex) } else { this.entity = this.sdk.viewer.imageryLayers.addImageryProvider(imageryProvider,) } diff --git a/src/Obj/Base/BaseSource/BaseLayer/GdImagery/index.js b/src/Obj/Base/BaseSource/BaseLayer/GdImagery/index.js index 788338b..80dd2fb 100644 --- a/src/Obj/Base/BaseSource/BaseLayer/GdImagery/index.js +++ b/src/Obj/Base/BaseSource/BaseLayer/GdImagery/index.js @@ -25,8 +25,8 @@ class GdImagery extends BaseLayer { tilingScheme: this.amapMercatorTilingScheme() }) - if (this.options.hasOwnProperty("layer_index")) { - this.entity = this.sdk.viewer.imageryLayers.addImageryProvider(gdLayer, this.options.layer_index) + if (this.options.hasOwnProperty("layerIndex")) { + this.entity = this.sdk.viewer.imageryLayers.addImageryProvider(gdLayer, this.options.layerIndex) } else { this.entity = this.sdk.viewer.imageryLayers.addImageryProvider(gdLayer,) } diff --git a/src/Obj/Base/BaseSource/BaseLayer/Layer/index.js b/src/Obj/Base/BaseSource/BaseLayer/Layer/index.js index ab904f7..d17936b 100644 --- a/src/Obj/Base/BaseSource/BaseLayer/Layer/index.js +++ b/src/Obj/Base/BaseSource/BaseLayer/Layer/index.js @@ -105,9 +105,9 @@ class Layer extends BaseLayer { if (!this.sdk || !this.sdk.viewer) { return } - if (this.options.hasOwnProperty("layer_index")) { + if (this.options.hasOwnProperty("layerIndex")) { this.entity = - this.sdk.viewer.scene.imageryLayers.addImageryProvider(layer, this.options.layer_index) + this.sdk.viewer.scene.imageryLayers.addImageryProvider(layer, this.options.layerIndex) } else { this.entity = this.sdk.viewer.scene.imageryLayers.addImageryProvider(layer,) diff --git a/src/Obj/Base/BaseSource/BaseLayer/Layer3rdparty/index.js b/src/Obj/Base/BaseSource/BaseLayer/Layer3rdparty/index.js index ed0d95b..9e7060b 100644 --- a/src/Obj/Base/BaseSource/BaseLayer/Layer3rdparty/index.js +++ b/src/Obj/Base/BaseSource/BaseLayer/Layer3rdparty/index.js @@ -30,9 +30,9 @@ class Layer3rdparty extends BaseLayer { let layer layer = new Cesium.UrlTemplateImageryProvider(params) - if (this.options.hasOwnProperty("layer_index")) { + if (this.options.hasOwnProperty("layerIndex")) { this.entity = - this.sdk.viewer.scene.imageryLayers.addImageryProvider(layer, this.options.layer_index) + this.sdk.viewer.scene.imageryLayers.addImageryProvider(layer, this.options.layerIndex) } else { this.entity = this.sdk.viewer.scene.imageryLayers.addImageryProvider(layer,) diff --git a/src/Obj/Base/BaseSource/BaseLayer/index.js b/src/Obj/Base/BaseSource/BaseLayer/index.js index 08c0b3a..f553ef6 100644 --- a/src/Obj/Base/BaseSource/BaseLayer/index.js +++ b/src/Obj/Base/BaseSource/BaseLayer/index.js @@ -73,7 +73,7 @@ class BaseLayer extends BaseSource { this.sdk.viewer.imageryLayers.raiseToTop(layer) } } - this.options.layer_index = this.entity._layerIndex + this.options.layerIndex = this.entity._layerIndex return this.entity._layerIndex } @@ -84,7 +84,7 @@ class BaseLayer extends BaseSource { * */ layerLower() { this.sdk.viewer.imageryLayers.lower(this.entity) - this.options.layer_index = this.entity._layerIndex + this.options.layerIndex = this.entity._layerIndex return this.entity._layerIndex } @@ -101,7 +101,7 @@ class BaseLayer extends BaseSource { this.sdk.viewer.imageryLayers.raiseToTop(layer) } } - this.options.layer_index = this.entity._layerIndex + this.options.layerIndex = this.entity._layerIndex return this.entity._layerIndex } @@ -112,7 +112,7 @@ class BaseLayer extends BaseSource { * */ layerToBottom() { this.sdk.viewer.imageryLayers.lowerToBottom(this.entity) - this.options.layer_index = this.entity._layerIndex + this.options.layerIndex = this.entity._layerIndex return this.entity._layerIndex } diff --git a/src/Obj/Base/Vector/index.js b/src/Obj/Base/Vector/index.js index 84dcd33..479c150 100644 --- a/src/Obj/Base/Vector/index.js +++ b/src/Obj/Base/Vector/index.js @@ -42,8 +42,8 @@ class Vector extends Base { return } this.colors = colors - this.options.head_tables = options.head_tables || [] - this.options.fileName = options.fileName || '未命名对象' + this.options.headTables = options.headTables || [] + this.options.name = options.name || '未命名对象' if (!this.options.path.endsWith('.kml')) { ; (this.options.color = options.color || 'rgba(0,255,184,0.5)'), @@ -120,34 +120,34 @@ class Vector extends Base { } async init() { - let url = '' - this.options.host = this.options.host || getHost() - if (this.options.host.endsWith('yjearth4.0')) { - url = this.options.host + '/api/v1/vector/load2' - } else { - url = this.options.host + '/yjearth4.0/api/v1/vector/load2' - } - url += '?path=' + this.options.path - // url = 'json/shp.json' - let response = await fetch(url, { - method: 'get', - headers: { - 'Content-Type': 'application/json', - token: getToken(), - Authorization: 'Bearer ' + getToken() + return new Promise(async (resolve, reject) => { + let url = '' + this.options.host = this.options.host || getHost() + url = this.options.host + '/gdal/import' + // url = 'json/shp.json' + let params = new FormData() + params.append('path', this.options.path) + let response = await fetch(url, { + method: 'post', + headers: { + Authorization: getToken() + }, + body: params + }) + console.log('response', response) + if (response.status === 200) { + let arrayBuffer = await response.arrayBuffer() + let uint8Array = new Uint8Array(arrayBuffer) + let string = this.decompressGzip(uint8Array) + if (this.data.length === 0) { + this.data = JSON.parse(string) + } + console.log('this.data', this.data) + await this.formatData() + Vector.create(this) + resolve() } - }) - if (response.status === 200) { - let arrayBuffer = await response.arrayBuffer() - let uint8Array = new Uint8Array(arrayBuffer) - let string = this.decompressGzip(uint8Array) - if(this.data.length===0) - { - this.data = JSON.parse(string) - } - await this.formatData() - return Vector.create(this) - } + }); } // 格式化数据 @@ -195,16 +195,16 @@ class Vector extends Base { } for (let m = 0; m < this.data.list[i].features.length; m++) { this.data.list[i].features[m].properties.id - if(!this.data.list[i].features[m].properties) { + if (!this.data.list[i].features[m].properties) { this.data.list[i].features[m].properties = {} } - if(!this.data.list[i].features[m].properties.id) { + if (!this.data.list[i].features[m].properties.id) { this.data.list[i].features[m].properties.id = Cesium.createGuid() } this.data.list[i].features[m].id = this.data.list[i].features[m].properties.id posConvert( this.data.list[i].features[m].geometry, - this.data.list[i].crs_src, + this.data.list[i].crs_src || '+proj=longlat +datum=WGS84 +no_defs', this.data.list[i].crs_dst || '+proj=longlat +datum=WGS84 +no_defs' ) this.data.list[i].features[m].geometry.geometries || @@ -231,12 +231,12 @@ class Vector extends Base { // } } - get fileName() { - return this.options.fileName + get name() { + return this.options.name } - set fileName(v) { - this.options.fileName = v - this._elms.fileName && (this._elms.fileName.value = v) + set name(v) { + this.options.name = v + this._elms.name && (this._elms.name.value = v) } get field() { @@ -252,9 +252,9 @@ class Vector extends Base { // } // } let label = v - for (let index = 0; index < this.options.head_tables.length; index++) { - if (this.options.head_tables[index].key === v) { - label = this.options.head_tables[index].label + for (let index = 0; index < this.options.headTables.length; index++) { + if (this.options.headTables[index].key === v) { + label = this.options.headTables[index].label break } } @@ -348,13 +348,8 @@ class Vector extends Base { ) { let url = '' that.options.host = that.options.host || getHost() - if (that.options.host.endsWith('yjearth4.0')) { - url = that.options.host + '/api/v1/vector/getKml' - } else { - url = that.options.host + '/yjearth4.0/api/v1/vector/getKml' - } + url = that.options.host + '/fileInfo/previewLocal' url += '?path=' + that.options.path - // url = 'json/shp.json' fetch(url, { method: 'get', headers: { @@ -734,17 +729,17 @@ class Vector extends Base { left: '180px', top: '100px', confirmCallBack: options => { - this.fileName = this.fileName.trim() - if (!this.fileName) { - this.fileName = '未命名对象' + this.name = this.name.trim() + if (!this.name) { + this.name = '未命名对象' } - this.originalOptions.fileName = this.fileName + this.originalOptions.name = this.name this.originalOptions.field = this.field this._DialogObject.close() DialogEvent.confirmCallBack && DialogEvent.confirmCallBack({ id: this.options.id, - fileName: this.originalOptions.fileName, + name: this.originalOptions.name, field: this.originalOptions.field }) }, @@ -772,17 +767,17 @@ class Vector extends Base { this._DialogObject.contentAppChild(contentElm) let nameElm = contentElm.getElementsByClassName('flie-name')[0] - nameElm.value = this.options.fileName + nameElm.value = this.options.name nameElm.addEventListener('input', () => { - this.options.fileName = nameElm.value + this.options.name = nameElm.value }) let keyData = [] for (let key in this.geojson.features[0].properties) { let label = key - for (let index = 0; index < this.options.head_tables.length; index++) { - if (this.options.head_tables[index].key === key) { - label = this.options.head_tables[index].label + for (let index = 0; index < this.options.headTables.length; index++) { + if (this.options.headTables[index].key === key) { + label = this.options.headTables[index].label break } } @@ -820,7 +815,7 @@ class Vector extends Base { }) this._elms.field = keyDataLegpElm } - this._elms.fileName = nameElm + this._elms.name = nameElm return @@ -833,9 +828,9 @@ class Vector extends Base { for (let key in this.geojson.features[0].properties) { let label = key - for (let index = 0; index < this.options.head_tables.length; index++) { - if (this.options.head_tables[index].key === key) { - label = this.options.head_tables[index].label + for (let index = 0; index < this.options.headTables.length; index++) { + if (this.options.headTables[index].key === key) { + label = this.options.headTables[index].label break } } @@ -848,7 +843,7 @@ class Vector extends Base { this.options.field = selectElm.value }) - this._elms.fileName = nameElm + this._elms.name = nameElm this._elms.field = selectElm } else { if (this._DialogObject && this._DialogObject.close) { @@ -858,255 +853,6 @@ class Vector extends Base { } } - async editById(status = false, nodeId, DialogEvent = {}) { - // nodeId = this.dataArray[0].attr.id - if (this._DialogObject && this._DialogObject.close) { - this._DialogObject.close() - this._DialogObject = null - } - let cameraName = '' - let index - if (status) { - let options = {} - for (let i = 0; i < this.geojson.features.length; i++) { - if (this.geojson.features[i].id === nodeId) { - if (this.geojson.features[i].content) { - options = this.deepCopyObj(this.geojson.features[i].content) - } - index = i - break - } - } - options.id = options.id || nodeId - options.link || (options.link = {}) - options.link.content || (options.link.content = []) - options.camera || (options.camera = []) - options.richTextContent || (options.richTextContent = '') - options.attributeType = options.attributeType || 'richText' - this._DialogObject = await new Dialog(this.sdk, options, { - title: '编辑属性', - left: '180px', - top: '100px', - confirmCallBack: () => { - this._DialogObject.close() - this.geojson.features[index].content = this.deepCopyObj( - this._DialogObject.attribute - ) - DialogEvent.confirmCallBack && - DialogEvent.confirmCallBack(this._DialogObject.attribute) - }, - closeCallBack: () => { - // this.reset() - DialogEvent.closeCallBack && DialogEvent.closeCallBack() - } - }) - this._DialogObject.event = DialogEvent - this._DialogObject.attribute = this.deepCopyObj(options) - let html = ` -
暂无数据
-暂无数据
-