* @private * @function WebMap.prototype.addMVTMapLayer * @description 添加地图服务mapboxstyle图层 * @param {Object} mapInfo - 地图信息 * @param {Object} layerInfo - mapboxstyle图层信息
(mapInfo, layerInfo, zIndex)
| 844 | * @param {Object} layerInfo - mapboxstyle图层信息 |
| 845 | */ |
| 846 | addMVTMapLayer(mapInfo, layerInfo, zIndex) { |
| 847 | layerInfo.zIndex = zIndex; |
| 848 | // 获取地图详细信息 |
| 849 | return this.getMapboxStyleLayerInfo(mapInfo, layerInfo) |
| 850 | .then((msLayerInfo) => { |
| 851 | // 创建图层 |
| 852 | return this.createMVTLayer(msLayerInfo).then((layer) => { |
| 853 | let layerID = Util.newGuid(8); |
| 854 | if (layerInfo.name) { |
| 855 | layer.setProperties({ |
| 856 | name: layerInfo.name, |
| 857 | layerID: layerID, |
| 858 | layerType: 'VECTOR_TILE' |
| 859 | }); |
| 860 | } |
| 861 | // 后续逻辑非需要visibleScales 否则修改很复杂 |
| 862 | layerInfo.visibleScales = layer.getSource().getTileGrid().getResolutions().map((res) => { |
| 863 | return Util.resolutionToScale(res, 96, layerInfo.coordUnit || 'm'); |
| 864 | }); |
| 865 | //否则没有ID,对不上号 |
| 866 | layerInfo.layer = layer; |
| 867 | layerInfo.layerID = layerID; |
| 868 | |
| 869 | this.map.addLayer(layer); |
| 870 | }); |
| 871 | }) |
| 872 | .catch(function (error) { |
| 873 | throw error; |
| 874 | }); |
| 875 | } |
| 876 | /** |
| 877 | * @private |
| 878 | * @function WebMap.prototype.createView |
no test coverage detected