(layerInfo, url, addedCallback)
| 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; |
no test coverage detected