Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
刘远
/
3d_dc
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
1
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
2a10e568
authored
2020-09-11 09:24:57 +0800
by
刘远
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
jikai commit
1 parent
d3efcda7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
21 deletions
src/assets/js/map/drawTool.js
src/assets/js/map/drawTool.js
View file @
2a10e56
...
...
@@ -2,50 +2,88 @@ import { loadModules } from "esri-loader";
import
mapManage
from
'./towMapObjects'
;
export
default
class
DrawTool
{
static
getInstance
()
{
mapManage
.
drawTool
||
(
mapManage
.
drawTool
=
new
this
());
loadModules
([
"esri/symbols/PictureMarkerSymbol"
,
"esri/layers/GraphicsLayer"
,
"esri/views/draw/Draw"
]).
then
((
a
)
=>
{
mapManage
.
drawTool
||
(
mapManage
.
drawTool
=
new
this
(
a
));
});
}
constructor
()
{
let
arg
=
arguments
[
0
];
this
.
view
=
mapManage
.
mapView
;
this
.
map
=
mapManage
.
mapView
.
map
;
this
.
active
=
!
1
;
this
.
polygon
=
null
;
this
.
guids
=
[];
loadModules
([
"esri/symbols/PictureMarkerSymbol"
,
"esri/layers/GraphicsLayer"
,
"esri/views/draw/Draw"
]).
then
(([
w
,
z
,
d
])
=>
{
this
.
options1
||
(
this
.
options1
=
{},
this
.
options1
.
pm
=
new
w
({
url
:
""
,
width
:
""
,
height
:
""
,
xoffset
:
0
,
yoffset
:
0
}));
this
.
map
.
add
(
this
.
graphicsLayer
=
new
z
({
id
:
"drawtool"
}));
this
.
draw
=
new
Draw
({
view
:
this
.
view
});
this
.
paths
=
[];
this
.
options1
||
(
this
.
options1
=
{},
this
.
options1
.
pm
=
{
type
:
'simple-marker'
,
color
:
[
165
,
42
,
42
,
0.7
],
width
:
"5px"
,
height
:
"5px"
});
this
.
map
.
add
(
this
.
graphicsLayer
=
new
arg
[
1
]({
id
:
"drawtool"
,
graphics
:
[]
}));
this
.
draw
=
new
arg
[
2
]({
view
:
this
.
view
});
}
activate
(
c
,
b
)
{
this
.
active
=
!
0
;
this
.
drawType
=
c
.
toUpperCase
();
this
.
callback
=
b
;
this
.
guids
=
[];
this
.
downCount
=
0
;
this
.
map
.
reorder
(
this
.
graphicsLayer
,
this
.
map
.
allLayers
.
length
-
1
);
//
this.map.reorder(this.graphicsLayer, this.map.allLayers.length - 1);
switch
(
this
.
drawType
)
{
case
"POINT1"
:
loadModules
([
"esri/Graphic"
]).
then
(([
h
,
f
])
=>
{
loadModules
([
"esri/Graphic"
,
"esri/geometry/Point"
]).
then
(([
h
,
f
])
=>
{
this
.
downCount
=
0
;
this
.
view
.
container
.
addEventListener
(
'mousedown'
,
b
=>
{
var
a
=
new
h
(
b
.
offsetX
,
b
.
offsetY
),
a
=
this
.
view
.
toMap
(
a
);
console
.
log
(
a
);
// this.graphic = new f(a, this.options1.pm, null);
// this.graphicsLayer.add(this.graphic);
// console.log('OKOKOK');
// b.stopPropagation()
let
action
=
this
.
draw
.
create
(
"point"
,
{
mode
:
"click"
});
action
.
on
(
"draw-complete"
,
event
=>
{
!
this
.
paths
.
length
&&
this
.
graphicsLayer
.
graphics
.
add
(
this
.
graphic
=
new
h
({
geometry
:
this
.
construc
({
type
:
f
,
vertices
:
event
.
vertices
}),
symbol
:
this
.
options1
.
pm
}));
this
.
paths
.
push
(
event
.
vertices
[
0
]);
this
.
callback
(
event
.
vertices
);
});
});
break
;
}
}
createPolyline
()
{
this
.
graphicsLayer
.
graphics
.
remove
(
this
.
graphic
);
loadModules
([
"esri/Graphic"
,
"esri/geometry/Polygon"
]).
then
(([
h
,
f
])
=>
{
this
.
graphic
=
new
h
({
geometry
:
this
.
construc
({
type
:
f
,
rings
:
this
.
paths
}),
symbol
:
{
type
:
"simple-line"
,
color
:
[
238
,
44
,
44
,
0.8
],
width
:
2
,
style
:
'solid'
}
});
this
.
graphicsLayer
.
graphics
.
add
(
this
.
graphic
);
});
}
deactivate
()
{
this
.
active
=
!
1
;
this
.
drawType
=
""
;
this
.
downCount
=
0
;
}
construc
(
arg
)
{
let
settings
=
{
hasZ
:
false
,
hasM
:
false
,
spatialReference
:
this
.
view
.
spatialReference
,
paths
:
arg
.
paths
,
rings
:
arg
.
rings
};
arg
.
vertices
&&
Object
.
assign
(
settings
,
{
x
:
arg
.
vertices
[
0
][
0
],
y
:
arg
.
vertices
[
0
][
1
]
});
return
new
arg
.
type
(
settings
);
}
}
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment