| | |
| | | * @param defBasemapName 初始化完成后,默认显示的图层 |
| | | */ |
| | | initBasemap = (mapConfig, isIntranet) => { |
| | | debugger |
| | | if(isIntranet) { |
| | | this._getToken(mapConfig); // 获取token,并按配置加载地图 |
| | | }else { |
| | | if(isIntranet) { // 内网 |
| | | this._getToken(mapConfig); // 获取token后,并按配置加载地图 |
| | | }else { // 外网 |
| | | this._createBasemapByConfig(mapConfig) |
| | | } |
| | | |
| | |
| | | * 获取所有的底图列表 |
| | | * @returns {null} 结构:[{名称, 图层引用}] |
| | | */ |
| | | getBasemapList = (map) => { |
| | | console.log(map) |
| | | return null |
| | | getBasemapList = () => { |
| | | return this.basemapList |
| | | } |
| | | |
| | | /** |
| | | * 通过名称获取底图对象 |
| | | * @param map 结构:[{名称, 图层引用}] |
| | | * @param name 名称 |
| | | * @param code 名称 |
| | | */ |
| | | getBasemap = (map, name) => { |
| | | console.log(map, name) |
| | | getBasemap = (map, code) => { |
| | | return this.basemapMap.get(code) |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param layer 待显示图层引用 |
| | | * @param isHideOthers 是否先关闭其他图层,默认是true |
| | | */ |
| | | showBasemap = (map, layer, isHideOthers) => { |
| | | console.log(map, layer, isHideOthers) |
| | | showBasemap = (map, code, isHideOthers = true) => { |
| | | let basemap = this.basemapMap.get(code) |
| | | if(isHideOthers) { |
| | | for(let i = 0, len = this.basemapList.length; i < len; ++i){ |
| | | map.removeLayer(this.basemapList[i]) |
| | | } |
| | | } |
| | | map.addLayer(basemap.layer) |
| | | map.addLayer(basemap.annotation) |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param map 地图对象 |
| | | * @param layer 待关闭图层引用 |
| | | */ |
| | | hideBasemap = (map, layer) => { |
| | | console.log(map, layer) |
| | | hideBasemap = (map, code) => { |
| | | let basemap = this.basemapMap.get(code) |
| | | map.removeLayer(basemap.layer) |
| | | map.removeLayer(basemap.annotation) |
| | | } |
| | | |
| | | // 公网创建地图部分 |
| | |
| | | let internetBasemaps = mapConfig.mapConfig.InternetBaseMaps |
| | | for(let i = 0, len = internetBasemaps.length; i < len; ++i) { |
| | | let basemapConfig = internetBasemaps[i] |
| | | let basemapLayer = this.L.tileLayer(basemapConfig.map.url, basemapConfig.map.options) |
| | | let basemapAnnotationLayer = this.L.tileLayer(basemapConfig.annotation.url, basemapConfig.annotation.options) |
| | | let basemapLayer = this.L.tileLayer(basemapConfig.map.url, basemapConfig.map.option) |
| | | let basemapAnnotationLayer = this.L.tileLayer(basemapConfig.annotation.url, basemapConfig.annotation.option) |
| | | |
| | | let basemap = { |
| | | code: basemapConfig.code, |
| | | name: basemapConfig.name, |
| | | conf: basemapConfig, |
| | | layer: basemapLayer, |
| | | annotation: basemapAnnotationLayer |
| | | } |
| | |
| | | let intranetBasemaps = mapConfig.mapConfig.IntranetBaseMaps |
| | | for(let i = 0, len = intranetBasemaps.length; i < len; ++i) { |
| | | let basemapConfig = intranetBasemaps[i] |
| | | let basemapLayer = this.L.tileLayer(basemapConfig.map.url, basemapConfig.map.options) |
| | | let basemapAnnotationLayer = this.L.tileLayer(basemapConfig.annotation.url, basemapConfig.annotation.options) |
| | | let basemapLayer = this.L.tileLayer(basemapConfig.map.url, basemapConfig.map.option) |
| | | let basemapAnnotationLayer = this.L.tileLayer(basemapConfig.annotation.url, basemapConfig.annotation.option) |
| | | |
| | | let basemap = { |
| | | code: basemapConfig.code, |
| | | name: basemapConfig.name, |
| | | conf: basemapConfig, |
| | | layer: basemapLayer, |
| | | annotation: basemapAnnotationLayer |
| | | } |