MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / addBaseMap

Method addBaseMap

src/openlayers/mapping/WebMap.js:712–759  ·  view source on GitHub ↗

* @private * @function WebMap.prototype.addBaseMap * @description 添加底图 * @param {string} mapInfo - 请求地图的url

(mapInfo)

Source from the content-addressed store, hash-verified

710 * @param {string} mapInfo - 请求地图的url
711 */
712 async addBaseMap(mapInfo) {
713 let { baseLayer } = mapInfo,
714 layerType = baseLayer.layerType;
715 //底图,使用默认的配置,不用存储的
716 if (layerType !== 'TILE' && layerType !== 'WMS' && layerType !== 'WMTS') {
717 this.getInternetMapInfo(baseLayer);
718 } else if (layerType === 'WMTS') {
719 // 通过请求完善信息
720 await this.getWmtsInfo(baseLayer);
721 } else if (layerType === 'TILE') {
722 await this.getTileInfo(baseLayer);
723 } else if (layerType === 'WMS') {
724 await this.getWmsInfo(baseLayer);
725 }
726 baseLayer.projection = mapInfo.projection;
727 if (!baseLayer.extent) {
728 baseLayer.extent = [
729 mapInfo.extent.leftBottom.x,
730 mapInfo.extent.leftBottom.y,
731 mapInfo.extent.rightTop.x,
732 mapInfo.extent.rightTop.y
733 ];
734 }
735 this.createView(mapInfo);
736 let layer = this.createBaseLayer(baseLayer, 0, null, null, true);
737 //底图增加图层类型,DV分享需要用它来识别版权信息
738 layer.setProperties({
739 layerType: layerType
740 });
741 this.map.addLayer(layer);
742
743 if (this.mapParams) {
744 this.mapParams.extent = baseLayer.extent;
745 this.mapParams.projection = mapInfo.projection;
746 }
747 if (baseLayer.labelLayerVisible) {
748 //存在天地图路网
749 let labelLayer = new olLayer.Tile({
750 source: this.createTiandituSource(baseLayer.layerType, mapInfo.projection, true),
751 zIndex: baseLayer.zIndex || 1,
752 visible: baseLayer.visible
753 });
754 this.map.addLayer(labelLayer);
755 // 挂载带baseLayer上,便于删除
756 baseLayer.labelLayer = labelLayer;
757 }
758 this.limitScale(mapInfo, baseLayer);
759 }
760
761 validScale(scale) {
762 if (!scale) {

Callers 1

getMapInfoSuccessMethod · 0.80

Calls 9

getInternetMapInfoMethod · 0.95
getWmtsInfoMethod · 0.95
getTileInfoMethod · 0.95
getWmsInfoMethod · 0.95
createViewMethod · 0.95
createBaseLayerMethod · 0.95
createTiandituSourceMethod · 0.95
limitScaleMethod · 0.95
addLayerMethod · 0.45

Tested by

no test coverage detected