Commit fe39bc21 authored by 邓晓峰's avatar 邓晓峰

feat: 添加高德地图

parent 4fc185fd
......@@ -18,20 +18,23 @@ module.exports = opts => {
};
const preset = {
compact: false,
presets: [
opts.env && [
// eslint-disable-next-line global-require
require('@umijs/deps/compiled/babel/preset-env'),
{
...mergeConfig(defaultEnvConfig,{}),
...mergeConfig(defaultEnvConfig, {}),
modules: false,
...opts.env
...opts.env,
},
],
].filter(Boolean),
plugins: [
['@babel/plugin-proposal-optional-chaining', { loose: false }],
['@babel/plugin-proposal-nullish-coalescing-operator', { loose: false }],
require('@umijs/deps/compiled/babel/plugin-syntax-top-level-await').default,
require('@umijs/deps/compiled/babel/plugin-syntax-top-level-await')
.default,
['@babel/plugin-transform-destructuring', { loose: false }],
// opts.typescript && ['babel-plugin-transform-typescript-metadata'],
['@babel/plugin-proposal-decorators', { legacy: true }],
......@@ -83,9 +86,11 @@ module.exports = opts => {
},
],
...(opts.import
? opts.import.map(importOpts => {
return ['babel-plugin-import', importOpts, importOpts.libraryName];
})
? opts.import.map(importOpts => [
'babel-plugin-import',
importOpts,
importOpts.libraryName,
])
: []),
opts.importToAwaitRequire && [
'@umijs/babel-plugin-import-to-await-require',
......
......@@ -11,7 +11,8 @@ const spinner = ora('building for production...');
const { printFileSizes } = require('./buildDevUtil');
// const Diff = require('diff');
/* eslint-disable */
spinner.start()
spinner.start();
rm(
process.env.npm_config_releasepath
? path.resolve(
......
......@@ -210,12 +210,13 @@ module.exports = options => {
...(defineConfig.extraBabelPlugins || []),
].filter(Boolean),
env: getPreset.env,
compact: false,
};
chainConfig.module
.rule('js')
.test(/\.(js|mjs|jsx|ts|tsx)$/)
.include.add([/node_modules\/@esri/, cwd, ...(process.env.APP_ROOT ? [process.cwd()] : [])])
.include.add([cwd, ...(process.env.APP_ROOT ? [process.cwd()] : [])])
.end()
.exclude.add(/node_modules/)
.add(/\.mfsu/)
......
......@@ -30,7 +30,6 @@ const initLocale = () => {
initGlobalConfig();
initLocale();
const unlisten = history.listen(location => {
if(location.pathname.indexOf('/civbase/user/login') > -1) {
console.log('init config')
initGlobalConfig();
......
......@@ -33,3 +33,7 @@ export const REQUEST_METHOD_GET = 'get';
export const REQUEST_METHOD_POST = 'post';
export const REQUEST_METHOD_PUT = 'put';
export const REQUEST_METHOD_DELETE = 'delete';
export const WEB_GIS_TYPE = {
ARCGIS: 'ArcgisMap',
AMAP: 'AMap'
}
......@@ -40,12 +40,15 @@ import RightContent from '@/components/GlobalHeader/ExtendRightContent';
import Panel from '@/components/SliderPanel/MinPanel';
import { actionCreators } from '@/containers/App/store';
import CreateBaseMap from '@/pages/map';
import AMap from '@/pages/amap';
import CesiumMap from '@/pages/cesiumMap';
import KeepAlive from 'react-activation'
import AMapLoader from '@amap/amap-jsapi-loader';
import { WEB_GIS_TYPE } from '../constants'
// import Authorized from '@/utils/Authorized';
import { findPathByLeafId, getBaseName } from '@/utils/utils';
// import { renderRoutes } from 'react-router-config';
import { renderRoutes } from '../utils/routes';
import { renderRoutes, getParams } from '../utils/routes';
import SecurityLayout from './SecurityLayout';
import Site from './Site';
import styles from './UserLayout.less';
......@@ -260,6 +263,7 @@ const BasicLayout = props => {
const [selectedKeys, setSelectedKeys] = useState([]);
const [tabActiveKey, setTabActiveKey] = useState("1");
const [currentRoutes, setCurrentRoutes] = useState({});
const [mapMode, setMapMode] = useState('ArcgisMap')
const [siteAction, setSiteAction] = useState(
() => new Site(props, setSiteLoading),
);
......@@ -274,7 +278,7 @@ const BasicLayout = props => {
if(!_.isEqual(currentRoutes, newRoutes)) {
setCurrentRoutes({})
setSelectIndex(-1);
setCurrentRoutes( newRoutes)
setCurrentRoutes(newRoutes)
}
}, [props.route, props.currentMenuIndex]);
......@@ -331,9 +335,9 @@ const BasicLayout = props => {
}
}, []);
useEffect(() => {
console.log(props.route.routes);
}, [props.currentMenuIndex]);
// useEffect(() => {
// console.log(props.route.routes);
// }, [props.currentMenuIndex]);
useEffect(() => {
window.share && window.share.event && window.share.event.on('event:updateCurrentChildrenRoutes', ({currentPath, currentRoute, selectedIndex}) => {
......@@ -411,6 +415,15 @@ const BasicLayout = props => {
}
}
}
const params = getParams(props.location.pathname);
if(params.hasOwnProperty('mapType') && params.mapType === WEB_GIS_TYPE.AMAP) {
AMapLoader.reset();
setMapMode(WEB_GIS_TYPE.AMAP)
} else {
AMapLoader.reset();
setMapMode(WEB_GIS_TYPE.ARCGIS)
}
console.log(props.location, currentRoutes)
}, [props.location]);
// window.share.event.on('event:history', params => {
// setTimeout(() => {
......@@ -431,8 +444,13 @@ const BasicLayout = props => {
useEffect(() => {
window.share.event.on('updateSite', res => setCityData(res));
// store.on('event:map', arg => {
// AMapLoader.reset();
// setMapMode(arg)
// });
return () => {
window.share.event.removeAllListeners('updateSite');
// store.off('event:map', () => {})
};
}, []);
......@@ -712,9 +730,15 @@ const BasicLayout = props => {
}
{
window.location.pathname.startsWith('/civbase/civ_3d') ? <KeepAlive><CesiumMap /></KeepAlive> : window.location.pathname.startsWith('/civbase/civ_webgis') ? <CreateBaseMap options={{ type: 'ArcgisMap' }}/> : null
window.location.pathname.startsWith('/civbase/civ_3d') ? <KeepAlive><CesiumMap /></KeepAlive> : window.location.pathname.startsWith('/civbase/civ_webgis') ? ((mapMode === 'AMap' ? <AMap/>: <CreateBaseMap options={{ type: 'ArcgisMap' }}/>)) : null
}
{
(mapMode === 'AMap' && <AMap/>)
}
<div id="micro-container" className="subapp-container">
{props.children}
......@@ -733,9 +757,8 @@ const BasicLayout = props => {
}
{
window.location.pathname.startsWith('/civbase/civ_3d') ? <KeepAlive><CesiumMap /></KeepAlive> : window.location.pathname.startsWith('/civbase/civ_webgis') ? <CreateBaseMap options={{ type: 'ArcgisMap' }}/> : null
window.location.pathname.startsWith('/civbase/civ_3d') ? <KeepAlive><CesiumMap /></KeepAlive> : window.location.pathname.startsWith('/civbase/civ_webgis') ? ((mapMode === 'AMap' ? <AMap/>: <CreateBaseMap options={{ type: 'ArcgisMap' }}/>)) : null
}
<div id="micro-container" className="subapp-container">
{/*<CreateBaseMap/>*/}
{props.children}
......
......@@ -334,6 +334,7 @@ window.app.define('@wisdom-utils/components', require.context('../node_modules/@
* arcgismap
*/
window.app.define('@wisdom-map/arcgismap', require.context('../node_modules/@wisdom-map/arcgismap/lib', true, /^.\/(lib\/)?[^\/]+\.js$/), 'index.js');
window.app.define('@wisdom-map/arcgisMap', require.context('../node_modules/@wisdom-map/arcgisMap/lib', true, /^.\/(lib\/)?[^\/]+\.js$/), 'index.js');
window.app.define('@wisdom-map/Amap', require.context('../node_modules/@wisdom-map/Amap/lib', true, /^.\/(lib\/)?[^\/]+\.js$/), 'index.js');
window.app.define('@wisdom-map/Map', require.context('../node_modules/@wisdom-map/Map/lib', true, /^.\/(lib\/)?[^\/]+\.js$/), 'index.js');
......
const mapSetting = {
zooms: [14],
mapSettings: {
mapStyle: 'amap://styles/74fae00a851749793870b658f9f22d55',
pipeStyle: 'image',
viewMode: '2D',
},
propertysName: ['所在位置', '开关状态', '编号', '口径'],
showSearchFileds: ['开关状态', '编号', '口径'],
showFileds: ['编号'],
contextMenu: true,
theme: 'dark',
radius: 120,
isEdit: false,
};
export default mapSetting;
\ No newline at end of file
import React, { useEffect, useState } from 'react';
import { AMapScene } from '@wisdom-map/Amap';
import { connect } from 'react-redux';
import mapSetting from './config';
import { store } from 'microser-data';
const config = {
type: '2d',
viewingMode: 'global',
proxyUrl: '',
environment: {
starsEnabled: true,
},
constraints: {
rotationEnabled: false,
tilt: {
max: 179.5,
},
collision: {
enabled: false,
},
},
viewpoint: {
camera: {
position: {
x: '0.0',
y: '0.0',
z: '0.0',
spatialReference: {
wkid: '4526.0',
},
},
heading: '0.0',
tilt: '0.0',
fov: '55.0',
},
targetGeometry: {
xmin: '0.0',
ymin: '0.0',
xmax: '0.0',
ymax: '0.0',
spatialReference: {
wkid: '4526.0',
},
},
},
basemaps: [
{
id: '高德地形',
title: '高德地形',
thumbnailUrl: 'assets/images/thumbnail/thumbnail_2.jpg',
baseLayers: [
{
title: '高德地形',
icon: '',
layerType: 'amap-v',
url: '',
opacity: '1.0',
visible: false,
useProxy: false,
proxyUrl: '',
style: '',
extent: '',
baseLayer: '',
resolution: '',
origin: '',
tileMatrix: '',
levelStart: '',
levelEnd: '',
levelEndEnlarge: false,
},
],
},
],
layers: [
{
id: 'lihonglin',
title: 'lihonglin',
icon: '',
layerType: 'PipenetLayer',
url: 'CityInterface/rest/services/MapServer.svc/lihonglin',
opacity: '1.0',
showLegend: true,
visible: true,
useProxy: true,
proxyUrl: '',
extent: '13196168.016289838,4814326.171369759,13232913.305918653,4843281.459597265',
baseLayer: '',
resolution: '',
origin: '',
tileMatrix: '',
wmtsUrl: '',
schemename: '1212',
roles: '',
areaName: '滦州市',
boundColor: '#86c8f8',
backgroundColor: '#000000',
boundWidth: '10px',
backgroundOpacity: '0.6',
basemaps: [
{
id: '高德地形',
title: '高德地形',
thumbnailUrl: 'assets/images/thumbnail/thumbnail_2.jpg',
baseLayers: [
{
title: '高德地形',
icon: '',
layerType: 'amap-v',
url: '',
opacity: '1.0',
visible: false,
useProxy: false,
proxyUrl: '',
style: '',
extent: '',
baseLayer: '',
resolution: '',
origin: '',
tileMatrix: '',
levelStart: '',
levelEnd: '',
levelEndEnlarge: false,
},
],
},
],
levelStart: '',
},
],
areasettings: {
boundColor: '#86c8f8',
boundWidth: '10px',
backgroundColor: '#000000',
backgroundOpacity: '0.6',
areaName: '滦州市',
extent: '13196168.016289838,4814326.171369759,13232913.305918653,4843281.459597265',
rings: '',
},
}
const AMap = props => {
const getMap = (obj, current) => {
// setAMapObj(obj);
// setCurrentMapObj(current);
};
return (
<>
<AMapScene
config={config}
getMapInfo={getMap}
theme={mapSetting.mapSettings.mapStyle}
/>
</>
);
};
// const mapStateToProps = state => ({
// view: state.getIn(['global', 'amapView']),
// });
export default AMap;
// export default Topic;
......@@ -213,7 +213,6 @@ class Login {
'request.preventCache': Date.now(),
})
.then(response => {
debugger
const result =
response && response.code === SERVICE_INTERFACE_SUCCESS_CODE
? Array.isArray(response.data)
......@@ -385,7 +384,6 @@ class Login {
url: 'product/webgisPanda/ToggleProject/ToggleProject',
});
}
debugger;
if (layer.areaName) {
this.globalConfig.mapsettings.areasettings.areaName = layer.areaName;
}
......
......@@ -27,7 +27,7 @@ export const guid = function(prefix) {
return prefix + uuid.replace(/-/g, '.') + new Date().getTime();
};
function getParams(pathname) {
export function getParams(pathname) {
let ret = {};
const url = pathname ? pathname : decodeURIComponent(window.location.pathname);
if (url.indexOf('|') > -1) {
......@@ -128,6 +128,7 @@ const generRotes = (widgets, parent, level = 0) => {
icon,
},
parent,
params: getParams(url),
};
if(/iframe/.test(url)) {
url = url.replace(/\/report/, '');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment