FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

【fix】当map maxzoom为24时 有些图层maxzoom会处理为25 超出24的最大限制,场景webmap3切换webmap2 · SuperMap/iClient-JavaScript@618e107 · GitHub

Commit 618e107

Browse files
committed
【fix】当map maxzoom为24时 有些图层maxzoom会处理为25 超出24的最大限制,场景webmap3切换webmap2
AI-GEN: 10% Claude
1 parent d2863d0 commit 618e107

2 files changed

Lines changed: 269 additions & 15 deletions

File tree

‎src/common/mapping/WebMapV2.js‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
557557
const { minScale, maxScale } = layer.visibleScale;
558558
const crs = this.map.getCRS();
559559
layer.minzoom = Math.max(this._transformScaleToZoom(minScale, crs, layer.tileSize), 0);
560-
layer.maxzoom = Math.min(this.map.getMaxZoom()+1, this._transformScaleToZoom(maxScale, crs, layer.tileSize) + 0.0000001);
560+
layer.maxzoom = Math.min(this.map.getMaxZoom()+1, this._transformScaleToZoom(maxScale, crs, layer.tileSize) + 0.0000001, 24);
561561
}
562562

563563
if (type === 'tile') {
@@ -1501,7 +1501,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
15011501
},
15021502
layout,
15031503
minzoom: minzoom || 0,
1504-
maxzoom: maxzoom || this.map.getMaxZoom() + 1
1504+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24)
15051505
},
15061506
layerInfo.layerID
15071507
);
@@ -1553,7 +1553,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
15531553
visibility: layerInfo.visible
15541554
},
15551555
minzoom: minzoom || 0,
1556-
maxzoom: maxzoom || this.map.getMaxZoom() + 1
1556+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24)
15571557
};
15581558
if (filter) {
15591559
layerOptions.filter = filter;
@@ -1608,7 +1608,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
16081608
'icon-rotate': iconRotateExpression || ((layerInfo.style.rotation || 0) * 180) / Math.PI
16091609
},
16101610
minzoom: minzoom || 0,
1611-
maxzoom: maxzoom || this.map.getMaxZoom() + 1
1611+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24)
16121612
};
16131613
if (filter) {
16141614
layerOptions.filter = filter;
@@ -1660,7 +1660,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
16601660
'icon-color': style.fillColor
16611661
},
16621662
minzoom: minzoom || 0,
1663-
maxzoom: maxzoom || this.map.getMaxZoom() + 1
1663+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24)
16641664
};
16651665
if (filter) {
16661666
layerOptions.filter = filter;
@@ -1964,7 +1964,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
19641964
visibility: visible
19651965
},
19661966
minzoom: minzoom || 0,
1967-
maxzoom: maxzoom || this.map.getMaxZoom() + 1
1967+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24)
19681968
};
19691969
if (filterExpression.length > 1) {
19701970
layerOptions.filter = filterExpression;
@@ -2082,7 +2082,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
20822082
'icon-rotate': symbolStyle.rotation || 0
20832083
},
20842084
minzoom: minzoom || 0,
2085-
maxzoom: maxzoom || this.map.getMaxZoom() + 1,
2085+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24),
20862086
filter: imagefilterExpression
20872087
},
20882088
layerID
@@ -2117,7 +2117,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
21172117
'icon-color': symbolStyle.fillColor
21182118
},
21192119
minzoom: minzoom || 0,
2120-
maxzoom: maxzoom || this.map.getMaxZoom() + 1,
2120+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24),
21212121
filter: svgfilterExpression
21222122
},
21232123
layerID
@@ -2288,7 +2288,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
22882288
paint: this._transformStyleToMapBoxGl(defaultStyle, geomType),
22892289
layout: {},
22902290
minzoom: minzoom || 0,
2291-
maxzoom: maxzoom || this.map.getMaxZoom() + 1
2291+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24)
22922292
},
22932293
markerLayerID
22942294
);
@@ -2306,7 +2306,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
23062306
visibility: layerInfo.visible
23072307
},
23082308
minzoom: minzoom || 0,
2309-
maxzoom: maxzoom || this.map.getMaxZoom() + 1
2309+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24)
23102310
},
23112311
markerLayerID
23122312
);
@@ -2410,7 +2410,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
24102410
visibility: layerInfo.visible
24112411
},
24122412
minzoom: minzoom || 0,
2413-
maxzoom: maxzoom || this.map.getMaxZoom() + 1
2413+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24)
24142414
});
24152415
if (addToMap) {
24162416
this._addLayerSucceeded({ layerInfo, features });
@@ -2617,7 +2617,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
26172617
paint: layerStyle.style,
26182618
layout: layerStyle.layout || {},
26192619
minzoom: minzoom || 0,
2620-
maxzoom: maxzoom || this.map.getMaxZoom() + 1
2620+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24)
26212621
};
26222622
if (filter) {
26232623
style.filter = filter;
@@ -2641,7 +2641,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
26412641
type: 'raster',
26422642
tiles: url,
26432643
minzoom: minzoom || 0,
2644-
maxzoom: maxzoom || this.map.getMaxZoom() + 1,
2644+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24),
26452645
tileSize: isIserver ? this.rasterTileSize : tileSize,
26462646
rasterSource: isIserver ? 'iserver' : '',
26472647
prjCoordSys:
@@ -2664,7 +2664,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
26642664
type: 'raster',
26652665
source: sourceId,
26662666
minzoom: minzoom || 0,
2667-
maxzoom: maxzoom || this.map.getMaxZoom() + 1,
2667+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24),
26682668
layout: {
26692669
visibility: this._getVisibility(visibility)
26702670
}
@@ -2847,7 +2847,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
28472847
visibility: layerInfo.visible ? 'visible' : 'none'
28482848
},
28492849
minzoom: minzoom || 0,
2850-
maxzoom: maxzoom || this.map.getMaxZoom() + 1
2850+
maxzoom: Math.min(maxzoom || this.map.getMaxZoom() + 1, 24)
28512851
});
28522852
this._addLayerSucceeded();
28532853
}

‎test/mapboxgl/mapping/WebMapV2Spec.js‎

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4675,4 +4675,258 @@ it('add rangeLayer last end === fieldValue', (done) => {
46754675
expect(map.addLocalIdeographFontFamily).toHaveBeenCalledWith('sans-serif,微软雅黑,supermapol-icons');
46764676
webMapV2.clean(false);
46774677
});
4678+
it('layermaxzoom <=24', (done) => {
4679+
const mapInfo = {
4680+
"maxScale": "1:144447.92746805",
4681+
"baseLayer": {
4682+
"layerType": "MAPBOXSTYLE",
4683+
"name": "Capital@World33font",
4684+
"dataSource": {
4685+
"type": "EXTERNAL",
4686+
"url": "http://localhost:8195/portalproxy/ad4c697aec15c20c/iserver/services/map-mvt-CapitalWorld33font/restjsr/v1/vectortile/maps/Capital%40World33font"
4687+
}
4688+
},
4689+
"projection": "EPSG:4326",
4690+
"minScale": "1:591658710.909131",
4691+
"title": "Capital@World33font",
4692+
"version": "2.3.0",
4693+
}
4694+
const layerInfo = {
4695+
layerType: 'RANGE',
4696+
visible: 'visible',
4697+
themeSetting: {
4698+
themeField: 'TAX',
4699+
customSettings: {},
4700+
segmentMethod: 'offset',
4701+
segmentCount: 6,
4702+
colors: ['#ffc6c4', '#f4a3a8', '#e38191', '#cc607d', '#ad466c', '#8b3058', '#672044']
4703+
},
4704+
name: 'DataSource:DEMARCACION_TERRITORIAL_Tax',
4705+
featureType: 'POLYGON',
4706+
style: {
4707+
strokeWidth: 1,
4708+
fillColor: '#8b3058',
4709+
fillOpacity: 0.9,
4710+
lineDash: 'solid',
4711+
strokeColor: '#ffffff',
4712+
type: 'POLYGON',
4713+
strokeOpacity: 1
4714+
},
4715+
projection: 'EPSG:4326',
4716+
enableFields: ['TAX'],
4717+
dataSource: {
4718+
type: 'REST_DATA',
4719+
url: 'http://test:8090/iserver/services/data-JSON_test/rest/data',
4720+
dataSourceName: 'DataSource:DEMARCACION_TERRITORIAL_Tax'
4721+
},
4722+
layerID: 'DataSource:DEMARCACION_TERRITORIAL_Tax'
4723+
};
4724+
const features = [
4725+
{
4726+
type: 'Feature',
4727+
properties: {
4728+
TAX: '2.0E18',
4729+
index: '0'
4730+
},
4731+
geometry: {
4732+
type: 'MultiPolygon'
4733+
},
4734+
id: 1
4735+
},
4736+
{
4737+
type: 'Feature',
4738+
properties: {
4739+
TAX: '2.00000000000098E12',
4740+
index: '1'
4741+
},
4742+
geometry: {
4743+
type: 'MultiPolygon'
4744+
},
4745+
id: 2
4746+
},
4747+
{
4748+
type: 'Feature',
4749+
properties: {
4750+
TAX: '2.000000000098E10',
4751+
index: '2'
4752+
},
4753+
geometry: {
4754+
type: 'MultiPolygon'
4755+
},
4756+
id: 3
4757+
},
4758+
{
4759+
type: 'Feature',
4760+
properties: {
4761+
TAX: '2.000000000098E10',
4762+
index: '3'
4763+
},
4764+
geometry: {
4765+
type: 'MultiPolygon'
4766+
},
4767+
id: 4
4768+
},
4769+
{
4770+
type: 'Feature',
4771+
properties: {
4772+
TAX: '2.000000000098E10',
4773+
index: '4'
4774+
},
4775+
geometry: {
4776+
type: 'MultiPolygon'
4777+
},
4778+
id: 5
4779+
},
4780+
{
4781+
type: 'Feature',
4782+
properties: {
4783+
TAX: '2.000000000098E10',
4784+
index: '5'
4785+
},
4786+
geometry: {
4787+
type: 'MultiPolygon'
4788+
},
4789+
id: 6
4790+
},
4791+
{
4792+
type: 'Feature',
4793+
properties: {
4794+
TAX: '2.000000000098E10',
4795+
index: '6'
4796+
},
4797+
geometry: {
4798+
type: 'MultiPolygon'
4799+
},
4800+
id: 7
4801+
},
4802+
{
4803+
type: 'Feature',
4804+
properties: {
4805+
TAX: '2.000000000098E10',
4806+
index: '7'
4807+
},
4808+
geometry: {
4809+
type: 'MultiPolygon'
4810+
},
4811+
id: 8
4812+
},
4813+
{
4814+
type: 'Feature',
4815+
properties: {
4816+
TAX: '2.000000000098E10',
4817+
index: '8'
4818+
},
4819+
geometry: {
4820+
type: 'MultiPolygon'
4821+
},
4822+
id: 9
4823+
},
4824+
{
4825+
type: 'Feature',
4826+
properties: {
4827+
TAX: '2.000000000098E10',
4828+
index: '9'
4829+
},
4830+
geometry: {
4831+
type: 'MultiPolygon'
4832+
},
4833+
id: 10
4834+
},
4835+
{
4836+
type: 'Feature',
4837+
properties: {
4838+
TAX: '2.000000000098E10',
4839+
index: '10'
4840+
},
4841+
geometry: {
4842+
type: 'MultiPolygon'
4843+
},
4844+
id: 11
4845+
},
4846+
{
4847+
type: 'Feature',
4848+
properties: {
4849+
TAX: '2.000000000098E10',
4850+
index: '11'
4851+
},
4852+
geometry: {
4853+
type: 'MultiPolygon'
4854+
},
4855+
id: 12
4856+
},
4857+
{
4858+
type: 'Feature',
4859+
properties: {
4860+
TAX: '2.000000000098E10',
4861+
index: '12'
4862+
},
4863+
geometry: {
4864+
type: 'MultiPolygon'
4865+
},
4866+
id: 13
4867+
},
4868+
{
4869+
type: 'Feature',
4870+
properties: {
4871+
TAX: '2.000000000098E10',
4872+
index: '13'
4873+
},
4874+
geometry: {
4875+
type: 'MultiPolygon'
4876+
},
4877+
id: 14
4878+
},
4879+
{
4880+
type: 'Feature',
4881+
properties: {
4882+
TAX: '2.000000000098E10',
4883+
index: '14'
4884+
},
4885+
geometry: {
4886+
type: 'MultiPolygon'
4887+
},
4888+
id: 15
4889+
},
4890+
{
4891+
type: 'Feature',
4892+
properties: {
4893+
TAX: '2.000000000098E10',
4894+
index: '15'
4895+
},
4896+
geometry: {
4897+
type: 'MultiPolygon'
4898+
},
4899+
id: 16
4900+
}
4901+
];
4902+
spyOn(FetchRequest, 'get').and.callFake((url) => {
4903+
if (url.indexOf('portal.json') > -1) {
4904+
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
4905+
}
4906+
if (url.indexOf('123/map.json') > -1) {
4907+
return Promise.resolve(
4908+
new Response(
4909+
JSON.stringify(mapInfo)
4910+
)
4911+
);
4912+
}
4913+
if (url.indexOf('/style.json')) {
4914+
return Promise.resolve(new Response(JSON.stringify(vectorTile_style)));
4915+
}
4916+
return Promise.resolve(new Response(JSON.stringify({})));
4917+
});
4918+
datavizWebmap = new WebMap('123', {
4919+
target: 'map',
4920+
serverUrl: 'http://fake/fakeiportal',
4921+
withCredentials: false
4922+
});
4923+
datavizWebmap.on('mapcreatesucceeded', ({ map }) => {
4924+
expect(map).not.toBeUndefined();
4925+
expect(map.getStyle().layers.length).toBe(1);
4926+
map.setMaxZoom(24);
4927+
datavizWebmap._handler._createVectorLayer(layerInfo,features);
4928+
expect(map.getStyle().layers[1].maxzoom).toBe(24);
4929+
done();
4930+
});
4931+
});
46784932
});

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL