Skip to content

Commit f99b3f0

Browse files
Merge branch 'v11.2.0' of https://github.com/SuperMap/iClient-JavaScript into v11.2.0
2 parents 277a86b + b179eb8 commit f99b3f0

File tree

23 files changed

+778
-54
lines changed

23 files changed

+778
-54
lines changed

dist/classic/include-classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
}
158158

159159
load({
160-
libsurl: '../../libs',
160+
libsurl: 'https://iclient.supermap.io/web/libs',
161161
disturl: '../../dist'
162162
});
163163
window.isLocal = false;

dist/leaflet/include-leaflet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
}
178178

179179
load({
180-
libsurl: '../../libs',
180+
libsurl: 'https://iclient.supermap.io/web/libs',
181181
disturl: '../../dist'
182182
});
183183
window.isLocal = false;

dist/mapboxgl/include-mapboxgl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
}
220220

221221
load({
222-
libsurl: '../../libs',
222+
libsurl: 'https://iclient.supermap.io/web/libs',
223223
disturl: '../../dist'
224224
});
225225
window.isLocal = false;

dist/maplibregl/include-maplibregl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
}
198198

199199
load({
200-
libsurl: '../../libs',
200+
libsurl: 'https://iclient.supermap.io/web/libs',
201201
disturl: '../../dist'
202202
});
203203
window.isLocal = false;

dist/ol/include-ol.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
inputScript(libsurl + '/openlayers/ol3-echarts/1.3.6/ol3Echarts.min.js');
9090
}
9191
if (inArray(includes, 'ol-mapbox-style')) {
92-
inputScript(libsurl + '/openlayers/plugins/ol-mapbox-style/2.11.2-5/olms.js');
92+
inputScript(libsurl + '/openlayers/plugins/ol-mapbox-style/2.11.2-6/olms.js');
9393
}
9494
if (inArray(includes, 'deck')) {
9595
inputScript(libsurl + '/deck.gl/5.1.3/deck.gl.min.js');
@@ -144,7 +144,7 @@
144144
}
145145

146146
load({
147-
libsurl: '../../libs',
147+
libsurl: 'https://iclient.supermap.io/web/libs',
148148
disturl: '../../dist'
149149
});
150150
window.isLocal = false;

dist/openlayers/include-openlayers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
inputScript(libsurl + '/openlayers/ol3-echarts/1.3.6/ol3Echarts.min.js');
9090
}
9191
if (inArray(includes, 'ol-mapbox-style')) {
92-
inputScript(libsurl + '/openlayers/plugins/ol-mapbox-style/2.11.2-5/olms.js');
92+
inputScript(libsurl + '/openlayers/plugins/ol-mapbox-style/2.11.2-6/olms.js');
9393
}
9494
if (inArray(includes, 'deck')) {
9595
inputScript(libsurl + '/deck.gl/5.1.3/deck.gl.min.js');
@@ -138,7 +138,7 @@
138138
}
139139

140140
load({
141-
libsurl: '../../libs',
141+
libsurl: 'https://iclient.supermap.io/web/libs',
142142
disturl: '../../dist'
143143
});
144144
window.isLocal = false;

examples/component/components_attributes_vue.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
width: 100%;
2020
height: 100%;
2121
}
22+
.sm-component-table-fixed {
23+
width: 100% !important;
24+
}
2225
</style>
2326
</head>
2427

@@ -71,7 +74,7 @@
7174
],
7275
table: {
7376
pagination: {
74-
pageSize: 10
77+
pageSize: 6
7578
}
7679
}
7780
};

examples/leaflet/01_chartService.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ <h5 class='panel-title text-center'>
486486
function clickHandler(event) {
487487
var coordinate = event.latlng;
488488
var pixelCoor = event.layerPoint;
489-
var b1 = map.containerPointToLatLng([pixelCoor.x-15,pixelCoor.y+15]);
490-
var b2 = map.containerPointToLatLng([pixelCoor.x+15,pixelCoor.y-15]);
489+
var b1 = map.layerPointToLatLng([pixelCoor.x-15,pixelCoor.y+15]);
490+
var b2 = map.layerPointToLatLng([pixelCoor.x+15,pixelCoor.y-15]);
491491
// 添加点要素
492492
pointResultLayer && map.removeLayer(pointResultLayer);
493493
pointResultLayer = L.circleMarker(coordinate,{radius:5});

src/mapboxgl/mapping/InitMap.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import mapboxgl from 'mapbox-gl';
22
import { MapService } from '../services/MapService';
33
import { FetchRequest } from '@supermapgis/iclient-common/util/FetchRequest';
44
import { InitMapServiceBase, isPlaneProjection, getZoom, getTileset, getTileFormat } from '@supermapgis/iclient-common/iServer/InitMapServiceBase';
5+
import { Util } from '@supermapgis/iclient-common/commontypes/Util';
56
import proj4 from 'proj4';
67

78
/**
@@ -137,7 +138,7 @@ async function getVectorTileCRSExtent(vectorStyleUrl, restMapUrl) {
137138
if (vectorStyleData.metadata && vectorStyleData.metadata.indexbounds) {
138139
return { extent: vectorStyleData.metadata.indexbounds };
139140
}
140-
const vectorExtentDataRes = await FetchRequest.get(`${restMapUrl}/prjCoordSys/projection/extent.json`);
141+
const vectorExtentDataRes = await FetchRequest.get(Util.urlPathAppend(restMapUrl, 'prjCoordSys/projection/extent.json'));
141142
const vectorExtentData = await vectorExtentDataRes.json();
142143
return { extent: vectorExtentData, center: vectorStyleData.center };
143144
} catch (error) {
@@ -176,7 +177,7 @@ async function createMapOptions(url, resetServiceInfo, options) {
176177
let extent = bounds;
177178
let tileUrl =
178179
sourceType === 'vector-tile'
179-
? url + '/tileFeature/vectorstyles.json?type=MapBox_GL&styleonly=true&tileURLTemplate=ZXY'
180+
? Util.urlAppend(Util.urlPathAppend(url, 'tileFeature/vectorstyles.json'), 'type=MapBox_GL&styleonly=true&tileURLTemplate=ZXY')
180181
: url;
181182
let nonEnhanceExtraInfo = {};
182183
let enhanceExtraInfo = {};
@@ -228,7 +229,7 @@ async function createMapOptions(url, resetServiceInfo, options) {
228229
const tileSize = 256;
229230
nonEnhanceExtraInfo.tileSize = tileSize;
230231
const transparent = mapOptions.transparent !== false;
231-
tileUrl += `/zxyTileImage.png?z={z}&x={x}&y={y}&width=${tileSize}&height=${tileSize}&transparent=${transparent}`;
232+
tileUrl = Util.urlAppend(Util.urlPathAppend(tileUrl, 'zxyTileImage.png'), `z={z}&x={x}&y={y}&width=${tileSize}&height=${tileSize}&transparent=${transparent}`);
232233
}
233234
}
234235
if (zoom === undefined) {

src/mapboxgl/mapping/utils/L7LayerUtil.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -638,12 +638,14 @@ function vectorSourceToL7Source(source, sourceLayer, options) {
638638
sourceLayer
639639
}
640640
};
641-
if (isIportalProxyServiceUrl(result.data, options)) {
642-
Object.assign(result.parser, {
643-
requestParameters: {
644-
credentials: 'include'
645-
}
646-
});
641+
const requestParameters = options.transformRequest(result.data, 'Tile');
642+
if (requestParameters) {
643+
if (requestParameters.credentials) {
644+
result.parser.requestParameters = { credentials: requestParameters.credentials };
645+
}
646+
if (requestParameters.headers) {
647+
result.parser.requestParameters = { ...result.parser.requestParameters, headers: requestParameters.headers };
648+
}
647649
}
648650
return result;
649651
}

src/mapboxgl/mapping/webmap/v2/WebMap.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ export class WebMap extends mapboxgl.Evented {
215215
case 'SUPERMAP_REST':
216216
this._createDynamicTiledLayer(layerInfo);
217217
break;
218+
case 'ZXY_TILE':
219+
this._createZXYLayer(layerInfo);
220+
break;
218221
case 'CLOUD':
219222
case 'CLOUD_BLACK':
220223
case 'OSM':
@@ -438,6 +441,13 @@ export class WebMap extends mapboxgl.Evented {
438441
this._addBaselayer(urlArr, 'XYZ-layers-' + layerInfo.name);
439442
}
440443

444+
_createZXYLayer(layerInfo) {
445+
const { url, subdomains, layerID, name, visible } = layerInfo;
446+
const urls = (subdomains && subdomains.length) ? subdomains.map(item => url.replace('{s}', item)) : [url];
447+
const layerId = layerID || name;
448+
this._addBaselayer(urls, layerId, undefined, undefined, '', visible);
449+
}
450+
441451
/**
442452
* @private
443453
* @function WebMap.prototype._createDynamicTiledLayer
@@ -630,6 +640,7 @@ export class WebMap extends mapboxgl.Evented {
630640
this.fire('getlayersfailed', { error: error, map: this.map });
631641
});
632642
} else if (
643+
layer.layerType === 'ZXY_TILE' ||
633644
layer.layerType === 'SUPERMAP_REST' ||
634645
layer.layerType === 'TILE' ||
635646
layer.layerType === 'WMS' ||
@@ -1808,7 +1819,7 @@ export class WebMap extends mapboxgl.Evented {
18081819
}
18091820
}
18101821

1811-
_addBaselayer(url, layerID, minzoom = 0, maxzoom = 22, isIserver) {
1822+
_addBaselayer(url, layerID, minzoom = 0, maxzoom = 22, isIserver, visible = true) {
18121823
this.map.addLayer({
18131824
id: layerID,
18141825
type: 'raster',
@@ -1819,6 +1830,7 @@ export class WebMap extends mapboxgl.Evented {
18191830
rasterSource: isIserver ? 'iserver' : '',
18201831
prjCoordSys: isIserver ? { epsgCode: this.baseProjection.split(':')[1] } : ''
18211832
},
1833+
layout: { visibility: visible ? 'visible' : 'none' },
18221834
minzoom: minzoom,
18231835
maxzoom: maxzoom
18241836
});

src/mapboxgl/mapping/webmap/v3/WebMap.js

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,8 @@ export class WebMap extends mapboxgl.Evented {
231231
const copyLayer = { ...matchLayer, ...layerInfo, id: copyLayerId };
232232
if (isL7Layer(copyLayer)) {
233233
const layers = [copyLayer];
234-
await addL7Layers({
235-
map: this.map,
236-
webMapInfo: { ...this._mapInfo, layers, sources: this._mapInfo.sources },
237-
l7Layers: layers,
238-
spriteDatas: this._spriteDatas,
239-
options: this.options
240-
});
234+
const params = this._getAddL7LayersParams(layers, this._mapInfo.sources, layers);
235+
await addL7Layers(params);
241236
return;
242237
}
243238
if (typeof copyLayer.source === 'object') {
@@ -327,18 +322,8 @@ export class WebMap extends mapboxgl.Evented {
327322
const fontFamilys = this._getLabelFontFamily();
328323
// 初始化 map
329324
const mapOptions = {
330-
transformRequest: (url, resourceType) => {
331-
const res = { url };
332-
if (
333-
resourceType === 'Tile' &&
334-
this.options.iportalServiceProxyUrl &&
335-
url.indexOf(this.options.iportalServiceProxyUrl) >= 0
336-
) {
337-
res.credentials = 'include';
338-
}
339-
return res;
340-
},
341325
...this.mapOptions,
326+
transformRequest: this._getTransformRequest(),
342327
container: this.options.target,
343328
crs: this._baseProjection,
344329
center,
@@ -364,6 +349,23 @@ export class WebMap extends mapboxgl.Evented {
364349
});
365350
}
366351

352+
_getTransformRequest() {
353+
if (this.mapOptions.transformRequest) {
354+
return this.mapOptions.transformRequest;
355+
}
356+
return (url, resourceType) => {
357+
if (resourceType === 'Tile') {
358+
const withCredentials = this.options.iportalServiceProxyUrl && url.indexOf(this.options.iportalServiceProxyUrl) >= 0;
359+
return {
360+
url: url,
361+
credentials: withCredentials ? 'include' : undefined,
362+
...(this.options.tileTransformRequest && this.options.tileTransformRequest(url))
363+
};
364+
}
365+
return { url };
366+
}
367+
}
368+
367369
_setBaseProjection() {
368370
let crs = this._mapInfo.crs;
369371
let baseProjection = crs;
@@ -480,16 +482,8 @@ export class WebMap extends mapboxgl.Evented {
480482
});
481483
const l7Layers = layers.filter((layer) => isL7Layer(layer));
482484
if (l7Layers.length > 0) {
483-
await addL7Layers({
484-
map: this.map,
485-
webMapInfo: { ...this._mapInfo, layers, sources },
486-
l7Layers,
487-
spriteDatas: this._spriteDatas,
488-
options: {
489-
...this.options,
490-
emitterEvent: this.fire.bind(this)
491-
}
492-
});
485+
const params = this._getAddL7LayersParams(layers, sources, l7Layers);
486+
await addL7Layers(params);
493487
}
494488
this._createLegendInfo();
495489
this._sendMapToUser();
@@ -499,6 +493,20 @@ export class WebMap extends mapboxgl.Evented {
499493
}
500494
}
501495

496+
_getAddL7LayersParams(layers, sources, l7Layers) {
497+
return {
498+
map: this.map,
499+
webMapInfo: { ...this._mapInfo, layers, sources },
500+
l7Layers,
501+
spriteDatas: this._spriteDatas,
502+
options: {
503+
...this.options,
504+
emitterEvent: this.fire.bind(this),
505+
transformRequest: this._getTransformRequest()
506+
}
507+
}
508+
}
509+
502510
/**
503511
* @private
504512
* @function WebMap.prototype._setUniqueId

src/maplibregl/mapping/InitMap.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import maplibregl from 'maplibre-gl';
22
import { FetchRequest } from '@supermapgis/iclient-common/util/FetchRequest';
33
import { MapService } from '../services/MapService';
44
import { InitMapServiceBase, isPlaneProjection, getZoom, getTileset, getTileFormat } from '@supermapgis/iclient-common/iServer/InitMapServiceBase';
5+
import { Util } from '@supermapgis/iclient-common/commontypes/Util';
56
import proj4 from 'proj4';
67
/**
78
* @function initMap
@@ -169,7 +170,7 @@ async function createMapOptions(url, resetServiceInfo, options) {
169170
let extent = bounds;
170171
let tileUrl =
171172
sourceType === 'vector-tile'
172-
? url + '/tileFeature/vectorstyles.json?type=MapBox_GL&styleonly=true&tileURLTemplate=ZXY'
173+
? Util.urlAppend(Util.urlPathAppend(url, 'tileFeature/vectorstyles.json'), 'type=MapBox_GL&styleonly=true&tileURLTemplate=ZXY')
173174
: url;
174175
let nonEnhanceExtraInfo = {};
175176
let enhanceExtraInfo = {};
@@ -221,7 +222,7 @@ async function createMapOptions(url, resetServiceInfo, options) {
221222
const tileSize = 256;
222223
nonEnhanceExtraInfo.tileSize = tileSize;
223224
const transparent = mapOptions.transparent !== false;
224-
tileUrl += `/zxyTileImage.png?z={z}&x={x}&y={y}&width=${tileSize}&height=${tileSize}&transparent=${transparent}`;
225+
tileUrl = Util.urlAppend(Util.urlPathAppend(tileUrl, 'zxyTileImage.png'), `z={z}&x={x}&y={y}&width=${tileSize}&height=${tileSize}&transparent=${transparent}`);
225226
}
226227
}
227228
if (zoom === undefined) {

src/openlayers/mapping/WebMap.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,9 @@ export class WebMap extends Observable {
968968
case 'SUPERMAP_REST':
969969
source = that.createDynamicTiledSource(layerInfo, isBaseLayer);
970970
break;
971+
case 'ZXY_TILE':
972+
source = this.createXYZTileSource(layerInfo);
973+
break;
971974
case 'CLOUD':
972975
case 'CLOUD_BLACK':
973976
case 'OSM':
@@ -1173,6 +1176,24 @@ export class WebMap extends Observable {
11731176
break;
11741177
}
11751178
}
1179+
/**
1180+
* @private
1181+
* @function WebMap.prototype.createXYZTileSource
1182+
* @description 创建图层的XYZTilesource。
1183+
* @param {Object} layerInfo - 图层信息
1184+
* @returns {ol.source.XYZ} xyz的source
1185+
*/
1186+
createXYZTileSource(layerInfo) {
1187+
const { url, subdomains } = layerInfo;
1188+
const urls = (subdomains && subdomains.length) ? subdomains.map(item => url.replace('{s}', item)) : [url];
1189+
const tileGrid = TileSuperMapRest.createTileGrid([-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892]);
1190+
return new XYZ({
1191+
urls,
1192+
wrapX: false,
1193+
crossOrigin: 'anonymous',
1194+
tileGrid
1195+
});
1196+
}
11761197
/**
11771198
* @private
11781199
* @function WebMap.prototype.createDynamicTiledSource
@@ -2107,6 +2128,10 @@ export class WebMap extends Observable {
21072128
that.errorCallback && that.errorCallback(e, 'getFeatureFaild', that.map);
21082129
}
21092130
);
2131+
} else if (layer.layerType === 'ZXY_TILE') {
2132+
that.map.addLayer(that.createBaseLayer(layer, layerIndex));
2133+
that.layerAdded++;
2134+
that.sendMapToUser(len);
21102135
}
21112136
}
21122137
}

src/openlayers/overlay/vectortile/MapboxStyles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Text from 'ol/style/Text';
1818
* <div style="padding: 20px;border: 1px solid #eee;border-left-width: 5px;border-radius: 3px;border-left-color: #ce4844;">
1919
* <p style="color: #ce4844">Notice</p>
2020
* <p style="font-size: 13px">该功能依赖 <a href='https://github.com/boundlessgeo/ol-mapbox-style'>ol-mapbox-style</a> 插件,请确认引入该插件。</p>
21-
* <a src="https://iclient.supermap.io/web/libs/openlayers/plugins/ol-mapbox-style/2.11.2-5/olms.js">https://iclient.supermap.io/web/libs/openlayers/plugins/ol-mapbox-style/2.11.2-5/olms.js</a>
21+
* <a src="https://iclient.supermap.io/web/libs/openlayers/plugins/ol-mapbox-style/2.11.2-6/olms.js">https://iclient.supermap.io/web/libs/openlayers/plugins/ol-mapbox-style/2.11.2-6/olms.js</a>
2222
* </div>
2323
* @modulecategory Overlay
2424
* @category Visualization VectorTile

0 commit comments

Comments
 (0)