Skip to content

Commit 8496f10

Browse files
committed
【fix】 优化 POI 微件 & API review by songym
1 parent c29fa9f commit 8496f10

File tree

7 files changed

+266
-259
lines changed

7 files changed

+266
-259
lines changed

dist/leaflet/iclient9-leaflet-es6.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83895,13 +83895,13 @@ external_L_default.a.supermap.widgets.searchViewModel = searchViewModel;
8389583895
* @category Widgets Search
8389683896
* @version 9.1.1
8389783897
* @param {Object} options - 可选参数。
83898-
* @param {string} [options.addressUrl] - 配置地址匹配服务。
8389983898
* @param {Object|Array.<string>} [options.cityConfig] - 城市地址匹配配置,默认为全国城市,与 options.cityGeoCodingConfig 支持匹配的服务对应;
8390083899
* 配置两种格式:{key1:{A:[],B:[]}, key2:{C:[],D:[]}} 或 ["成都市","北京市"],用户可根据自己的项目需求进行配置
8390183900
* @param {Object} [options.cityGeoCodingConfig] - 城市地址匹配服务配置,包括:{addressUrl:"",key:""} 默认为 online 地址匹配服务,与 options.cityConfig 对应
8390283901
* @param {boolean} [options.isGeoCoding=true] - 是否支持城市地址匹配功能。
83903-
* @param {boolean} [options.pageSize=10] - 返回记录结果数,最大设置为 20。
83904-
* @param {boolean} [options.pageNum=1] - 分页页码,默认 1 代表第一页。
83902+
* @param {number} [options.pageSize=10] - 地址匹配查询返回记录结果数,最大设置为 20。
83903+
* @param {number} [options.pageNum=1] - 地址匹配查询分页页码,默认 1 代表第一页。
83904+
* @param {number} [options.perPageDataNum=8] - 每页显示个数,最大值为 8。
8390583905
* @param {string} [options.position='topright'] - 微件在地图中显示的位置,包括:'topleft','topright','bottomleft' 和 'bottomright',继承自 leaflet control。
8390683906
* @param {function} [options.style] - 设置图层点线面默认样式,点样式返回 maker 或者 circleMaker;线和面返回 L.path 样式。
8390783907
* @param {function} [options.onEachFeature] - 在创建和设置样式后,将为每个创建的要素调用一次的函数。用于将事件和弹出窗口附加到要素。默认情况下,对新创建的图层不执行任何操作。
@@ -83919,14 +83919,16 @@ var SearchView = WidgetsViewBase.extend({
8391983919
},
8392083920
isGeoCoding: true,
8392183921
pageSize: 10,
83922-
pageNum: 1
83922+
pageNum: 1,
83923+
perPageDataNum: 8
8392383924
},
8392483925

8392583926
initialize(options) {
8392683927
WidgetsViewBase.prototype.initialize.apply(this, [options]);
8392783928
//当前选中查询的图层名:
8392883929
this.currentSearchLayerName = "";
8392983930
this.isSearchLayer = false;
83931+
this.perPageDataNum = this.options.perPageDataNum;
8393083932
},
8393183933

8393283934
/*------以下是一些接口-----*/
@@ -84418,7 +84420,7 @@ var SearchView = WidgetsViewBase.extend({
8441884420
_prepareResultData(data) {
8441984421
this.currentResult = data;
8442084422
//向下取舍,这只页码
84421-
let pageCounts = Math.ceil(data.length / 8);
84423+
let pageCounts = Math.ceil(data.length / this.perPageDataNum);
8442284424
this._resultDomObj.setPageLink(pageCounts);
8442384425
//初始结果页面内容:
8442484426
this._createResultListByPageNum(1, data);
@@ -84443,17 +84445,17 @@ var SearchView = WidgetsViewBase.extend({
8444384445
_createResultListByPageNum(page, data) {
8444484446
let start = 0,
8444584447
end;
84446-
if (page === 1 && data.length < 8) {
84448+
if (page === 1 && data.length < this.perPageDataNum) {
8444784449
//data数据不满8个时:
8444884450
end = data.length - 1;
84449-
} else if (page * 8 > data.length) {
84451+
} else if (page * this.perPageDataNum > data.length) {
8445084452
//最后一页且数据不满8个时
84451-
start = 8 * (page - 1);
84453+
start = this.perPageDataNum * (page - 1);
8445284454
end = data.length - 1
8445384455
} else {
8445484456
//中间页面的情况
84455-
start = 8 * (page - 1);
84456-
end = page * 8 - 1
84457+
start = this.perPageDataNum * (page - 1);
84458+
end = page * this.perPageDataNum - 1
8445784459
}
8445884460
const content = document.createElement("div");
8445984461
for (let i = start; i <= end; i++) {
@@ -84556,8 +84558,8 @@ var SearchView = WidgetsViewBase.extend({
8455684558
for (let i = 0; i < this.searchLayersData.length; i++) {
8455784559
let item = this.searchLayersData[i]
8455884560
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+
dataIndex = i % this.perPageDataNum;
84562+
page = parseInt(i / this.perPageDataNum) + 1;
8456184563
break;
8456284564
}
8456384565
}

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

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

dist/leaflet/iclient9-leaflet.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66200,13 +66200,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
6620066200
* @category Widgets Search
6620166201
* @version 9.1.1
6620266202
* @param {Object} options - 可选参数。
66203-
* @param {string} [options.addressUrl] - 配置地址匹配服务。
6620466203
* @param {Object|Array.<string>} [options.cityConfig] - 城市地址匹配配置,默认为全国城市,与 options.cityGeoCodingConfig 支持匹配的服务对应;
6620566204
* 配置两种格式:{key1:{A:[],B:[]}, key2:{C:[],D:[]}} 或 ["成都市","北京市"],用户可根据自己的项目需求进行配置
6620666205
* @param {Object} [options.cityGeoCodingConfig] - 城市地址匹配服务配置,包括:{addressUrl:"",key:""} 默认为 online 地址匹配服务,与 options.cityConfig 对应
6620766206
* @param {boolean} [options.isGeoCoding=true] - 是否支持城市地址匹配功能。
66208-
* @param {boolean} [options.pageSize=10] - 返回记录结果数,最大设置为 20。
66209-
* @param {boolean} [options.pageNum=1] - 分页页码,默认 1 代表第一页。
66207+
* @param {number} [options.pageSize=10] - 地址匹配查询返回记录结果数,最大设置为 20。
66208+
* @param {number} [options.pageNum=1] - 地址匹配查询分页页码,默认 1 代表第一页。
66209+
* @param {number} [options.perPageDataNum=8] - 每页显示个数,最大值为 8。
6621066210
* @param {string} [options.position='topright'] - 微件在地图中显示的位置,包括:'topleft','topright','bottomleft' 和 'bottomright',继承自 leaflet control。
6621166211
* @param {function} [options.style] - 设置图层点线面默认样式,点样式返回 maker 或者 circleMaker;线和面返回 L.path 样式。
6621266212
* @param {function} [options.onEachFeature] - 在创建和设置样式后,将为每个创建的要素调用一次的函数。用于将事件和弹出窗口附加到要素。默认情况下,对新创建的图层不执行任何操作。
@@ -66224,14 +66224,16 @@ var SearchView = exports.SearchView = _WidgetsViewBase.WidgetsViewBase.extend({
6622466224
},
6622566225
isGeoCoding: true,
6622666226
pageSize: 10,
66227-
pageNum: 1
66227+
pageNum: 1,
66228+
perPageDataNum: 8
6622866229
},
6622966230

6623066231
initialize: function initialize(options) {
6623166232
_WidgetsViewBase.WidgetsViewBase.prototype.initialize.apply(this, [options]);
6623266233
//当前选中查询的图层名:
6623366234
this.currentSearchLayerName = "";
6623466235
this.isSearchLayer = false;
66236+
this.perPageDataNum = this.options.perPageDataNum;
6623566237
},
6623666238

6623766239

@@ -66732,7 +66734,7 @@ var SearchView = exports.SearchView = _WidgetsViewBase.WidgetsViewBase.extend({
6673266734
_prepareResultData: function _prepareResultData(data) {
6673366735
this.currentResult = data;
6673466736
//向下取舍,这只页码
66735-
var pageCounts = Math.ceil(data.length / 8);
66737+
var pageCounts = Math.ceil(data.length / this.perPageDataNum);
6673666738
this._resultDomObj.setPageLink(pageCounts);
6673766739
//初始结果页面内容:
6673866740
this._createResultListByPageNum(1, data);
@@ -66758,17 +66760,17 @@ var SearchView = exports.SearchView = _WidgetsViewBase.WidgetsViewBase.extend({
6675866760
_createResultListByPageNum: function _createResultListByPageNum(page, data) {
6675966761
var start = 0,
6676066762
end = void 0;
66761-
if (page === 1 && data.length < 8) {
66763+
if (page === 1 && data.length < this.perPageDataNum) {
6676266764
//data数据不满8个时:
6676366765
end = data.length - 1;
66764-
} else if (page * 8 > data.length) {
66766+
} else if (page * this.perPageDataNum > data.length) {
6676566767
//最后一页且数据不满8个时
66766-
start = 8 * (page - 1);
66768+
start = this.perPageDataNum * (page - 1);
6676766769
end = data.length - 1;
6676866770
} else {
6676966771
//中间页面的情况
66770-
start = 8 * (page - 1);
66771-
end = page * 8 - 1;
66772+
start = this.perPageDataNum * (page - 1);
66773+
end = page * this.perPageDataNum - 1;
6677266774
}
6677366775
var content = document.createElement("div");
6677466776
for (var i = start; i <= end; i++) {
@@ -66879,8 +66881,8 @@ var SearchView = exports.SearchView = _WidgetsViewBase.WidgetsViewBase.extend({
6687966881
for (var i = 0; i < _this4.searchLayersData.length; i++) {
6688066882
var item = _this4.searchLayersData[i];
6688166883
if (item.properties && item.properties.name === feature.properties.name || item.filterAttribute && item.filterAttribute.filterAttributeName + ": " + item.filterAttribute.filterAttributeValue === layer.filterAttribute.filterAttributeName + ": " + layer.filterAttribute.filterAttributeValue) {
66882-
dataIndex = i % 8;
66883-
page = parseInt(i / 8) + 1;
66884+
dataIndex = i % _this4.perPageDataNum;
66885+
page = parseInt(i / _this4.perPageDataNum) + 1;
6688466886
break;
6688566887
}
6688666888
}

dist/leaflet/iclient9-leaflet.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/leaflet/widgets_Search.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
L.supermap.tiledMapLayer(url).addTo(map);
3838
//添加微件:
3939
var poiSearch = L.supermap.widgets.search({
40-
isGeoCoding: !window.isLocal
40+
isGeoCoding: !window.isLocal,
41+
perPageDataNum: 8 // 每页显示数据个数
4142
//设置结果图层样式:
4243
/*style: (feature, latLng) => {
4344
if (latLng /!*&& feature instanceof L.latLng || feature.geometry.type.toLowerCase() === "point"*!/) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"elasticsearch": "13.0.1",
117117
"fetch-ie8": "1.5.0",
118118
"fetch-jsonp": "1.0.6",
119-
"jsonsql": "^0.2.5",
119+
"jsonsql": "0.2.5",
120120
"leaflet": "1.3.1",
121121
"lodash.topairs": "4.3.0",
122122
"mapbox-gl": "0.45.0",
@@ -126,6 +126,6 @@
126126
"proj4": "2.3.15",
127127
"promise-polyfill": "6.0.2",
128128
"three": "0.92.0",
129-
"xlsx": "^0.12.13"
129+
"xlsx": "0.12.13"
130130
}
131131
}

src/leaflet/widgets/search/SearchView.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ import {
2727
* @category Widgets Search
2828
* @version 9.1.1
2929
* @param {Object} options - 可选参数。
30-
* @param {string} [options.addressUrl] - 配置地址匹配服务。
3130
* @param {Object|Array.<string>} [options.cityConfig] - 城市地址匹配配置,默认为全国城市,与 options.cityGeoCodingConfig 支持匹配的服务对应;
3231
* 配置两种格式:{key1:{A:[],B:[]}, key2:{C:[],D:[]}} 或 ["成都市","北京市"],用户可根据自己的项目需求进行配置
3332
* @param {Object} [options.cityGeoCodingConfig] - 城市地址匹配服务配置,包括:{addressUrl:"",key:""} 默认为 online 地址匹配服务,与 options.cityConfig 对应
3433
* @param {boolean} [options.isGeoCoding=true] - 是否支持城市地址匹配功能。
35-
* @param {boolean} [options.pageSize=10] - 返回记录结果数,最大设置为 20。
36-
* @param {boolean} [options.pageNum=1] - 分页页码,默认 1 代表第一页。
34+
* @param {number} [options.pageSize=10] - 地址匹配查询返回记录结果数,最大设置为 20。
35+
* @param {number} [options.pageNum=1] - 地址匹配查询分页页码,默认 1 代表第一页。
36+
* @param {number} [options.perPageDataNum=8] - 每页显示个数,最大值为 8。
3737
* @param {string} [options.position='topright'] - 微件在地图中显示的位置,包括:'topleft','topright','bottomleft' 和 'bottomright',继承自 leaflet control。
3838
* @param {function} [options.style] - 设置图层点线面默认样式,点样式返回 maker 或者 circleMaker;线和面返回 L.path 样式。
3939
* @param {function} [options.onEachFeature] - 在创建和设置样式后,将为每个创建的要素调用一次的函数。用于将事件和弹出窗口附加到要素。默认情况下,对新创建的图层不执行任何操作。
@@ -51,14 +51,16 @@ export var SearchView = WidgetsViewBase.extend({
5151
},
5252
isGeoCoding: true,
5353
pageSize: 10,
54-
pageNum: 1
54+
pageNum: 1,
55+
perPageDataNum: 8
5556
},
5657

5758
initialize(options) {
5859
WidgetsViewBase.prototype.initialize.apply(this, [options]);
5960
//当前选中查询的图层名:
6061
this.currentSearchLayerName = "";
6162
this.isSearchLayer = false;
63+
this.perPageDataNum = this.options.perPageDataNum;
6264
},
6365

6466
/*------以下是一些接口-----*/
@@ -550,7 +552,7 @@ export var SearchView = WidgetsViewBase.extend({
550552
_prepareResultData(data) {
551553
this.currentResult = data;
552554
//向下取舍,这只页码
553-
let pageCounts = Math.ceil(data.length / 8);
555+
let pageCounts = Math.ceil(data.length / this.perPageDataNum);
554556
this._resultDomObj.setPageLink(pageCounts);
555557
//初始结果页面内容:
556558
this._createResultListByPageNum(1, data);
@@ -575,17 +577,17 @@ export var SearchView = WidgetsViewBase.extend({
575577
_createResultListByPageNum(page, data) {
576578
let start = 0,
577579
end;
578-
if (page === 1 && data.length < 8) {
580+
if (page === 1 && data.length < this.perPageDataNum) {
579581
//data数据不满8个时:
580582
end = data.length - 1;
581-
} else if (page * 8 > data.length) {
583+
} else if (page * this.perPageDataNum > data.length) {
582584
//最后一页且数据不满8个时
583-
start = 8 * (page - 1);
585+
start = this.perPageDataNum * (page - 1);
584586
end = data.length - 1
585587
} else {
586588
//中间页面的情况
587-
start = 8 * (page - 1);
588-
end = page * 8 - 1
589+
start = this.perPageDataNum * (page - 1);
590+
end = page * this.perPageDataNum - 1
589591
}
590592
const content = document.createElement("div");
591593
for (let i = start; i <= end; i++) {
@@ -688,8 +690,8 @@ export var SearchView = WidgetsViewBase.extend({
688690
for (let i = 0; i < this.searchLayersData.length; i++) {
689691
let item = this.searchLayersData[i]
690692
if ((item.properties && (item.properties.name === feature.properties.name)) || (item.filterAttribute && (item.filterAttribute.filterAttributeName + ": " + item.filterAttribute.filterAttributeValue) === (layer.filterAttribute.filterAttributeName + ": " + layer.filterAttribute.filterAttributeValue))) {
691-
dataIndex = i % 8;
692-
page = parseInt(i / 8) + 1;
693+
dataIndex = i % this.perPageDataNum;
694+
page = parseInt(i / this.perPageDataNum) + 1;
693695
break;
694696
}
695697
}

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