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

feat: 添加高德地图

parent 4fc185fd
...@@ -18,20 +18,23 @@ module.exports = opts => { ...@@ -18,20 +18,23 @@ module.exports = opts => {
}; };
const preset = { const preset = {
compact: false,
presets: [ presets: [
opts.env && [ opts.env && [
// eslint-disable-next-line global-require
require('@umijs/deps/compiled/babel/preset-env'), require('@umijs/deps/compiled/babel/preset-env'),
{ {
...mergeConfig(defaultEnvConfig,{}), ...mergeConfig(defaultEnvConfig, {}),
modules: false, modules: false,
...opts.env ...opts.env,
}, },
], ],
].filter(Boolean), ].filter(Boolean),
plugins: [ plugins: [
['@babel/plugin-proposal-optional-chaining', { loose: false }], ['@babel/plugin-proposal-optional-chaining', { loose: false }],
['@babel/plugin-proposal-nullish-coalescing-operator', { 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 }], ['@babel/plugin-transform-destructuring', { loose: false }],
// opts.typescript && ['babel-plugin-transform-typescript-metadata'], // opts.typescript && ['babel-plugin-transform-typescript-metadata'],
['@babel/plugin-proposal-decorators', { legacy: true }], ['@babel/plugin-proposal-decorators', { legacy: true }],
...@@ -83,9 +86,11 @@ module.exports = opts => { ...@@ -83,9 +86,11 @@ module.exports = opts => {
}, },
], ],
...(opts.import ...(opts.import
? opts.import.map(importOpts => { ? opts.import.map(importOpts => [
return ['babel-plugin-import', importOpts, importOpts.libraryName]; 'babel-plugin-import',
}) importOpts,
importOpts.libraryName,
])
: []), : []),
opts.importToAwaitRequire && [ opts.importToAwaitRequire && [
'@umijs/babel-plugin-import-to-await-require', '@umijs/babel-plugin-import-to-await-require',
......
...@@ -11,7 +11,8 @@ const spinner = ora('building for production...'); ...@@ -11,7 +11,8 @@ const spinner = ora('building for production...');
const { printFileSizes } = require('./buildDevUtil'); const { printFileSizes } = require('./buildDevUtil');
// const Diff = require('diff'); // const Diff = require('diff');
/* eslint-disable */ /* eslint-disable */
spinner.start() spinner.start();
rm( rm(
process.env.npm_config_releasepath process.env.npm_config_releasepath
? path.resolve( ? path.resolve(
......
...@@ -210,12 +210,13 @@ module.exports = options => { ...@@ -210,12 +210,13 @@ module.exports = options => {
...(defineConfig.extraBabelPlugins || []), ...(defineConfig.extraBabelPlugins || []),
].filter(Boolean), ].filter(Boolean),
env: getPreset.env, env: getPreset.env,
compact: false,
}; };
chainConfig.module chainConfig.module
.rule('js') .rule('js')
.test(/\.(js|mjs|jsx|ts|tsx)$/) .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() .end()
.exclude.add(/node_modules/) .exclude.add(/node_modules/)
.add(/\.mfsu/) .add(/\.mfsu/)
......
...@@ -30,7 +30,6 @@ const initLocale = () => { ...@@ -30,7 +30,6 @@ const initLocale = () => {
initGlobalConfig(); initGlobalConfig();
initLocale(); initLocale();
const unlisten = history.listen(location => { const unlisten = history.listen(location => {
if(location.pathname.indexOf('/civbase/user/login') > -1) { if(location.pathname.indexOf('/civbase/user/login') > -1) {
console.log('init config') console.log('init config')
initGlobalConfig(); initGlobalConfig();
......
...@@ -33,3 +33,7 @@ export const REQUEST_METHOD_GET = 'get'; ...@@ -33,3 +33,7 @@ export const REQUEST_METHOD_GET = 'get';
export const REQUEST_METHOD_POST = 'post'; export const REQUEST_METHOD_POST = 'post';
export const REQUEST_METHOD_PUT = 'put'; export const REQUEST_METHOD_PUT = 'put';
export const REQUEST_METHOD_DELETE = 'delete'; 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'; ...@@ -40,12 +40,15 @@ import RightContent from '@/components/GlobalHeader/ExtendRightContent';
import Panel from '@/components/SliderPanel/MinPanel'; import Panel from '@/components/SliderPanel/MinPanel';
import { actionCreators } from '@/containers/App/store'; import { actionCreators } from '@/containers/App/store';
import CreateBaseMap from '@/pages/map'; import CreateBaseMap from '@/pages/map';
import AMap from '@/pages/amap';
import CesiumMap from '@/pages/cesiumMap'; import CesiumMap from '@/pages/cesiumMap';
import KeepAlive from 'react-activation' import KeepAlive from 'react-activation'
import AMapLoader from '@amap/amap-jsapi-loader';
import { WEB_GIS_TYPE } from '../constants'
// import Authorized from '@/utils/Authorized'; // import Authorized from '@/utils/Authorized';
import { findPathByLeafId, getBaseName } from '@/utils/utils'; import { findPathByLeafId, getBaseName } from '@/utils/utils';
// import { renderRoutes } from 'react-router-config'; // import { renderRoutes } from 'react-router-config';
import { renderRoutes } from '../utils/routes'; import { renderRoutes, getParams } from '../utils/routes';
import SecurityLayout from './SecurityLayout'; import SecurityLayout from './SecurityLayout';
import Site from './Site'; import Site from './Site';
import styles from './UserLayout.less'; import styles from './UserLayout.less';
...@@ -260,6 +263,7 @@ const BasicLayout = props => { ...@@ -260,6 +263,7 @@ const BasicLayout = props => {
const [selectedKeys, setSelectedKeys] = useState([]); const [selectedKeys, setSelectedKeys] = useState([]);
const [tabActiveKey, setTabActiveKey] = useState("1"); const [tabActiveKey, setTabActiveKey] = useState("1");
const [currentRoutes, setCurrentRoutes] = useState({}); const [currentRoutes, setCurrentRoutes] = useState({});
const [mapMode, setMapMode] = useState('ArcgisMap')
const [siteAction, setSiteAction] = useState( const [siteAction, setSiteAction] = useState(
() => new Site(props, setSiteLoading), () => new Site(props, setSiteLoading),
); );
...@@ -274,7 +278,7 @@ const BasicLayout = props => { ...@@ -274,7 +278,7 @@ const BasicLayout = props => {
if(!_.isEqual(currentRoutes, newRoutes)) { if(!_.isEqual(currentRoutes, newRoutes)) {
setCurrentRoutes({}) setCurrentRoutes({})
setSelectIndex(-1); setSelectIndex(-1);
setCurrentRoutes( newRoutes) setCurrentRoutes(newRoutes)
} }
}, [props.route, props.currentMenuIndex]); }, [props.route, props.currentMenuIndex]);
...@@ -331,9 +335,9 @@ const BasicLayout = props => { ...@@ -331,9 +335,9 @@ const BasicLayout = props => {
} }
}, []); }, []);
useEffect(() => { // useEffect(() => {
console.log(props.route.routes); // console.log(props.route.routes);
}, [props.currentMenuIndex]); // }, [props.currentMenuIndex]);
useEffect(() => { useEffect(() => {
window.share && window.share.event && window.share.event.on('event:updateCurrentChildrenRoutes', ({currentPath, currentRoute, selectedIndex}) => { window.share && window.share.event && window.share.event.on('event:updateCurrentChildrenRoutes', ({currentPath, currentRoute, selectedIndex}) => {
...@@ -411,6 +415,15 @@ const BasicLayout = props => { ...@@ -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]); }, [props.location]);
// window.share.event.on('event:history', params => { // window.share.event.on('event:history', params => {
// setTimeout(() => { // setTimeout(() => {
...@@ -431,8 +444,13 @@ const BasicLayout = props => { ...@@ -431,8 +444,13 @@ const BasicLayout = props => {
useEffect(() => { useEffect(() => {
window.share.event.on('updateSite', res => setCityData(res)); window.share.event.on('updateSite', res => setCityData(res));
// store.on('event:map', arg => {
// AMapLoader.reset();
// setMapMode(arg)
// });
return () => { return () => {
window.share.event.removeAllListeners('updateSite'); window.share.event.removeAllListeners('updateSite');
// store.off('event:map', () => {})
}; };
}, []); }, []);
...@@ -712,9 +730,15 @@ const BasicLayout = props => { ...@@ -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"> <div id="micro-container" className="subapp-container">
{props.children} {props.children}
...@@ -733,9 +757,8 @@ const BasicLayout = props => { ...@@ -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"> <div id="micro-container" className="subapp-container">
{/*<CreateBaseMap/>*/} {/*<CreateBaseMap/>*/}
{props.children} {props.children}
......
...@@ -334,6 +334,7 @@ window.app.define('@wisdom-utils/components', require.context('../node_modules/@ ...@@ -334,6 +334,7 @@ window.app.define('@wisdom-utils/components', require.context('../node_modules/@
* arcgismap * 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/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/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'); 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 { ...@@ -213,7 +213,6 @@ class Login {
'request.preventCache': Date.now(), 'request.preventCache': Date.now(),
}) })
.then(response => { .then(response => {
debugger
const result = const result =
response && response.code === SERVICE_INTERFACE_SUCCESS_CODE response && response.code === SERVICE_INTERFACE_SUCCESS_CODE
? Array.isArray(response.data) ? Array.isArray(response.data)
...@@ -385,7 +384,6 @@ class Login { ...@@ -385,7 +384,6 @@ class Login {
url: 'product/webgisPanda/ToggleProject/ToggleProject', url: 'product/webgisPanda/ToggleProject/ToggleProject',
}); });
} }
debugger;
if (layer.areaName) { if (layer.areaName) {
this.globalConfig.mapsettings.areasettings.areaName = layer.areaName; this.globalConfig.mapsettings.areasettings.areaName = layer.areaName;
} }
......
...@@ -27,7 +27,7 @@ export const guid = function(prefix) { ...@@ -27,7 +27,7 @@ export const guid = function(prefix) {
return prefix + uuid.replace(/-/g, '.') + new Date().getTime(); return prefix + uuid.replace(/-/g, '.') + new Date().getTime();
}; };
function getParams(pathname) { export function getParams(pathname) {
let ret = {}; let ret = {};
const url = pathname ? pathname : decodeURIComponent(window.location.pathname); const url = pathname ? pathname : decodeURIComponent(window.location.pathname);
if (url.indexOf('|') > -1) { if (url.indexOf('|') > -1) {
...@@ -128,6 +128,7 @@ const generRotes = (widgets, parent, level = 0) => { ...@@ -128,6 +128,7 @@ const generRotes = (widgets, parent, level = 0) => {
icon, icon,
}, },
parent, parent,
params: getParams(url),
}; };
if(/iframe/.test(url)) { if(/iframe/.test(url)) {
url = url.replace(/\/report/, ''); 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