Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
d3664828
Commit
d3664828
authored
Dec 18, 2020
by
邹绪超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 引入管网
parent
e10f8fe6
Pipeline
#20849
passed with stages
in 4 minutes 26 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
548 additions
and
38 deletions
+548
-38
.umirc.js
.umirc.js
+6
-0
module.js
packages/map/src/config/module.js
+1
-0
createMap.jsx
packages/map/src/demos/createMap.jsx
+21
-3
AMapTileLayer.js
packages/map/src/extensions/layers/AMapTileLayer.js
+1
-1
index.js
packages/map/src/index.js
+382
-32
GeometryTool.js
packages/map/src/utils/GeometryTool.js
+69
-0
utils.js
packages/map/src/utils/utils.js
+68
-2
No files found.
.umirc.js
View file @
d3664828
...
...
@@ -85,4 +85,10 @@ export default {
'https://gw.alipayobjects.com/os/lib/antd/4.6.6/dist/antd-with-locales.js'
,
]
:
[],
proxy
:
{
'/CityInterface'
:
{
target
:
'http://localhost:8099'
,
changeOrigin
:
true
,
},
},
};
packages/map/src/config/module.js
View file @
d3664828
...
...
@@ -30,4 +30,5 @@ export default [
'gis/geometry/Point'
,
'dojo/_base/lang'
,
'gis/core/promiseUtils'
,
'gis/core/urlUtils'
,
];
packages/map/src/demos/createMap.jsx
View file @
d3664828
import
mapsettings
from
'../mapData'
;
import
MapManganer
from
'../index'
;
export
default
()
=>
{
return
<
MapManganer
mapsettings=
{
mapsettings
}
/>;
};
export
default
class
CreateMap
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
mapManganerRef
=
React
.
createRef
();
if
(
!
window
.
_config
)
{
window
.
_config
=
{
site
:
''
,
mapsettings
:
mapsettings
,
useCoverMap
:
true
,
};
}
}
componentDidMount
()
{
window
.
mapManager
=
this
.
mapManganerRef
.
current
;
}
render
()
{
return
<
MapManganer
mapsettings=
{
mapsettings
}
ref=
{
this
.
mapManganerRef
}
/>;
}
}
packages/map/src/extensions/layers/AMapTileLayer.js
View file @
d3664828
import
TilemetaUtils
from
'./support/TilemetaUtils'
;
console
.
log
(
'Amap-tilelayer'
);
export
default
function
(
TileLayer
,
lang
,
promiseUtils
)
{
var
dpi
=
96
,
//pixel per inch
level
=
99
,
//地图缩放级数
...
...
packages/map/src/index.js
View file @
d3664828
...
...
@@ -7,7 +7,9 @@ import gisModules from './config/module';
import
AMapTileLayer
from
'./extensions/layers/AMapTileLayer'
;
import
GoogleTileLayer
from
'./extensions/layers/GoogleTileLayer'
;
import
*
as
utils
from
'./utils/utils'
;
import
*
as
Utils
from
'./utils/Utils'
;
import
*
as
GeomUtils
from
'./utils/GeometryTool'
;
export
default
class
MapManager
extends
React
.
Component
{
static
defaultProps
=
{
...
...
@@ -24,16 +26,17 @@ export default class MapManager extends React.Component {
this
.
initializeVariables
();
}
initializeVariables
()
{
async
initializeVariables
()
{
this
.
view
=
null
;
this
.
map
=
null
;
this
.
basemap
=
null
;
this
.
tipManager
=
null
;
this
.
AreaLayerSum
=
null
;
this
.
reorderGroups
=
[];
this
.
hidetipHandler
=
null
;
this
.
showtipHandler
=
null
;
this
.
renderMenu
=
true
;
this
.
mapsettings
=
this
.
props
.
mapsettings
;
window
.
_config
=
{
site
:
''
,
};
}
getStyle
()
{
...
...
@@ -43,14 +46,28 @@ export default class MapManager extends React.Component {
};
}
componentDidMount
()
{
utils
.
loadModules
(
this
.
props
.
modules
).
then
(
function
(
moduleArr
)
{
this
.
getModules
(
moduleArr
);
this
.
createMapLayers
();
this
.
renderView
();
}.
bind
(
this
),
);
async
componentDidMount
()
{
let
moduleArr
=
await
Utils
.
asyncLoadModules
(
this
.
props
.
modules
);
await
GeomUtils
.
loadAllDependencies
();
this
.
getModules
(
moduleArr
);
this
.
createMapLayers
();
this
.
renderView
();
this
.
loadAMap
();
}
loadAMap
()
{
console
.
log
(
'load AMap'
);
let
url
=
'https://webapi.amap.com/maps?v=1.4.15&key=e83f64300a2a55a33fa8e4ab9a46bca6'
;
fetch
(
url
).
then
((
params
)
=>
{
console
.
log
(
params
);
console
.
log
(
window
);
// let plugins = ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.DistrictSearch']
// AMap.plugins(plugins, () => {
// })
let
UIurl
=
'//webapi.amap.com/ui/1.1/main.js'
;
fetch
(
UIurl
,
()
=>
{});
});
}
getModules
(
moduleArr
)
{
...
...
@@ -86,7 +103,9 @@ export default class MapManager extends React.Component {
Point
:
moduleArr
[
28
],
lang
:
moduleArr
[
29
],
promiseUtils
:
moduleArr
[
30
],
urlUtils
:
moduleArr
[
31
],
};
Utils
.
bindUrlUtils
(
this
.
loadedModules
.
urlUtils
);
}
createMapLayers
()
{
...
...
@@ -106,6 +125,43 @@ export default class MapManager extends React.Component {
this
.
addLayerProxy
();
this
.
addMap
();
this
.
addBasemaps
();
this
.
addLayerReorder
();
this
.
addLayers
();
if
(
'2d'
==
this
.
mapsettings
.
type
.
toLowerCase
())
{
this
.
addMatrixLayer
();
//加入空的GraphicsLayer,用于获取地图的moveStart,viewChange,moveEnd事件
}
this
.
addTipManager
();
if
(
this
.
renderMenu
&&
this
.
view
&&
this
.
view
.
type
==
'2d'
)
{
this
.
loadedModules
.
watchUtils
.
whenTrue
(
this
.
view
,
'ready'
,
this
.
renderRightClickMenu
.
bind
(
this
),
);
this
.
loadedModules
.
watchUtils
.
whenTrueOnce
(
this
.
view
,
'ready'
,
this
.
renderRoamte
.
bind
(
this
));
// edit by zhangyao on 2018/11/1
this
.
hidetipHandler
=
this
.
loadedModules
.
watchUtils
.
whenTrue
(
this
.
view
,
'stationary'
,
function
(
e
)
{
console
.
log
(
'地图禁止'
);
// this.tipManager.$el.show();
// this.$el.find(".gis-view-surface div.gis-display-object").show();
if
(
this
.
updateLayerView
)
this
.
updateLayerView
();
}.
bind
(
this
),
);
this
.
showtipHandler
=
this
.
loadedModules
.
watchUtils
.
whenFalse
(
this
.
view
,
'stationary'
,
function
(
e
)
{
if
(
this
.
view
.
animation
)
{
// 判断地图是否在缩放
// this.tipManager.$el.hide();
// this.$el.find(".gis-view-surface div.gis-display-object").hide();
console
.
log
(
'地图移动'
);
}
}.
bind
(
this
),
);
}
}
addLayerProxy
()
{}
...
...
@@ -163,7 +219,53 @@ export default class MapManager extends React.Component {
this
.
view
.
then
(
this
.
setInitialViewpoint
);
}
setInitialViewpoint
()
{}
setInitialViewpoint
()
{
window
.
view
=
this
.
view
;
if
(
this
.
viewpoint
)
{
this
.
initialViewpoint
=
new
this
.
loadedModules
.
Viewpoint
();
if
(
this
.
viewpoint
.
camera
)
{
this
.
initialViewpoint
.
camera
=
new
this
.
loadedModules
.
Camera
(
this
.
viewpoint
.
camera
);
this
.
viewpoint
.
targetGeometry
&&
(
this
.
initialViewpoint
.
targetGeometry
=
GeomUtils
.
toGeometry
(
this
.
viewpoint
.
targetGeometry
,
));
this
.
viewpoint
.
scale
&&
(
this
.
initialViewpoint
.
scale
=
this
.
viewpoint
.
scale
);
this
.
viewpoint
.
rotation
&&
(
this
.
initialViewpoint
.
rotation
=
this
.
viewpoint
.
rotation
);
}
var
geom
=
this
.
initialViewpoint
.
targetGeometry
;
if
(
geom
&&
!
(
geom
.
xmin
==
0
&&
geom
.
ymin
==
0
&&
geom
.
xmax
==
0
&&
geom
.
ymax
==
0
))
{
if
(
geom
.
type
==
'extent'
)
{
var
scale
=
this
.
getNearestScale
(
geom
.
clone
());
if
(
scale
!=
-
1
)
{
this
.
initialViewpoint
.
scale
=
scale
;
}
}
}
else
{
if
(
this
.
view
.
extent
)
{
this
.
initialViewpoint
.
targetGeometry
=
this
.
view
.
extent
.
clone
();
this
.
initialViewpoint
.
scale
=
this
.
view
.
scale
;
}
}
this
.
view
.
goTo
(
this
.
initialViewpoint
);
}
else
{
this
.
initialViewpoint
=
this
.
view
.
viewpoint
;
}
if
(
this
.
mapsettings
.
areasettings
&&
this
.
mapsettings
.
areasettings
.
areaName
.
toLowerCase
().
indexOf
(
'offlinearea'
)
>
-
1
&&
!
this
.
areaLayerInit
)
{
this
.
extent
=
{};
this
.
setExtent
();
this
.
areaLayerInit
=
true
;
return
;
}
if
(
!
this
.
areaLayerInit
)
{
this
.
loadAreaLayer
();
}
}
addBasemaps
()
{
let
basemapconfigs
=
this
.
mapsettings
.
basemaps
;
...
...
@@ -213,11 +315,173 @@ export default class MapManager extends React.Component {
createDefaultBasemap
()
{}
addLayerReorder
()
{
this
.
layerAddedHandler
=
this
.
layerAddedHandler
.
bind
(
this
);
this
.
map
.
layers
.
on
(
'after-add'
,
this
.
layerAddedHandler
);
}
layerAddedHandler
(
event
)
{
var
lyr
=
event
.
item
;
if
(
'graphics'
===
lyr
.
type
)
{
if
(
this
.
isInGroup
(
lyr
))
{
var
layer
=
this
.
map
.
layers
.
find
(
function
(
l
)
{
return
this
.
getLayerWeight
(
l
)
>
this
.
getLayerWeight
(
lyr
);
}.
bind
(
this
),
);
if
(
layer
)
{
this
.
map
.
layers
.
reorder
(
lyr
,
this
.
map
.
layers
.
indexOf
(
layer
)
-
1
);
}
}
}
}
isInGroup
(
lyr
)
{
var
groupName
=
lyr
.
order
.
split
(
'-'
)[
0
],
lyrIndex
=
Number
(
lyr
.
order
.
split
(
'-'
)[
1
]),
groupIndex
=
this
.
reorderGroups
.
indexOf
(
groupName
);
return
_
.
isNumber
(
lyrIndex
)
&&
groupIndex
>=
0
;
}
getLayerWeight
()
{
if
(
'graphics'
===
lyr
.
type
)
{
var
groupName
=
lyr
.
order
.
split
(
'-'
)[
0
],
lyrIndex
=
Number
(
lyr
.
order
.
split
(
'-'
)[
1
]),
groupIndex
=
this
.
reorderGroups
.
indexOf
(
groupName
);
if
(
_
.
isNumber
(
lyrIndex
)
&&
groupIndex
>=
0
)
{
return
(
groupIndex
+
1
)
*
100
+
lyrIndex
;
}
else
{
return
0
;
}
}
else
{
return
-
1
;
}
}
registerReorderStrategy
(
groupName
)
{
var
index
=
this
.
reorderGroups
.
indexOf
(
groupName
);
index
<
0
&&
this
.
reorderGroups
.
push
(
groupName
);
}
addLayers
()
{
let
layerconfigs
=
this
.
mapsettings
.
layers
;
if
(
layerconfigs
)
{
var
layer
;
layerconfigs
.
forEach
(
function
(
layerconfig
)
{
if
(
!
layerconfig
.
id
)
return
;
this
.
createLayer
(
layerconfig
,
this
.
map
,
false
,
'pipeLayer'
);
}.
bind
(
this
),
);
}
}
addMatrixLayer
()
{
this
.
_matrixLayer
=
new
this
.
loadedModules
.
GraphicsLayer
();
this
.
view
.
map
.
add
(
this
.
_matrixLayer
);
this
.
matrixLayerViewCreated
=
this
.
matrixLayerViewCreated
.
bind
(
this
);
this
.
matrixLayerMoveStart
=
this
.
matrixLayerMoveStart
.
bind
(
this
);
this
.
matrixLayerViewChange
=
this
.
matrixLayerViewChange
.
bind
(
this
);
this
.
matrixLayerMoveEnd
=
this
.
matrixLayerMoveEnd
.
bind
(
this
);
this
.
view
.
whenLayerView
(
this
.
_matrixLayer
).
then
(
this
.
matrixLayerViewCreated
);
}
matrixLayerViewCreated
(
lyrView
)
{
if
(
lyrView
)
{
lyrView
.
on
(
'moveStart'
,
this
.
matrixLayerMoveStart
);
lyrView
.
on
(
'viewChange'
,
this
.
matrixLayerViewChange
);
lyrView
.
on
(
'moveEnd'
,
this
.
matrixLayerMoveEnd
);
}
}
matrixLayerMoveStart
(
lyrView
)
{
var
m
=
this
.
getLayerViewMatrix
(
lyrView
);
this
.
view
.
emit
(
'moveStart'
,
{
layerView
:
lyrView
,
matrix
:
m
,
matrixString
:
this
.
toMatrixString
(
m
),
});
}
matrixLayerViewChange
(
lyrView
)
{
var
m
=
this
.
getLayerViewMatrix
(
lyrView
);
this
.
view
.
emit
(
'viewChange'
,
{
layerView
:
lyrView
,
matrix
:
m
,
zooming
:
m
.
xx
!=
1
,
matrixString
:
this
.
toMatrixString
(
m
),
});
}
matrixLayerMoveEnd
(
lyrView
)
{
var
m
=
this
.
getLayerViewMatrix
(
lyrView
);
this
.
view
.
emit
(
'moveEnd'
,
{
layerView
:
lyrView
,
matrix
:
m
,
matrixString
:
this
.
toMatrixString
(
m
),
});
}
getLayerViewMatrix
(
lyrView
)
{
let
matrix
=
this
.
loadedModules
.
matrix
;
var
m
=
matrix
.
clone
(
matrix
.
identify
);
if
(
lyrView
.
graphicsView
&&
lyrView
.
graphicsView
.
_frontGroup
&&
lyrView
.
graphicsView
.
_frontGroup
.
g
&&
lyrView
.
graphicsView
.
_frontGroup
.
g
.
matrix
)
{
var
targetMatrix
=
lyrView
.
graphicsView
.
_frontGroup
.
g
.
matrix
;
if
(
_
.
isArray
(
targetMatrix
))
{
// 4.6版本 matrix为数组
targetMatrix
=
{
xx
:
targetMatrix
[
0
],
yx
:
targetMatrix
[
1
],
xy
:
targetMatrix
[
2
],
yy
:
targetMatrix
[
3
],
dx
:
targetMatrix
[
4
],
dy
:
targetMatrix
[
5
],
};
}
m
=
matrix
.
clone
(
targetMatrix
);
}
return
m
;
}
toMatrixString
(
m
)
{
return
(
'matrix('
+
[
m
.
xx
.
toFixed
(
8
),
m
.
yx
.
toFixed
(
8
),
m
.
xy
.
toFixed
(
8
),
m
.
yy
.
toFixed
(
8
),
m
.
dx
.
toFixed
(
8
),
m
.
dy
.
toFixed
(
8
),
].
join
()
+
')'
);
}
addTipManager
()
{
this
.
openedPopups
=
[];
//后期做tipMananger
// this.tipManager = new TipManager({
// view: this.view,
// container: this.$el.find(".gis-view-surface")
// });
// this.tipManager.render();
}
renderRightClickMenu
()
{}
renderRoamte
()
{}
createLayer
(
config
,
collection
,
returnLayer
,
layerType
)
{
var
layer
;
var
layers
=
[];
if
(
config
.
url
)
{
//config.url =
urlUtils.getUrl(config.url);
config
.
url
=
this
.
loadedModules
.
urlUtils
.
getUrl
(
config
.
url
);
}
switch
(
config
.
layerType
.
toLowerCase
())
{
case
'tilelayer'
:
...
...
@@ -226,7 +490,7 @@ export default class MapManager extends React.Component {
case
'pipenetlayer'
:
case
'mapimagelayer'
:
layer
=
new
this
.
loadedModules
.
MapImageLayer
(
u
tils
.
_
.
extend
({},
config
,
{
U
tils
.
_
.
extend
({},
config
,
{
token
:
_config
.
token
,
client
:
'webgis'
,
visible
:
false
,
...
...
@@ -234,6 +498,7 @@ export default class MapManager extends React.Component {
);
layer
.
then
(
function
()
{
layer
.
visible
=
true
;
if
(
layer
.
hasAnnotation
)
{
// layer.annotationLayer = this.addAnnotationLayer(layer.title, layer.url, config.visible);
}
...
...
@@ -254,7 +519,7 @@ export default class MapManager extends React.Component {
return
this
.
createLayer
(
c
,
[],
true
,
''
);
},
this
);
layer
=
new
this
.
loadedModules
.
GroupLayer
(
u
tils
.
_
.
extend
({},
config
,
{
U
tils
.
_
.
extend
({},
config
,
{
layers
:
layers
,
}),
);
...
...
@@ -264,7 +529,7 @@ export default class MapManager extends React.Component {
case
'google-i-a'
:
case
'google-ia'
:
layer
=
new
this
.
loadedModules
.
GoogleTileLayer
(
u
tils
.
_
.
extend
(
config
,
{
U
tils
.
_
.
extend
(
config
,
{
url
:
'http://fack.com'
,
}),
);
...
...
@@ -272,7 +537,7 @@ export default class MapManager extends React.Component {
case
'google-user'
:
var
proxyUrl
=
config
.
proxyUrl
?
config
.
proxyUrl
:
config
.
wmtsUrl
?
config
.
wmtsUrl
:
null
;
layer
=
new
this
.
loadedModules
.
UserTileLayer
(
u
tils
.
_
.
extend
(
config
,
{
U
tils
.
_
.
extend
(
config
,
{
url
:
proxyUrl
,
}),
);
...
...
@@ -281,7 +546,7 @@ export default class MapManager extends React.Component {
case
'pipenet-tile'
:
var
proxyUrl
=
config
.
proxyUrl
?
config
.
proxyUrl
:
config
.
wmtsUrl
?
config
.
wmtsUrl
:
null
;
layer
=
new
this
.
loadedModules
.
PipenetTileLayer
(
u
tils
.
_
.
extend
(
config
,
{
U
tils
.
_
.
extend
(
config
,
{
url
:
proxyUrl
,
}),
);
...
...
@@ -290,7 +555,7 @@ export default class MapManager extends React.Component {
case
'baidu-i'
:
case
'baidu-ia'
:
layer
=
new
this
.
loadedModules
.
BaiduTileLayer
(
u
tils
.
_
.
extend
(
config
,
{
U
tils
.
_
.
extend
(
config
,
{
url
:
'http://fack.com'
,
}),
);
...
...
@@ -302,7 +567,7 @@ export default class MapManager extends React.Component {
case
'amap-i2'
:
case
'amap-ia2'
:
layer
=
new
this
.
loadedModules
.
AMapTileLayer
(
u
tils
.
_
.
extend
(
config
,
{
U
tils
.
_
.
extend
(
config
,
{
url
:
'http://fack.com'
,
}),
);
...
...
@@ -320,7 +585,7 @@ export default class MapManager extends React.Component {
case
'tianditu-ll-t'
:
case
'tianditu-ll-ta'
:
layer
=
new
this
.
loadedModules
.
TiandituTileLayer
(
u
tils
.
_
.
extend
(
config
,
{
U
tils
.
_
.
extend
(
config
,
{
url
:
'http://fack.com'
,
}),
);
...
...
@@ -329,13 +594,13 @@ export default class MapManager extends React.Component {
//深拷贝config
var
configString
=
JSON
.
stringify
(
config
);
//天地图矢量
var
configv
=
u
tils
.
_
.
extend
(
JSON
.
parse
(
configString
),
{
var
configv
=
U
tils
.
_
.
extend
(
JSON
.
parse
(
configString
),
{
layerType
:
'tianditu-v'
,
});
this
.
createLayer
(
configv
,
collection
,
false
,
layerType
);
//天地图注记
var
configva
=
u
tils
.
_
.
extend
(
JSON
.
parse
(
configString
),
{
var
configva
=
U
tils
.
_
.
extend
(
JSON
.
parse
(
configString
),
{
layerType
:
'tianditu-va'
,
});
this
.
createLayer
(
configva
,
collection
,
false
,
layerType
);
...
...
@@ -344,13 +609,13 @@ export default class MapManager extends React.Component {
//深拷贝config
var
configString
=
JSON
.
stringify
(
config
);
//天地图矢量
var
configi
=
u
tils
.
_
.
extend
(
JSON
.
parse
(
configString
),
{
var
configi
=
U
tils
.
_
.
extend
(
JSON
.
parse
(
configString
),
{
layerType
:
'tianditu-i'
,
});
this
.
createLayer
(
configi
,
collection
,
false
,
layerType
);
//天地图注记
var
configia
=
u
tils
.
_
.
extend
(
JSON
.
parse
(
configString
),
{
var
configia
=
U
tils
.
_
.
extend
(
JSON
.
parse
(
configString
),
{
layerType
:
'tianditu-ia'
,
});
this
.
createLayer
(
configia
,
collection
,
false
,
layerType
);
...
...
@@ -358,20 +623,20 @@ export default class MapManager extends React.Component {
break
;
case
'osm'
:
layer
=
new
this
.
loadedModules
.
OpenStreetMapLayer
(
u
tils
.
_
.
extend
(
config
,
{
U
tils
.
_
.
extend
(
config
,
{
url
:
'http://fack.com'
,
}),
);
break
;
case
'wmts-v'
:
layer
=
new
this
.
loadedModules
.
WMTSTileLayer
(
u
tils
.
_
.
extend
(
config
,
{}));
layer
=
new
this
.
loadedModules
.
WMTSTileLayer
(
U
tils
.
_
.
extend
(
config
,
{}));
break
;
case
'arcgis-streetpurplishblue'
:
case
'arcgis-streetwarm'
:
case
'arcgis-community'
:
case
'arcgis-streetgray'
:
layer
=
new
this
.
loadedModules
.
TileLayer
(
u
tils
.
_
.
extend
(
config
,
{
U
tils
.
_
.
extend
(
config
,
{
url
:
'http://map.geoq.cn/ArcGIS/rest/services/ChinaOnline'
+
config
.
layerType
.
replace
(
'arcgis-'
,
''
)
+
...
...
@@ -391,7 +656,7 @@ export default class MapManager extends React.Component {
default
:
if
(
config
.
layerType
.
toLowerCase
().
indexOf
(
'tianditu-'
)
>
-
1
)
{
layer
=
new
this
.
loadedModules
.
TiandituTileLayer
(
u
tils
.
_
.
extend
(
config
,
{
U
tils
.
_
.
extend
(
config
,
{
url
:
'http://fack.com'
,
}),
);
...
...
@@ -411,7 +676,7 @@ export default class MapManager extends React.Component {
layer
.
visible
=
true
;
break
;
case
'pipeLayer'
:
u
tils
.
_
.
extend
(
layer
,
{
U
tils
.
_
.
extend
(
layer
,
{
preload
:
true
,
});
break
;
...
...
@@ -421,6 +686,91 @@ export default class MapManager extends React.Component {
collection
.
add
(
layer
);
}
loadAreaLayer
()
{
var
url
=
window
.
location
.
protocol
+
'//webapi.amap.com/maps?'
;
this
.
areaLayerInit
=
true
;
this
.
extent
=
{
spatialReference
:
{
wkid
:
4526
,
},
xmin
:
0
,
ymin
:
0
,
xmax
:
0
,
ymax
:
0
,
};
if
(
!
this
.
mapsettings
.
areasettings
)
return
null
;
// if (this.basemaps && this.basemaps[0] && this.basemaps[0]['id'] == '自定义底图') return this.setExtent()
var
area
=
this
.
mapsettings
.
areasettings
.
areaName
.
split
(
','
);
if
(
window
.
navigator
.
onLine
==
true
&&
area
.
length
==
1
)
{
let
timer
=
setInterval
(
function
()
{
if
(
window
.
AMap
&&
window
.
AMap
.
DistrictSearch
)
{
clearInterval
(
timer
);
this
.
getAreaLayer
();
}
}.
bind
(
this
),
500
,
);
}
else
{
// if (this.getPipenetLayer()) var url = this.getPipenetLayer().url;
// if (url && _config.mapsettings.areasettings.areaName) {
// request(url + "/GetMapArea", {
// query: {
// areaName: _config.mapsettings.areasettings.areaName.split(',')[0],
// outSR: webgisPandaTool.getCurrentMapWkid(),
// },
// cacheBust: true
// }).then(function (r) {
// if (r.data && r.data.length > 0) {
// this.polygon = [], this.edge = [], this.area = [], this.bound = null;
// r.data.forEach(function (point) {
// this.polygon.push([point.x, point.y]);
// }.bind(this))
// this.edge.push(this.polygon);
// _config.useCoverMap && this.area.push(this.polygon);
// this._setAreaLayer();
// } else {
// console.log("行政区图层无数据");
// }
// }.bind(this), function (error) {
// console.log("未查询到行政区图层数据!");
// }.bind(this))
// }
}
}
getAreaLayer
()
{}
setExtent
()
{}
showPipeNetLayer
()
{}
getNearestScale
(
extent
)
{
var
resolution
=
extent
.
width
/
this
.
view
.
width
,
zoom
=
0
,
nearestScale
=
-
1
,
diff
=
Number
.
POSITIVE_INFINITY
;
if
(
this
.
view
.
map
.
basemap
&&
this
.
view
.
map
.
basemap
.
baseLayers
.
length
>
0
)
{
this
.
view
.
map
.
basemap
.
baseLayers
.
getItemAt
(
0
).
tileInfo
.
lods
.
forEach
(
function
(
item
)
{
if
(
item
.
resolution
>=
resolution
)
{
var
difftemp
=
item
.
resolution
-
resolution
;
if
(
difftemp
<
diff
)
{
diff
=
difftemp
;
nearestScale
=
item
.
scale
;
zoom
=
item
.
level
;
}
}
}.
bind
(
this
),
);
}
if
(
!
this
.
mapsettings
.
scale
)
{
this
.
mapsettings
.
scale
=
nearestScale
;
this
.
mapsettings
.
zoom
=
zoom
;
}
return
nearestScale
;
}
render
()
{
return
<
div
ref
=
{
this
.
mapRef
}
id
=
{
this
.
props
.
id
}
style
=
{
this
.
getStyle
()}
><
/div>
;
}
...
...
packages/map/src/utils/GeometryTool.js
0 → 100644
View file @
d3664828
import
gisConfig
from
'../config/gis'
;
import
esriLoader
from
'esri-loader'
;
console
.
log
(
'test---geometry'
);
export
function
toGeometry
(
jsonObj
,
mapMng
)
{
var
geometry
,
mm
=
mapMng
||
mapManager
;
if
(
jsonObj
)
{
jsonObj
.
spatialReference
=
{
wkid
:
mm
.
view
.
spatialReference
.
wkid
,
};
geometry
=
AllDependenciesLoadedModules
[
'jsonUtils'
].
fromJSON
(
jsonObj
);
}
return
geometry
;
}
const
toGeometryDependenciesModules
=
{
jsonUtils
:
'gis/geometry/support/jsonUtils'
,
};
const
getDefaultSymbolDependenciesModules
=
{
SimpleMarkerSymbol
:
'gis/symbols/SimpleMarkerSymbol'
,
SimpleLineSymbol
:
'gis/symbols/SimpleLineSymbol'
,
SimpleFillSymbol
:
'gis/symbols/SimpleFillSymbol'
,
Color
:
'gis/Color'
,
};
const
ALLDependenciesModules
=
Object
.
assign
(
{},
toGeometryDependenciesModules
,
getDefaultSymbolDependenciesModules
,
);
const
AllDependenciesLoadedModules
=
{};
export
async
function
loadAllDependencies
()
{
isRequestLoadModules
(
ALLDependenciesModules
,
AllDependenciesLoadedModules
)
?
await
loadCommonModules
(
ALLDependenciesModules
,
AllDependenciesLoadedModules
)
:
''
;
}
export
async
function
loadToGeometryDependencies
()
{
isRequestLoadModules
(
toGeometryDependenciesModules
,
AllDependenciesLoadedModules
)
?
await
loadCommonModules
(
toGeometryDependenciesModules
,
AllDependenciesLoadedModules
)
:
''
;
}
export
async
function
loadGetDefaultSymbolDependencies
()
{
isRequestLoadModules
(
getDefaultSymbolDependenciesModules
,
AllDependenciesLoadedModules
)
?
await
loadCommonModules
(
getDefaultSymbolDependenciesModules
,
AllDependenciesLoadedModules
)
:
''
;
}
async
function
loadCommonModules
(
modulesUrlsObject
,
loadedModuleObject
)
{
let
moduleArr
=
Object
.
entries
(
modulesUrlsObject
);
let
moduleUrlsArray
=
moduleArr
.
map
((
item
)
=>
item
[
1
]);
let
modules
=
await
esriLoader
.
loadModules
(
moduleUrlsArray
,
gisConfig
);
modules
.
map
(
function
(
module
,
index
)
{
loadedModuleObject
[
moduleArr
[
index
][
0
]]
=
module
;
}.
bind
(
this
),
);
}
function
isRequestLoadModules
(
originModules
,
targetModule
)
{
let
flag
=
false
;
for
(
let
key
in
originModules
)
{
if
(
!
flag
&&
!
targetModule
[
key
])
flag
=
true
;
}
return
flag
;
}
packages/map/src/utils/utils.js
View file @
d3664828
...
...
@@ -16,6 +16,72 @@ export function loadModules(modules = [], mapSettings = {}) {
);
}
// export const urlUtils = window.urlUtils || function() {}
export
async
function
asyncLoadModules
(
modules
=
[],
mapSettings
=
{})
{
let
mergeMapSettings
=
Object
.
assign
(
gisConfig
,
mapSettings
);
let
results
=
await
esriLoader
.
loadModules
(
modules
,
mergeMapSettings
);
return
results
;
}
export
function
bindUrlUtils
(
urlUtils
)
{
if
(
!
urlUtils
.
getUrl
)
{
urlUtils
.
getUrl
=
urlUtilsGetUrl
;
}
}
function
urlUtilsGetUrl
(
template
,
_module
)
{
var
urlArr
=
[];
urlArr
.
push
(
location
.
protocol
+
'/'
);
urlArr
.
push
(
location
.
host
);
if
(
_config
.
prefix
)
{
urlArr
.
push
(
_config
.
prefix
);
}
// export urlUtils
if
(
_module
&&
_module
.
length
)
{
// url服务接口 模块配置路径采用绝对路径
var
_urlModuleTempl
=
{
CaseManageREST
:
'CityInterface/Services/CityServer_CaseManage/REST/CaseManageREST.svc'
,
EditREST
:
'CityInterface/Services/CityServer_Edit/REST/EditREST.svc'
,
MapREST
:
'CityInterface/rest/services/MapServer.svc'
,
MapRESTOld
:
'CityInterface/Services/CityServer_Map/REST/MapREST.svc'
,
WorkFlowREST
:
'CityInterface/Services/CityServer_WorkFlow/REST/WorkFlowREST.svc'
,
AuditREST
:
'CityInterface/Services/CityServer_Audit/REST/AuditREST.svc'
,
LocatorREST
:
'CityInterface/Services/CityServer_Locator/REST/LocatorREST.svc'
,
NewNotificationREST
:
'CityInterface/Services/CityServer_NewNotification/REST/NewNotificationREST.svc'
,
OfficeTemplateREST
:
'Cityinterface/Services/CityServer_OfficeTemplate/REST/OfficeTemplate.svc'
,
OfflineTaskEditREST
:
'CityInterface/Services/CityServer_OfflineTaskEdit/REST/OfflineTaskEditREST.svc'
,
PatrolStandardRest
:
'CityInterface/rest/services/PatrolStandard.svc'
,
PatrolStandardRestOld
:
'CityInterface/Services/CityServer_Patrol_Standard/REST/PatrolStandardRest.svc'
,
NewPatrolREST
:
'CityInterface/rest/services/NewPatrol.svc'
,
OldPatrolREST
:
'CityInterface/Services/CityServer_NewPatrol/REST/Newpatrolrest.svc'
,
MobileBusinessBaseREST
:
'CityInterface/Services/CityServer_MobileBusiness/REST/BaseREST.svc'
,
HZGSProjectBoxREST
:
'CityInterface/Services/CityServer_HZGSProjectBox/REST/HZGSProjectBoxREST.svc'
,
ZS_ProjectManageREST
:
'CityInterface/Services/CityServer_ProjectManage_ZS/REST/ProjectManageREST.svc'
,
};
var
_templ
=
_urlModuleTempl
[
_module
]
?
_urlModuleTempl
[
_module
]
:
''
;
urlArr
.
push
(
_templ
);
return
urlArr
.
join
(
'/'
);
}
else
{
if
(
[
'{host}'
,
'{protocol}'
,
'{prefix}'
,
'{ip}'
].
some
(
function
(
str
)
{
return
template
.
toLowerCase
().
indexOf
(
str
)
>=
0
;
})
)
{
return
template
.
replace
(
/
\{
host
\}
/gi
,
urlArr
.
join
(
'/'
))
.
replace
(
/
\{
protocol
\}
/gi
,
_config
.
protocol
+
'//'
)
.
replace
(
/
\{
prefix
\}
/gi
,
_config
.
prefix
||
''
)
.
replace
(
/
\{
ip
\}
/gi
,
_config
.
ip
);
}
else
if
(
template
.
indexOf
(
'http://'
)
==
0
||
template
.
indexOf
(
'https://'
)
==
0
)
{
return
template
;
}
else
{
urlArr
.
push
(
template
);
return
urlArr
.
join
(
'/'
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment