Skip to content

Commit 4f77032

Browse files
committed
【fix】微件,在有道上记录的缺陷。优化代码。
1 parent 581bd30 commit 4f77032

15 files changed

+831
-850
lines changed

dist/classic/include-classic.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@
7171
}
7272
if (!inArray(excludes, 'iclient-classic')) {
7373
if (supportES6()) {
74-
inputScript("../../dist/classic/iclient-classic-es6.js");
74+
inputScript("../../dist/classic/iclient-classic-es6.min.js");
7575
} else {
76-
inputScript("../../dist/classic/iclient-classic-es6.js");
76+
inputScript("../../dist/classic/iclient-classic.min.js");
7777
}
7878
}
7979
if (inArray(includes, 'tianditu')) {

dist/leaflet/iclient9-leaflet-es6.js

Lines changed: 118 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -82175,6 +82175,16 @@ var OpenFileView = external_L_default.a.Control.extend({
8217582175
return this._initOpenFileView();
8217682176
},
8217782177

82178+
/**
82179+
* @function L.supermap.widgets.openfile.prototype.onAdd
82180+
* @description 改变微件样式
82181+
* @param {string} styleName - css样式名
82182+
* @param {string} value - css样式值
82183+
*/
82184+
setViewStyle(styleName, value) {
82185+
this.rootContainer.style[styleName] = value;
82186+
},
82187+
8217882188
/**
8217982189
* @function L.supermap.widgets.openfile.prototype._initOpenFileView
8218082190
* @description 创建打开本地文件数据微件
@@ -82200,39 +82210,38 @@ var OpenFileView = external_L_default.a.Control.extend({
8220082210
this.fileInput = external_L_default.a.DomUtil.create('input', 'openFile_input', this.fileSelect);
8220182211
this.fileInput.id = "input_file";
8220282212
this.fileInput.type = "file";
82203-
this.fileInput.accept = ".json,.geojson,.csv,.xlsx,.xls,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
82213+
this.fileInput.accept = ".json,.geojson,.csv,.xls,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
8220482214

8220582215
this.fileInput.onchange = (fileEventObject) => {
8220682216
this.messageBox.closeView();
8220782217
this.viewModel.readFile(fileEventObject);
8220882218
};
82209-
8221082219
//增加提示框:
8221182220
this.messageBox = new MessageBox();
8221282221

82213-
this.viewModel.on("filesizeexceed", this._showMessageListener.bind(this));
82214-
this.viewModel.on("errorfileformat", this._showMessageListener.bind(this));
82215-
this.viewModel.on("openfilefail", this._showMessageListener.bind(this));
82216-
this.viewModel.on("readdatafail", this._showMessageListener.bind(this));
82222+
//添加监听
82223+
this.viewModel.on("filesizeexceed", (e) => {
82224+
this.messageBox.showView(e.message, e.messageType);
82225+
});
82226+
this.viewModel.on("errorfileformat", (e) => {
82227+
this.messageBox.showView(e.message, e.messageType);
82228+
});
82229+
this.viewModel.on("openfilefail", (e) => {
82230+
this.messageBox.showView(e.message, e.messageType);
82231+
});
82232+
this.viewModel.on("readdatafail", (e) => {
82233+
this.messageBox.showView(e.message, e.messageType);
82234+
});
8221782235
this.viewModel.on("openfilesuccess", (e) => {
8221882236
this.event.fire("openfilesuccess", e);
8221982237
});
8222082238

82239+
this.rootContainer = uploadContent;
8222182240
return uploadContent;
8222282241
},
8222382242

8222482243
on(eventType, callback) {
8222582244
this.event.on(eventType, callback);
82226-
},
82227-
82228-
/**
82229-
* @function L.supermap.widgets.openfile.prototype._showMessageListener
82230-
* @description 监听 OpenFileViewModel 事件,显示提示框
82231-
* @param {Object} e - 事件对象
82232-
* @private
82233-
*/
82234-
_showMessageListener(e) {
82235-
this.messageBox.showView(e.message, e.messageType);
8223682245
}
8223782246

8223882247
});
@@ -83458,7 +83467,7 @@ var DataFlowViewModel = external_L_default.a.Evented.extend({
8345883467
//若当前数据流服务没变,则不进行重新订阅 todo 或者没点击暂停
8345983468
if (this.urlDataFlow === urlDataFlow) {
8346083469
if (this.dataFlowStatus) {
83461-
this.fire("dataFlowServiceSubscribed");
83470+
this.fire("dataflowfervicefubscribed");
8346283471
return;
8346383472
}
8346483473
} else {
@@ -83472,31 +83481,32 @@ var DataFlowViewModel = external_L_default.a.Evented.extend({
8347283481
}
8347383482
//创建DataFlowLayer,创建DataFlowLayer订阅iServer dataflow服务并将结果加载到地图上
8347483483
const dataFlowLayer = new DataFlowLayer(urlDataFlow, this.options._defaultLayerOptions);
83475-
dataFlowLayer.on('dataupdated', this._defaultDataUpdatedCallBack.bind(this));
83484+
dataFlowLayer.on('subscribesuccessed', (result) => {
83485+
this.fire("subscribesuccessed", {result: result});
83486+
});
83487+
dataFlowLayer.on('dataupdated', (result) => {
83488+
//派发出订阅返回的数据:
83489+
this.fire("dataupdated", {result: result});
83490+
//若数据超出当前视图范围,则移动到数据所在视图范围:
83491+
let layerBounds = result.layer.getBounds(),
83492+
mapBounds = CommontypesConversion_CommontypesConversion.toSuperMapBounds(this.map.getBounds()),
83493+
layerBoundsSuperMap = CommontypesConversion_CommontypesConversion.toSuperMapBounds(layerBounds);
83494+
if (!mapBounds.intersectsBounds(layerBoundsSuperMap)) {
83495+
if (layerBoundsSuperMap.left === layerBoundsSuperMap.right && layerBoundsSuperMap.top === layerBoundsSuperMap.bottom) {
83496+
this.map.setView(layerBounds.getCenter())
83497+
} else {
83498+
this.map.flyToBounds(layerBounds);
83499+
}
83500+
}
83501+
if (this.popupsStatus) {
83502+
this.openPopups();
83503+
}
83504+
});
8347683505
dataFlowLayer.addTo(this.map);
8347783506

8347883507
this.dataFlowLayer = dataFlowLayer;
8347983508
},
8348083509

83481-
_defaultDataUpdatedCallBack(result) {
83482-
//派发出订阅返回的数据:
83483-
this.fire("dataupdated", {result: result});
83484-
//若数据超出当前视图范围,则移动到数据所在视图范围:
83485-
let layerBounds = result.layer.getBounds(),
83486-
mapBounds = CommontypesConversion_CommontypesConversion.toSuperMapBounds(this.map.getBounds()),
83487-
layerBoundsSuperMap = CommontypesConversion_CommontypesConversion.toSuperMapBounds(layerBounds);
83488-
if (!mapBounds.intersectsBounds(layerBoundsSuperMap)) {
83489-
if (layerBoundsSuperMap.left === layerBoundsSuperMap.right && layerBoundsSuperMap.top === layerBoundsSuperMap.bottom) {
83490-
this.map.setView(layerBounds.getCenter())
83491-
} else {
83492-
this.map.flyToBounds(layerBounds);
83493-
}
83494-
}
83495-
if (this.popupsStatus) {
83496-
this.openPopups();
83497-
}
83498-
},
83499-
8350083510
/**
8350183511
* @function L.supermap.widgets.dataFlowViewModel.prototype.cancelSubscribe
8350283512
* @description 取消订阅的数据流
@@ -83517,24 +83527,28 @@ var DataFlowViewModel = external_L_default.a.Evented.extend({
8351783527
*/
8351883528
openPopups() {
8351983529
this.popupsStatus = true;
83520-
const layers = this.dataFlowLayer.getLayers();
83521-
for (let i = 0; i < layers.length; i++) {
83522-
for (let j = 0; j < layers[i].getLayers().length; j++) {
83523-
layers[i].getLayers()[j].openPopup();
83530+
if (this.dataFlowLayer) {
83531+
const layers = this.dataFlowLayer.getLayers();
83532+
for (let i = 0; i < layers.length; i++) {
83533+
for (let j = 0; j < layers[i].getLayers().length; j++) {
83534+
layers[i].getLayers()[j].openPopup();
83535+
}
8352483536
}
83525-
8352683537
}
83538+
8352783539
},
8352883540
/**
8352983541
* @function L.supermap.widgets.dataFlowViewModel.prototype.closePopups
8353083542
* @description 关闭图层要素 popup
8353183543
*/
8353283544
closePopups() {
8353383545
this.popupsStatus = false;
83534-
const layers = this.dataFlowLayer.getLayers();
83535-
for (let i = 0; i < layers.length; i++) {
83536-
for (let j = 0; j < layers[i].getLayers().length; j++) {
83537-
layers[i].getLayers()[j].closePopup();
83546+
if (this.dataFlowLayer) {
83547+
const layers = this.dataFlowLayer.getLayers();
83548+
for (let i = 0; i < layers.length; i++) {
83549+
for (let j = 0; j < layers[i].getLayers().length; j++) {
83550+
layers[i].getLayers()[j].closePopup();
83551+
}
8353883552
}
8353983553
}
8354083554
}
@@ -83602,13 +83616,11 @@ var DataFlowView = external_L_default.a.Control.extend({
8360283616
}
8360383617
if (this.options.onEachFeature) {
8360483618
styleOptions.onEachFeature = this.options.onEachFeature;
83605-
8360683619
}
8360783620
}
83608-
8360983621
this.styleOptions = styleOptions;
83610-
8361183622
},
83623+
8361283624
/**
8361383625
* @function L.supermap.widgets.DataFlowView.prototype.onAdd
8361483626
* @description 向底图添加微件
@@ -83619,6 +83631,15 @@ var DataFlowView = external_L_default.a.Control.extend({
8361983631
return this._initView();
8362083632
},
8362183633

83634+
/**
83635+
* @function L.supermap.widgets.DataFlowView.prototype.on
83636+
* @param {string} eventType - 监听的事件类型
83637+
* @param {Function} callback - 监听事件的回调函数
83638+
*/
83639+
on(eventType, callback) {
83640+
this.event.on(eventType, callback);
83641+
},
83642+
8362283643
/**
8362383644
* @function L.supermap.widgets.DataFlowView.prototype._initView
8362483645
* @description 创建打开本地文件数据微件
@@ -83641,17 +83662,22 @@ var DataFlowView = external_L_default.a.Control.extend({
8364183662
dataFlowInput.type = "text";
8364283663
dataFlowInput.placeholder = "请输入数据流服务地址如:ws://{serviceRoot}/{dataFlowName}/dataflow/subscribe";
8364383664
dataFlowInput.title = "请输入数据流服务地址如:ws://{serviceRoot}/{dataFlowName}/dataflow/subscribe";
83644-
//---输入框值改变,打开清除按钮
83645-
dataFlowInput.oninput = this.inputOnchange.bind(this);
83665+
8364683666
this.dataFlowInput = dataFlowInput;
8364783667
dataFlowInputContainer.appendChild(dataFlowInput);
8364883668
//删除输入值按钮:
8364983669
const inputClearBtn = document.createElement("span");
8365083670
inputClearBtn.setAttribute("class", "supermapol-icons-close");
8365183671
inputClearBtn.hidden = true;
83652-
//---清除输入值
83653-
inputClearBtn.onclick = this.clearInputValue.bind(this);
83654-
this.inputClearBtn = inputClearBtn;
83672+
//---清除输入值【清除按钮点击事件】
83673+
inputClearBtn.onclick = (e) => {
83674+
dataFlowInput.value = "";
83675+
e.target.hidden = true;
83676+
};
83677+
//---输入框值改变,打开清除按钮【输入框内容改变事件】
83678+
dataFlowInput.oninput = () => {
83679+
inputClearBtn.hidden = false;
83680+
};
8365583681
dataFlowInputContainer.appendChild(inputClearBtn);
8365683682
dataFlowContainer1.appendChild(dataFlowInputContainer);
8365783683

@@ -83665,14 +83691,24 @@ var DataFlowView = external_L_default.a.Control.extend({
8366583691
const attributesCheckbox = document.createElement("div");
8366683692
attributesCheckbox.setAttribute("class", "widget-checkbox-default checkbox-selected-img");
8366783693
attributesCheckbox.checked = true;
83668-
attributesCheckbox.onclick = this.isShowAttributes.bind(this);
83669-
this.attributesCheckbox = attributesCheckbox;
8367083694
checkboxContainer.appendChild(attributesCheckbox);
8367183695
const checkboxLabel = document.createElement("div");
8367283696
checkboxLabel.setAttribute("class", "label label-selected");
8367383697
checkboxLabel.innerHTML = "显示要素信息";
83674-
this.checkboxLabel = checkboxLabel;
8367583698
checkboxContainer.appendChild(checkboxLabel);
83699+
//----是否显示属性框【属性框复选框点击事件】
83700+
attributesCheckbox.onclick = (e) => {
83701+
e.target.checked = !e.target.checked;
83702+
if (e.target.checked) {
83703+
checkboxLabel.setAttribute("class", "label label-selected");
83704+
e.target.setAttribute("class", "widget-checkbox-default checkbox-selected-img");
83705+
this.viewModel.openPopups();
83706+
} else {
83707+
checkboxLabel.setAttribute("class", "label");
83708+
e.target.setAttribute("class", "widget-checkbox-default checkbox-default-img");
83709+
this.viewModel.closePopups();
83710+
}
83711+
};
8367683712

8367783713
dataFlowContainer2.appendChild(checkboxContainer);
8367883714
widgetContent.appendChild(dataFlowContainer2);
@@ -83683,12 +83719,23 @@ var DataFlowView = external_L_default.a.Control.extend({
8368383719
const subscribe = document.createElement("button");
8368483720
subscribe.setAttribute("class", "widget-button-default");
8368583721
subscribe.innerHTML = "订阅";
83686-
subscribe.onclick = this.subscribe.bind(this);
83722+
//----订阅服务【订阅按钮点击事件】
83723+
subscribe.onclick = () => {
83724+
const urlDataFlow = dataFlowInput.value;
83725+
if (urlDataFlow === "") {
83726+
this.messageBox.showView("请先输入数据流服务地址。");
83727+
return;
83728+
}
83729+
this.viewModel.subscribe(urlDataFlow);
83730+
};
8368783731
dataFlowContainer3.appendChild(subscribe);
8368883732
const cancelSubscribe = document.createElement("button");
8368983733
cancelSubscribe.setAttribute("class", "widget-button-default");
8369083734
cancelSubscribe.innerHTML = "取消订阅";
83691-
cancelSubscribe.onclick = this.cancelSubscribe.bind(this);
83735+
//----取消订阅服务【取消订阅按钮点击事件】
83736+
cancelSubscribe.onclick = () => {
83737+
this.viewModel.cancelSubscribe();
83738+
};
8369283739
dataFlowContainer3.appendChild(cancelSubscribe);
8369383740
widgetContent.appendChild(dataFlowContainer3);
8369483741

@@ -83707,82 +83754,26 @@ var DataFlowView = external_L_default.a.Control.extend({
8370783754

8370883755
//增加提示框:
8370983756
this.messageBox = new MessageBox();
83710-
this.viewModel.on("dataFlowServiceSubscribed", this._showMessageBox.bind(this));
83757+
83758+
this.viewModel.on("dataflowfervicefubscribed", () => {
83759+
this.messageBox.showView("已订阅该数据流服务。");
83760+
});
83761+
83762+
this.viewModel.on("subscribesuccessed", () => {
83763+
this.messageBox.showView("数据流服务订阅成功。");
83764+
});
8371183765

8371283766
/**
8371383767
* @event L.supermap.widgets.DataFlowView#dataupdated
8371483768
* @description 数据流服务成功返回数据后触发
8371583769
* @property {Object} result - 事件返回的数据对象。
8371683770
*/
83717-
this.viewModel.on("dataupdated", (result) => self.event.fire("dataupdated", result));
83771+
this.viewModel.on("dataupdated", (result) => {
83772+
this.messageBox.closeView();
83773+
this.event.fire("dataupdated", result);
83774+
});
8371883775

8371983776
return widgetContainer;
83720-
},
83721-
83722-
_showMessageBox(e) {
83723-
if (e.type === "dataFlowServiceSubscribed") {
83724-
this.messageBox.showView("已订阅该数据流服务。");
83725-
}
83726-
},
83727-
83728-
/**
83729-
* @function L.supermap.widgets.DataFlowView.prototype.on
83730-
* @param {string} eventType - 监听的事件类型
83731-
* @param {Function} callback - 监听事件的回调函数
83732-
*/
83733-
on(eventType, callback) {
83734-
this.event.on(eventType, callback);
83735-
},
83736-
83737-
/**
83738-
* 订阅
83739-
* @private
83740-
*/
83741-
subscribe() {
83742-
const urlDataFlow = this.dataFlowInput.value;
83743-
if (urlDataFlow === "") {
83744-
this.messageBox.showView("请先输入数据流服务地址。");
83745-
return;
83746-
}
83747-
this.viewModel.subscribe(urlDataFlow);
83748-
},
83749-
/**
83750-
* 取消订阅
83751-
* @private
83752-
*/
83753-
cancelSubscribe() {
83754-
this.viewModel.cancelSubscribe();
83755-
},
83756-
/**
83757-
* 是否显示要素信息
83758-
* @private
83759-
*/
83760-
isShowAttributes(e) {
83761-
this.attributesCheckbox.checked = !e.target.checked;
83762-
if (this.attributesCheckbox.checked) {
83763-
this.checkboxLabel.setAttribute("class", "label label-selected");
83764-
this.attributesCheckbox.setAttribute("class", "widget-checkbox-default checkbox-selected-img");
83765-
this.viewModel.openPopups();
83766-
} else {
83767-
this.checkboxLabel.setAttribute("class", "label");
83768-
this.attributesCheckbox.setAttribute("class", "widget-checkbox-default checkbox-default-img");
83769-
this.viewModel.closePopups();
83770-
}
83771-
},
83772-
/**
83773-
* 清除输入框内容
83774-
* @private
83775-
*/
83776-
clearInputValue() {
83777-
this.dataFlowInput.value = "";
83778-
this.inputClearBtn.hidden = true;
83779-
},
83780-
/**
83781-
* 输入框值改变,打开清除按钮
83782-
* @private
83783-
*/
83784-
inputOnchange() {
83785-
this.inputClearBtn.hidden = false;
8378683777
}
8378783778

8378883779
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy