MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / _createXYZLayer

Method _createXYZLayer

src/common/mapping/WebMapV2.js:773–810  ·  view source on GitHub ↗
(layerInfo, url, addedCallback)

Source from the content-addressed store, hash-verified

771 }
772
773 _createXYZLayer(layerInfo, url, addedCallback) {
774 let urlArr = [];
775
776 if (layerInfo.layerType === 'OSM') {
777 const res = url.match(/\w\-\w/g)[0];
778 const start = res[0];
779 const end = res[2];
780 let alphabet = '';
781 for (let i = 97; i < 123; i++) {
782 alphabet += String.fromCharCode(i);
783 }
784 const alphabetArr = alphabet.split('');
785
786 const startIndex = alphabetArr.indexOf(start);
787 const endIndex = alphabetArr.indexOf(end);
788
789 const res3 = alphabetArr.slice(startIndex, endIndex + 1);
790
791 for (let i = 0; i < res3.length; i++) {
792 const replaceRes = url.replace(/{\w\-\w}/g, res3[i]);
793 urlArr.push(replaceRes);
794 }
795 } else if (layerInfo.layerType === 'GOOGLE_CN') {
796 const res = url.match(/\d\-\d/g)[0];
797 const start = parseInt(res[0]);
798 const end = parseInt(res[2]);
799
800 for (let i = start; i <= end; i++) {
801 const replaceRes = url.replace(/{\d\-\d}/g, i.toString());
802 urlArr.push(replaceRes);
803 }
804 } else {
805 urlArr = [url];
806 }
807 const layerId = layerInfo.layerID || layerInfo.name;
808 this._addBaselayer({ url: urlArr, layerID: layerId, visibility: layerInfo.visible, bounds: INTERNET_MAP_BOUNDS[layerInfo.layerType] || [-180, -90, 180, 90] });
809 addedCallback && addedCallback();
810 }
811
812 _createZXYLayer(layerInfo, addedCallback) {
813 const { url, subdomains, layerID, name, visible, tileSize, resolutions, origin, minZoom: minzoom, maxZoom: maxzoom, mapBounds } = layerInfo;

Callers 1

_initBaseLayerMethod · 0.95

Calls 5

_addBaselayerMethod · 0.95
matchMethod · 0.80
indexOfMethod · 0.80
pushMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected