import * as layer from 'ol/layer' import * as source from 'ol/source' import HaituImg from './images/bg-ocean.png' import LutuImg from './images/bg-land.png' import WeixingImg from './images/bg-sky.png' import store from '@/store/index' const baseMapView = { center: [109.6915958479584, 19.111636735969318], projection: "EPSG:4326", zoom: 9 // extent: [120.8953306326286,31.3667480047968,121.37735577911297,31.692561298253832] } const initBaseLayer = (obj) => { const _layer = new layer.Tile({ source: new source.XYZ({ projection: "EPSG:4326", url: `/${store.state.app.apiProxy.EzServer6Api}/EzServer6/Maps/${obj.key}/EzMap?Service=getImage&Type=RGB&ZoomOffset=0&Col={x}&Row={y}&Zoom={z}&V=0.3`, }), visible: obj.visible, }) _layer.set('_maxZoom', obj.maxZoom) _layer.set('_minZoom', obj.minZoom) _layer.set('_easyMapOl_layerName', obj.name) _layer.set('_label', obj.label) _layer.set('_img', obj.img) return _layer } const initLocalhost = (obj) => { const _layer = new layer.Tile({ source: new source.XYZ({ url: 'http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}' }), visible: obj.visible, }) _layer.set('_maxZoom', obj.maxZoom) _layer.set('_minZoom', obj.minZoom) _layer.set('_easyMapOl_layerName', obj.name) _layer.set('_label', obj.label) _layer.set('_img', obj.img) return _layer } const baseMapLayers = [ initBaseLayer({ key: 'sea', name: 'base_haitu', label: '海图', maxZoom: 14, minZoom: 5, visible: false, img: HaituImg }), !window.location.origin.includes('localhost') ? initBaseLayer({ key: 'tdtsl', name: 'base_tianditu', label: '陆图', maxZoom: 20, minZoom: 8, visible: true, img: LutuImg }) : initLocalhost({ key: 'tdtsl', name: 'base_tianditu', label: '陆图', maxZoom: 20, minZoom: 8, visible: true, img: LutuImg }), initBaseLayer({ key: 'hnimg', name: 'base_weixingtu', label: '卫星遥感图', maxZoom: 19, minZoom: 8, visible: false, img: WeixingImg }), ] export default { baseMapView, baseMapLayers, }