@@ -82175,6 +82175,16 @@ var OpenFileView = external_L_default.a.Control.extend({
82175
82175
return this._initOpenFileView();
82176
82176
},
82177
82177
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
+
82178
82188
/**
82179
82189
* @function L.supermap.widgets.openfile.prototype._initOpenFileView
82180
82190
* @description 创建打开本地文件数据微件
@@ -82200,39 +82210,38 @@ var OpenFileView = external_L_default.a.Control.extend({
82200
82210
this.fileInput = external_L_default.a.DomUtil.create('input', 'openFile_input', this.fileSelect);
82201
82211
this.fileInput.id = "input_file";
82202
82212
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"
82204
82214
82205
82215
this.fileInput.onchange = (fileEventObject) => {
82206
82216
this.messageBox.closeView();
82207
82217
this.viewModel.readFile(fileEventObject);
82208
82218
};
82209
-
82210
82219
//增加提示框:
82211
82220
this.messageBox = new MessageBox();
82212
82221
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
+ });
82217
82235
this.viewModel.on("openfilesuccess", (e) => {
82218
82236
this.event.fire("openfilesuccess", e);
82219
82237
});
82220
82238
82239
+ this.rootContainer = uploadContent;
82221
82240
return uploadContent;
82222
82241
},
82223
82242
82224
82243
on(eventType, callback) {
82225
82244
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);
82236
82245
}
82237
82246
82238
82247
});
@@ -83458,7 +83467,7 @@ var DataFlowViewModel = external_L_default.a.Evented.extend({
83458
83467
//若当前数据流服务没变,则不进行重新订阅 todo 或者没点击暂停
83459
83468
if (this.urlDataFlow === urlDataFlow) {
83460
83469
if (this.dataFlowStatus) {
83461
- this.fire("dataFlowServiceSubscribed ");
83470
+ this.fire("dataflowfervicefubscribed ");
83462
83471
return;
83463
83472
}
83464
83473
} else {
@@ -83472,31 +83481,32 @@ var DataFlowViewModel = external_L_default.a.Evented.extend({
83472
83481
}
83473
83482
//创建DataFlowLayer,创建DataFlowLayer订阅iServer dataflow服务并将结果加载到地图上
83474
83483
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
+ });
83476
83505
dataFlowLayer.addTo(this.map);
83477
83506
83478
83507
this.dataFlowLayer = dataFlowLayer;
83479
83508
},
83480
83509
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
-
83500
83510
/**
83501
83511
* @function L.supermap.widgets.dataFlowViewModel.prototype.cancelSubscribe
83502
83512
* @description 取消订阅的数据流
@@ -83517,24 +83527,28 @@ var DataFlowViewModel = external_L_default.a.Evented.extend({
83517
83527
*/
83518
83528
openPopups() {
83519
83529
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
+ }
83524
83536
}
83525
-
83526
83537
}
83538
+
83527
83539
},
83528
83540
/**
83529
83541
* @function L.supermap.widgets.dataFlowViewModel.prototype.closePopups
83530
83542
* @description 关闭图层要素 popup
83531
83543
*/
83532
83544
closePopups() {
83533
83545
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
+ }
83538
83552
}
83539
83553
}
83540
83554
}
@@ -83602,13 +83616,11 @@ var DataFlowView = external_L_default.a.Control.extend({
83602
83616
}
83603
83617
if (this.options.onEachFeature) {
83604
83618
styleOptions.onEachFeature = this.options.onEachFeature;
83605
-
83606
83619
}
83607
83620
}
83608
-
83609
83621
this.styleOptions = styleOptions;
83610
-
83611
83622
},
83623
+
83612
83624
/**
83613
83625
* @function L.supermap.widgets.DataFlowView.prototype.onAdd
83614
83626
* @description 向底图添加微件
@@ -83619,6 +83631,15 @@ var DataFlowView = external_L_default.a.Control.extend({
83619
83631
return this._initView();
83620
83632
},
83621
83633
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
+
83622
83643
/**
83623
83644
* @function L.supermap.widgets.DataFlowView.prototype._initView
83624
83645
* @description 创建打开本地文件数据微件
@@ -83641,17 +83662,22 @@ var DataFlowView = external_L_default.a.Control.extend({
83641
83662
dataFlowInput.type = "text";
83642
83663
dataFlowInput.placeholder = "请输入数据流服务地址如:ws://{serviceRoot}/{dataFlowName}/dataflow/subscribe";
83643
83664
dataFlowInput.title = "请输入数据流服务地址如:ws://{serviceRoot}/{dataFlowName}/dataflow/subscribe";
83644
- //---输入框值改变,打开清除按钮
83645
- dataFlowInput.oninput = this.inputOnchange.bind(this);
83665
+
83646
83666
this.dataFlowInput = dataFlowInput;
83647
83667
dataFlowInputContainer.appendChild(dataFlowInput);
83648
83668
//删除输入值按钮:
83649
83669
const inputClearBtn = document.createElement("span");
83650
83670
inputClearBtn.setAttribute("class", "supermapol-icons-close");
83651
83671
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
+ };
83655
83681
dataFlowInputContainer.appendChild(inputClearBtn);
83656
83682
dataFlowContainer1.appendChild(dataFlowInputContainer);
83657
83683
@@ -83665,14 +83691,24 @@ var DataFlowView = external_L_default.a.Control.extend({
83665
83691
const attributesCheckbox = document.createElement("div");
83666
83692
attributesCheckbox.setAttribute("class", "widget-checkbox-default checkbox-selected-img");
83667
83693
attributesCheckbox.checked = true;
83668
- attributesCheckbox.onclick = this.isShowAttributes.bind(this);
83669
- this.attributesCheckbox = attributesCheckbox;
83670
83694
checkboxContainer.appendChild(attributesCheckbox);
83671
83695
const checkboxLabel = document.createElement("div");
83672
83696
checkboxLabel.setAttribute("class", "label label-selected");
83673
83697
checkboxLabel.innerHTML = "显示要素信息";
83674
- this.checkboxLabel = checkboxLabel;
83675
83698
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
+ };
83676
83712
83677
83713
dataFlowContainer2.appendChild(checkboxContainer);
83678
83714
widgetContent.appendChild(dataFlowContainer2);
@@ -83683,12 +83719,23 @@ var DataFlowView = external_L_default.a.Control.extend({
83683
83719
const subscribe = document.createElement("button");
83684
83720
subscribe.setAttribute("class", "widget-button-default");
83685
83721
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
+ };
83687
83731
dataFlowContainer3.appendChild(subscribe);
83688
83732
const cancelSubscribe = document.createElement("button");
83689
83733
cancelSubscribe.setAttribute("class", "widget-button-default");
83690
83734
cancelSubscribe.innerHTML = "取消订阅";
83691
- cancelSubscribe.onclick = this.cancelSubscribe.bind(this);
83735
+ //----取消订阅服务【取消订阅按钮点击事件】
83736
+ cancelSubscribe.onclick = () => {
83737
+ this.viewModel.cancelSubscribe();
83738
+ };
83692
83739
dataFlowContainer3.appendChild(cancelSubscribe);
83693
83740
widgetContent.appendChild(dataFlowContainer3);
83694
83741
@@ -83707,82 +83754,26 @@ var DataFlowView = external_L_default.a.Control.extend({
83707
83754
83708
83755
//增加提示框:
83709
83756
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
+ });
83711
83765
83712
83766
/**
83713
83767
* @event L.supermap.widgets.DataFlowView#dataupdated
83714
83768
* @description 数据流服务成功返回数据后触发
83715
83769
* @property {Object} result - 事件返回的数据对象。
83716
83770
*/
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
+ });
83718
83775
83719
83776
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;
83786
83777
}
83787
83778
83788
83779
});
0 commit comments