Skip to content

Commit 4bb3043

Browse files
【fix】栅格查询限制查询范围,调整地图中心点与缩放级别 review by qiwei
1 parent a03a6b3 commit 4bb3043

File tree

10 files changed

+103
-18
lines changed

10 files changed

+103
-18
lines changed

examples/leaflet/02_getGridCellInfos.html

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
top: 0;
2828
right: 0;
2929
height: 100vh;
30-
width: 500px;
30+
width: 400px;
3131
padding: 20px;
3232
background: #fff;
3333
font-family: Avenir, Helvetica, Arial, sans-serif;
@@ -216,9 +216,8 @@ <h4 class="panel-title">
216216
map = L.map('map', {
217217
preferCanvas: true,
218218
crs: L.CRS.EPSG4326,
219-
center: { lon: 30, lat: 0 },
220-
maxZoom: 18,
221-
zoom: 2
219+
center: { lon: 120, lat: 28 },
220+
zoom: 5
222221
});
223222

224223
new L.supermap.TiledMapLayer(baseUrl, { noWrap: true }).addTo(map);
@@ -269,10 +268,31 @@ <h4 class="panel-title">
269268
appendTable(res);
270269
})
271270
}
271+
function getValuesCount(res) {
272+
var count = 0;
273+
if (!res.object.bounds) {
274+
count += 1;
275+
} else if (res.object.bounds && !Array.isArray(res.object.bounds)) {
276+
count += res.result.valuesCount;
277+
} else {
278+
var customResult = res.result.customResult;
279+
for(var i = 0 ; i < customResult.length ; i ++) {
280+
if (customResult[i].values) {
281+
count += customResult[i].valuesCount;
282+
} else {
283+
count += 1;
284+
}
285+
}
286+
}
287+
return count;
288+
}
272289
function appendTable(res) {
273290
if (!res) {
274291
return;
275292
}
293+
if ((res.error && res.error.code === 400) || getValuesCount(res) > 5000) {
294+
return widgets.alert.showAlert(resources.msg_outOfQueryRange, false);
295+
}
276296
// 展开table
277297
collapseTable();
278298
if (!res.object.bounds) {
-1.56 KB
Loading

examples/locales/en-US/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,7 @@ window.examplesResources = {
18771877
"msg_deleteFeatureFailed": 'Delete feature failed',
18781878
"msg_geographicPosition": "geographical position error! ",
18791879
"msg_gridQueryNote": "Note: Click the map at any position, the instance will start to grid query at this location, and the bottom left corner of the map will show the query results after the query is completed.",
1880+
"msg_outOfQueryRange": "Please narrow down the search scope。",
18801881
"msg_drawQueryBounds": "Please draw the query range!",
18811882
"msg_drawClipBounds": "Please draw the clip range!",
18821883
"msg_chooseColor": "Please choose color value",

examples/locales/zh-CN/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,7 @@ window.examplesResources = {
18291829
"msg_deleteFeatureFailed": '删除地物失败',
18301830
"msg_geographicPosition": "地理位置错误!",
18311831
"msg_gridQueryNote": "注:点击地图任意位置,案例以该位置进行栅格查询,查询完成后地图左下角会显示查询结果。",
1832+
"msg_outOfQueryRange": "请缩小查询范围。",
18321833
"msg_drawQueryBounds": "请绘制查询范围!",
18331834
"msg_drawClipBounds": "请绘制裁剪范围!",
18341835
"msg_chooseColor": "请选颜色值",

examples/mapboxgl/02_getGridCellInfos.html

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
top: 0;
2828
right: 0;
2929
height: 100vh;
30-
width: 500px;
30+
width: 400px;
3131
padding: 20px;
3232
background: #fff;
3333
font-family: Avenir, Helvetica, Arial, sans-serif;
@@ -236,8 +236,8 @@ <h4 class="panel-title">
236236
"source": "raster-tiles",
237237
}]
238238
},
239-
center: [30, 0],
240-
zoom: 2
239+
center: [116, 32],
240+
zoom: 4
241241
});
242242

243243
map.addControl(new mapboxgl.supermap.LogoControl({ link: "https://iclient.supermap.io" }), 'bottom-right');
@@ -252,7 +252,6 @@ <h4 class="panel-title">
252252
trash: true,
253253
}
254254
});
255-
console.log($($('.mapboxgl-ctrl').get(1)));
256255
$($('.mapboxgl-ctrl').get(1)).hide();
257256
map.addControl(Draw, 'top-left')
258257
function queryResult() {
@@ -300,10 +299,31 @@ <h4 class="panel-title">
300299
})
301300
}
302301
})
302+
function getValuesCount(res) {
303+
var count = 0;
304+
if (!res.object.bounds) {
305+
count += 1;
306+
} else if (res.object.bounds && !Array.isArray(res.object.bounds)) {
307+
count += res.result.valuesCount;
308+
} else {
309+
var customResult = res.result.customResult;
310+
for (var i = 0; i < customResult.length; i++) {
311+
if (customResult[i].values) {
312+
count += customResult[i].valuesCount;
313+
} else {
314+
count += 1;
315+
}
316+
}
317+
}
318+
return count;
319+
}
303320
function appendTable(res) {
304321
if (!res) {
305322
return;
306323
}
324+
if ((res.error && res.error.code === 400) || getValuesCount(res) > 5000) {
325+
return widgets.alert.showAlert(resources.msg_outOfQueryRange, false);
326+
}
307327
// 展开table
308328
collapseTable();
309329
if (!res.object.bounds) {
@@ -373,7 +393,7 @@ <h4 class="panel-title">
373393
table.appendChild(thead);
374394
table.appendChild(tbody);
375395

376-
var theadInfo = '<tr><th>'+ resources.text_index +'</th><th>'+ resources.text_row_index +'</th><th>'+ resources.text_column_index +'</th><th>'+ resources.text_color_number +'</th><th>'+ resources.text_color_rgba +'</th></tr>';
396+
var theadInfo = '<tr><th>' + resources.text_index + '</th><th>' + resources.text_row_index + '</th><th>' + resources.text_column_index + '</th><th>' + resources.text_color_number + '</th><th>' + resources.text_color_rgba + '</th></tr>';
377397
thead.append(theadInfo);
378398
thead.innerHTML = theadInfo;
379399
tbody.innerHTML = tbodyHtml;
-20.7 KB
Loading

examples/maplibregl/02_getGridCellInfos.html

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
top: 0;
5454
right: 0;
5555
height: 100vh;
56-
width: 500px;
56+
width: 400px;
5757
padding: 20px;
5858
background: #fff;
5959
font-family: Avenir, Helvetica, Arial, sans-serif;
@@ -262,8 +262,8 @@ <h4 class="panel-title">
262262
"source": "raster-tiles",
263263
}]
264264
},
265-
center: [30, 0],
266-
zoom: 2
265+
center: [116, 32],
266+
zoom: 4
267267
});
268268
//mapbox 绘制要素图形控件
269269
var Draw = new MapboxDraw({
@@ -323,10 +323,31 @@ <h4 class="panel-title">
323323
})
324324
}
325325
});
326+
function getValuesCount(res) {
327+
var count = 0;
328+
if (!res.object.bounds) {
329+
count += 1;
330+
} else if (res.object.bounds && !Array.isArray(res.object.bounds)) {
331+
count += res.result.valuesCount;
332+
} else {
333+
var customResult = res.result.customResult;
334+
for(var i = 0 ; i < customResult.length ; i ++) {
335+
if (customResult[i].values) {
336+
count += customResult[i].valuesCount;
337+
} else {
338+
count += 1;
339+
}
340+
}
341+
}
342+
return count;
343+
}
326344
function appendTable(res) {
327345
if (!res) {
328346
return;
329347
}
348+
if ((res.error && res.error.code === 400) || getValuesCount(res) > 5000) {
349+
return widgets.alert.showAlert(resources.msg_outOfQueryRange, false);
350+
}
330351
// 展开table
331352
collapseTable();
332353
if (!res.object.bounds) {
-21.6 KB
Loading

examples/openlayers/02_getGridCellInfos.html

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
top: 0;
3030
right: 0;
3131
height: 100vh;
32-
width: 500px;
32+
width: 400px;
3333
padding: 20px;
3434
background: #fff;
3535
font-family: Avenir, Helvetica, Arial, sans-serif;
@@ -221,7 +221,8 @@ <h4 class="panel-title">
221221
</div>
222222
<script type="text/javascript" include="bootstrap,jquery,widgets" src="../js/include-web.js"></script>
223223
<script type="text/javascript">
224-
var map, baseUrl = (window.isLocal ? window.server : "https://iserver.supermap.io") + "/iserver/services/map-world/rest/maps/世界地图_Day",
224+
var map,
225+
baseUrl = (window.isLocal ? window.server : "https://iserver.supermap.io") + "/iserver/services/map-world/rest/maps/世界地图_Day",
225226
url = (window.isLocal ? window.server : "https://iserver.supermap.io") + "/iserver/services/data-world/rest/data",
226227
draw,
227228
querylist = [],
@@ -230,8 +231,8 @@ <h4 class="panel-title">
230231
target: 'map',
231232
controls: ol.control.defaults({ attributionOptions: { collapsed: false } }).extend([new ol.supermap.control.Logo({ link: "https://iclient.supermap.io" })]),
232233
view: new ol.View({
233-
center: [30, 0],
234-
zoom: 3,
234+
center: [120, 28],
235+
zoom: 6,
235236
projection: 'EPSG:4326',
236237
multiWorld: true,
237238
})
@@ -274,10 +275,31 @@ <h4 class="panel-title">
274275
appendTable(res);
275276
})
276277
}
278+
function getValuesCount(res) {
279+
var count = 0;
280+
if (!res.object.bounds) {
281+
count += 1;
282+
} else if (res.object.bounds && !Array.isArray(res.object.bounds)) {
283+
count += res.result.valuesCount;
284+
} else {
285+
var customResult = res.result.customResult;
286+
for (var i = 0; i < customResult.length; i++) {
287+
if (customResult[i].values) {
288+
count += customResult[i].valuesCount;
289+
} else {
290+
count += 1;
291+
}
292+
}
293+
}
294+
return count;
295+
}
277296
function appendTable(res) {
278-
if (!res || res.error) {
297+
if (!res) {
279298
return;
280299
}
300+
if ((res.error && res.error.code === 400) || getValuesCount(res) > 5000) {
301+
return widgets.alert.showAlert(resources.msg_outOfQueryRange, false);
302+
}
281303
// 展开table
282304
collapseTable();
283305
if (!res.object.bounds) {
@@ -347,7 +369,7 @@ <h4 class="panel-title">
347369
table.appendChild(thead);
348370
table.appendChild(tbody);
349371

350-
var theadInfo = '<tr><th>'+ resources.text_index +'</th><th>'+ resources.text_row_index +'</th><th>'+ resources.text_column_index +'</th><th>'+ resources.text_color_number +'</th><th>'+ resources.text_color_rgba +'</th></tr>';
372+
var theadInfo = '<tr><th>' + resources.text_index + '</th><th>' + resources.text_row_index + '</th><th>' + resources.text_column_index + '</th><th>' + resources.text_color_number + '</th><th>' + resources.text_color_rgba + '</th></tr>';
351373
thead.append(theadInfo);
352374
thead.innerHTML = theadInfo;
353375
tbody.innerHTML = tbodyHtml;
5.52 KB
Loading

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