Skip to content

Commit 6c6c015

Browse files
committed
【fix】 fix poi 微件 点击列表和点 双向联动问题 & popup 内容不全问题 review by songym
1 parent a79f83c commit 6c6c015

File tree

5 files changed

+309
-120
lines changed

5 files changed

+309
-120
lines changed

dist/leaflet/iclient9-leaflet-es6.js

Lines changed: 107 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,34 @@
4444
/******/ // define getter function for harmony exports
4545
/******/ __webpack_require__.d = function(exports, name, getter) {
4646
/******/ if(!__webpack_require__.o(exports, name)) {
47-
/******/ Object.defineProperty(exports, name, {
48-
/******/ configurable: false,
49-
/******/ enumerable: true,
50-
/******/ get: getter
51-
/******/ });
47+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
5248
/******/ }
5349
/******/ };
5450
/******/
5551
/******/ // define __esModule on exports
5652
/******/ __webpack_require__.r = function(exports) {
53+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
54+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
55+
/******/ }
5756
/******/ Object.defineProperty(exports, '__esModule', { value: true });
5857
/******/ };
5958
/******/
59+
/******/ // create a fake namespace object
60+
/******/ // mode & 1: value is a module id, require it
61+
/******/ // mode & 2: merge all properties of value into the ns
62+
/******/ // mode & 4: return value when already ns object
63+
/******/ // mode & 8|1: behave like require
64+
/******/ __webpack_require__.t = function(value, mode) {
65+
/******/ if(mode & 1) value = __webpack_require__(value);
66+
/******/ if(mode & 8) return value;
67+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
68+
/******/ var ns = Object.create(null);
69+
/******/ __webpack_require__.r(ns);
70+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
71+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
72+
/******/ return ns;
73+
/******/ };
74+
/******/
6075
/******/ // getDefaultExport function for compatibility with non-harmony modules
6176
/******/ __webpack_require__.n = function(module) {
6277
/******/ var getter = module && module.__esModule ?
@@ -84321,12 +84336,19 @@ var SearchView = WidgetsViewBase.extend({
8432184336
this.clearSearchResult();
8432284337
this.searchResultLayer = external_L_default.a.featureGroup(data, {
8432384338
pointToLayer: this.options.style,
84324-
style: this.options.style,
84325-
onEachFeature: this.options.onEachFeature
84339+
style: this.options.style
8432684340
}).bindPopup(function (layer) {
84327-
return (new AttributesPopContainer_AttributesPopContainer(layer.feature.properties)).getElement();
84341+
if (layer.feature.properties) {
84342+
return (new AttributesPopContainer_AttributesPopContainer({
84343+
attributes: layer.feature.properties
84344+
})).getElement();
84345+
}
8432884346
}).addTo(this.map);
84329-
84347+
this.searchResultLayer.eachLayer((layer) => {
84348+
this.options.onEachFeature ?this.options.onEachFeature(layer.toGeoJSON(), layer):
84349+
this._featureOnclickEvent.bind(this)(layer.toGeoJSON(), layer);
84350+
});
84351+
this.searchLayersData = data;
8433084352
//查询结果列表:
8433184353
this._prepareResultData(data);
8433284354
/**
@@ -84344,15 +84366,18 @@ var SearchView = WidgetsViewBase.extend({
8434484366
const data = e.result;
8434584367
//先清空当前有的地址匹配图层
8434684368
this.clearSearchResult();
84347-
8434884369
this.searchResultLayer = external_L_default.a.geoJSON(data, {
8434984370
pointToLayer: this.options.style,
8435084371
style: this.options.style,
84351-
onEachFeature: this.options.onEachFeature
84372+
onEachFeature: this.options.onEachFeature || this._featureOnclickEvent.bind(this)
8435284373
}).bindPopup(function (layer) {
84353-
return (new AttributesPopContainer_AttributesPopContainer(layer.feature.properties)).getElement();
84374+
if (layer.feature.properties) {
84375+
return (new AttributesPopContainer_AttributesPopContainer({
84376+
attributes: layer.feature.properties
84377+
})).getElement();
84378+
}
8435484379
}).addTo(this.map);
84355-
84380+
this.searchLayersData = data
8435684381
//查询结果列表:
8435784382
this._prepareResultData(data);
8435884383
/**
@@ -84420,18 +84445,18 @@ var SearchView = WidgetsViewBase.extend({
8442084445
end;
8442184446
if (page === 1 && data.length < 8) {
8442284447
//data数据不满8个时:
84423-
end = data.length;
84448+
end = data.length - 1;
8442484449
} else if (page * 8 > data.length) {
8442584450
//最后一页且数据不满8个时
8442684451
start = 8 * (page - 1);
84427-
end = data.length
84452+
end = data.length - 1
8442884453
} else {
8442984454
//中间页面的情况
8443084455
start = 8 * (page - 1);
8443184456
end = page * 8 - 1
8443284457
}
8443384458
const content = document.createElement("div");
84434-
for (let i = start; i < end; i++) {
84459+
for (let i = start; i <= end; i++) {
8443584460
let properties, featureType = "Point";
8443684461
if (data[i].filterAttribute) {
8443784462
featureType = data[i].feature.geometry.type;
@@ -84448,7 +84473,7 @@ var SearchView = WidgetsViewBase.extend({
8444884473
content.firstChild.getElementsByClassName("widget-search-result-icon")[0].classList.add("widget-search__resultitme-selected");
8444984474
const filter = content.firstChild.getElementsByClassName("widget-search-result-info")[0].firstChild.innerText;
8445084475

84451-
this._linkageFeature(filter);
84476+
!this._selectMarkerFeature && this._linkageFeature(filter);
8445284477
},
8445384478

8445484479
/**
@@ -84480,25 +84505,19 @@ var SearchView = WidgetsViewBase.extend({
8448084505
} else {
8448184506
filterValue = filter;
8448284507
}
84483-
84508+
this._selectFeature && this._selectFeature.addTo(this.map);
8448484509
this.searchResultLayer.eachLayer((layer) => {
8448584510
// this._resetLayerStyleToDefault(layer);
84486-
8448784511
if (!filterValue || layer.filterAttribute && layer.filterAttribute.filterAttributeValue === filterValue ||
8448884512
layer.feature.properties && layer.feature.properties.name === filterValue) {
84513+
layer.remove();
84514+
8448984515
this._setSelectedLayerStyle(layer);
8449084516
/*layer.bindPopup(function () {
8449184517
return (new AttributesPopContainer(layer.feature.properties)).getElement()
8449284518
}, {closeOnClick: false}).openPopup().addTo(this.map);*/
8449384519
//若这个图层只有一个点的话,则直接 flyTo 到点:
84494-
this._flyToBounds(this.searchResultLayer.getBounds());
84495-
let center;
84496-
if (layer.getLatLng) {
84497-
center = layer.getLatLng();
84498-
} else if (layer.getCenter) {
84499-
center = layer.getCenter();
84500-
}
84501-
this.map.setView(center);
84520+
8450284521
}
8450384522
});
8450484523
},
@@ -84511,31 +84530,71 @@ var SearchView = WidgetsViewBase.extend({
8451184530
if (this.searchResultLayer) {
8451284531
this.map.closePopup();
8451384532
//若当前是查询图层的结果,则不删除图层,只修改样式
84514-
if (!this.isSearchLayer) {
84515-
this.map.removeLayer(this.searchResultLayer);
84516-
}
84517-
if (this._selectFeature) {
84518-
this.map.removeLayer(this._selectFeature);
84519-
}
84533+
!this.isSearchLayer && this.map.removeLayer(this.searchResultLayer);
84534+
this._selectMarkerFeature && this.map.removeLayer(this._selectMarkerFeature);
84535+
this._selectFeaturethis && this.map.removeLayer(this._selectFeature);
84536+
this._selectMarkerFeature = null;
8452084537
this._selectFeature = null;
8452184538
this.searchResultLayer = null;
8452284539
this.currentResult = null;
8452384540
}
8452484541
},
84542+
/**
84543+
* @function L.supermap.widgets.search.prototype._featureOnclickEvent
84544+
* @description 要素点击事件
84545+
* @param {L.layer} layer - 需要设置选中样式的图层。
84546+
* @private
84547+
*/
84548+
_featureOnclickEvent(feature, layer) {
84549+
layer.on('click', () => {
84550+
let pageEles1 = document.getElementsByClassName('widget-pagination__link')[0];
84551+
this._resultDomObj._changePageEvent({ target: pageEles1.children[0].children[0] });
84552+
this._selectFeature && this._selectFeature.addTo(this.map);
84553+
layer.remove();
84554+
let page, dataIndex;
84555+
84556+
for (let i = 0; i < this.searchLayersData.length; i++) {
84557+
let item = this.searchLayersData[i]
84558+
if ((item.properties && (item.properties.name === feature.properties.name)) || (item.filterAttribute && (item.filterAttribute.filterAttributeName + ": " + item.filterAttribute.filterAttributeValue) === (layer.filterAttribute.filterAttributeName + ": " + layer.filterAttribute.filterAttributeValue))) {
84559+
dataIndex = i % 8;
84560+
page = parseInt(i / 8) + 1;
84561+
break;
84562+
}
84563+
}
84564+
if (page > 1) {
84565+
for (let i = 1; i < page; i++) {
84566+
let pageEles;
84567+
pageEles = document.getElementsByClassName('widget-pagination__link')[0];
84568+
this._resultDomObj._changePageEvent({ target: pageEles.children[pageEles.children.length - 2].children[0] });
84569+
}
84570+
}
84571+
let pageList = document.getElementsByClassName('widget-search-result-info')
84572+
84573+
let target = pageList[dataIndex].children[0];
8452584574

84575+
if (target.innerHTML === feature.properties.name || target.innerHTML === (layer.filterAttribute.filterAttributeName + ": " + layer.filterAttribute.filterAttributeValue)) {
84576+
let selectFeatureOption = pageList[dataIndex].parentNode;
84577+
//修改
84578+
if (document.getElementsByClassName("widget-search__resultitme-selected").length > 0) {
84579+
document.getElementsByClassName("widget-search__resultitme-selected")[0].classList.remove("widget-search__resultitme-selected");
84580+
}
84581+
selectFeatureOption.firstChild.classList.add("widget-search__resultitme-selected");
84582+
this._setSelectedLayerStyle(layer);
84583+
}
84584+
}, this)
84585+
},
8452684586
/**
8452784587
* @function L.supermap.widgets.search.prototype._setSelectedLayerStyle
8452884588
* @description 设置图层选中样式。
8452984589
* @param {L.layer} layer - 需要设置选中样式的图层。
8453084590
* @private
8453184591
*/
8453284592
_setSelectedLayerStyle(layer) {
84533-
if (this._selectFeature) {
84534-
this.map.removeLayer(this._selectFeature);
84535-
this._selectFeature = null;
84536-
}
84593+
this._selectMarkerFeature && this._selectMarkerFeature.remove();
84594+
this._selectMarkerFeature = null;
84595+
this._selectFeature = layer;
8453784596
//circleMarker 需要变成 marker 的样式:
84538-
this._selectFeature = external_L_default.a.geoJSON(layer.toGeoJSON(), {
84597+
this._selectMarkerFeature = external_L_default.a.geoJSON(layer.toGeoJSON(), {
8453984598
//点选中样式, todo marker 显示位置需要调整
8454084599
pointToLayer: (geoJsonPoint, latlng) => {
8454184600
return external_L_default.a.marker(latlng, {
@@ -84554,14 +84613,22 @@ var SearchView = WidgetsViewBase.extend({
8455484613
fillOpacity: 0.2
8455584614
}
8455684615
}).addTo(this.map);
84557-
this._selectFeature.bindPopup(function () {
84616+
this._selectMarkerFeature.bindPopup(function () {
8455884617
return (new AttributesPopContainer_AttributesPopContainer({
8455984618
attributes: layer.feature.properties
8456084619
})).getElement()
8456184620
}, {
8456284621
closeOnClick: false
8456384622
}).openPopup().addTo(this.map);
8456484623

84624+
this._flyToBounds(this.searchResultLayer.getBounds());
84625+
let center;
84626+
if (layer.getLatLng) {
84627+
center = layer.getLatLng();
84628+
} else if (layer.getCenter) {
84629+
center = layer.getCenter();
84630+
}
84631+
this.map.setView(center);
8456584632
}
8456684633
});
8456784634

@@ -90938,7 +91005,7 @@ module.exports = function(proj4){
9093891005
/* 74 */
9093991006
/***/ (function(module) {
9094091007

90941-
module.exports = {"_from":"proj4@2.3.15","_id":"proj4@2.3.15","_inBundle":false,"_integrity":"sha1-WtBui8owvg/6OJpJ5FZfUfBtCJ4=","_location":"/proj4","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"proj4@2.3.15","name":"proj4","escapedName":"proj4","rawSpec":"2.3.15","saveSpec":null,"fetchSpec":"2.3.15"},"_requiredBy":["/"],"_resolved":"http://registry.npm.taobao.org/proj4/download/proj4-2.3.15.tgz","_shasum":"5ad06e8bca30be0ffa389a49e4565f51f06d089e","_spec":"proj4@2.3.15","_where":"F:\\dev\\iClient-JavaScript","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"bundleDependencies":false,"contributors":[{"name":"Mike Adair","email":"madair@dmsolutions.ca"},{"name":"Richard Greenwood","email":"rich@greenwoodmap.com"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"},{"name":"Richard Marsden","url":"http://www.winwaed.com"},{"name":"T. Mittan"},{"name":"D. Steinwand"},{"name":"S. Nelson"}],"dependencies":{"mgrs":"~0.0.2"},"deprecated":false,"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"browserify":"~12.0.1","chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"~0.4.2","grunt-browserify":"~4.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~0.8.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","istanbul":"~0.2.4","mocha":"~1.17.1","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"homepage":"https://github.com/proj4js/proj4js#readme","jam":{"main":"dist/proj4.js","include":["dist/proj4.js","README.md","AUTHORS","LICENSE.md"]},"license":"MIT","main":"lib/index.js","name":"proj4","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"test":"./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"},"version":"2.3.15"};
91008+
module.exports = {"_args":[["proj4@2.3.15","D:\\iClient-JavaScript"]],"_from":"proj4@2.3.15","_id":"proj4@2.3.15","_inBundle":false,"_integrity":"sha1-WtBui8owvg/6OJpJ5FZfUfBtCJ4=","_location":"/proj4","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"proj4@2.3.15","name":"proj4","escapedName":"proj4","rawSpec":"2.3.15","saveSpec":null,"fetchSpec":"2.3.15"},"_requiredBy":["/"],"_resolved":"http://registry.npm.taobao.org/proj4/download/proj4-2.3.15.tgz","_spec":"2.3.15","_where":"D:\\iClient-JavaScript","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"contributors":[{"name":"Mike Adair","email":"madair@dmsolutions.ca"},{"name":"Richard Greenwood","email":"rich@greenwoodmap.com"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"},{"name":"Richard Marsden","url":"http://www.winwaed.com"},{"name":"T. Mittan"},{"name":"D. Steinwand"},{"name":"S. Nelson"}],"dependencies":{"mgrs":"~0.0.2"},"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"browserify":"~12.0.1","chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"~0.4.2","grunt-browserify":"~4.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~0.8.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","istanbul":"~0.2.4","mocha":"~1.17.1","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"homepage":"https://github.com/proj4js/proj4js#readme","jam":{"main":"dist/proj4.js","include":["dist/proj4.js","README.md","AUTHORS","LICENSE.md"]},"license":"MIT","main":"lib/index.js","name":"proj4","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"test":"./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"},"version":"2.3.15"};
9094291009

9094391010
/***/ }),
9094491011
/* 75 */

dist/leaflet/iclient9-leaflet-es6.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)