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

Method addMVTMapLayer

src/openlayers/mapping/WebMap.js:846–875  ·  view source on GitHub ↗

* @private * @function WebMap.prototype.addMVTMapLayer * @description 添加地图服务mapboxstyle图层 * @param {Object} mapInfo - 地图信息 * @param {Object} layerInfo - mapboxstyle图层信息

(mapInfo, layerInfo, zIndex)

Source from the content-addressed store, hash-verified

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

Callers 2

getMapInfoSuccessMethod · 0.80
addLayersMethod · 0.80

Calls 7

createMVTLayerMethod · 0.95
mapMethod · 0.80
getTileGridMethod · 0.80
getResolutionsMethod · 0.45
getSourceMethod · 0.45
addLayerMethod · 0.45

Tested by

no test coverage detected