Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
c51f5397
Commit
c51f5397
authored
10 years ago
by
duminil
Browse files
Options
Download
Email Patches
Plain Diff
RegionChooser Markers are now draggable.
parent
72645e3f
master
develop
migrate_to_Java11
0.2.2
0.1.0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
website/polygon.js
+43
-28
website/polygon.js
with
43 additions
and
28 deletions
+43
-28
website/polygon.js
+
43
-
28
View file @
c51f5397
...
@@ -7,11 +7,9 @@ function PolygonCreator(map) {
...
@@ -7,11 +7,9 @@ function PolygonCreator(map) {
this
.
map
=
map
;
this
.
map
=
map
;
this
.
pen
=
new
Pen
(
this
.
map
);
this
.
pen
=
new
Pen
(
this
.
map
);
var
thisOjb
=
this
;
var
thisOjb
=
this
;
proj4
.
defs
(
"
EPSG:31467
"
,
proj4
.
defs
(
"
EPSG:31467
"
,
"
+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0
"
"
+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0
"
+
"
+ellps=bessel +datum=potsdam +units=m +no_defs
"
);
// http://spatialreference.org/ref/epsg/31467/proj4js/
+
"
+ellps=bessel +datum=potsdam +units=m +no_defs
"
);
// http://spatialreference.org/ref/epsg/31467/proj4js/
this
.
event
=
google
.
maps
.
event
.
addListener
(
thisOjb
.
map
,
'
click
'
,
function
(
event
)
{
this
.
event
=
google
.
maps
.
event
.
addListener
(
thisOjb
.
map
,
'
click
'
,
function
(
event
)
{
thisOjb
.
pen
.
draw
(
event
.
latLng
);
thisOjb
.
pen
.
draw
(
event
.
latLng
);
});
});
this
.
destroy
=
function
()
{
this
.
destroy
=
function
()
{
...
@@ -30,19 +28,20 @@ function Pen(map) {
...
@@ -30,19 +28,20 @@ function Pen(map) {
this
.
polyline
=
null
;
this
.
polyline
=
null
;
this
.
polygon
=
null
;
this
.
polygon
=
null
;
this
.
currentDot
=
null
;
this
.
currentDot
=
null
;
this
.
i
=
0
;
this
.
draw
=
function
(
latLng
)
{
this
.
draw
=
function
(
latLng
)
{
if
(
null
!=
this
.
polygon
)
{
if
(
null
!=
this
.
polygon
)
{
alert
(
'
Click Reset to draw another
'
);
alert
(
'
Click Reset to draw another
'
);
}
else
{
}
else
{
if
(
this
.
currentDot
!=
null
&&
this
.
listOfDots
.
length
>
1
if
(
this
.
currentDot
!=
null
&&
this
.
listOfDots
.
length
>
1
&&
this
.
currentDot
==
this
.
listOfDots
[
0
])
{
&&
this
.
currentDot
==
this
.
listOfDots
[
0
])
{
this
.
drawPolygon
(
this
.
listOfDots
);
this
.
drawPolygon
(
this
.
listOfDots
);
this
.
refreshInfo
();
this
.
refreshInfo
();
}
else
{
}
else
{
if
(
null
!=
this
.
polyline
)
{
if
(
null
!=
this
.
polyline
)
{
this
.
polyline
.
remove
();
this
.
polyline
.
remove
();
}
}
var
dot
=
new
Dot
(
latLng
,
this
.
map
,
this
);
var
dot
=
new
Dot
(
latLng
,
this
.
i
,
this
.
map
,
this
);
this
.
i
+=
1
;
this
.
listOfDots
.
push
(
dot
);
this
.
listOfDots
.
push
(
dot
);
this
.
refreshInfo
();
this
.
refreshInfo
();
if
(
this
.
listOfDots
.
length
>
1
)
{
if
(
this
.
listOfDots
.
length
>
1
)
{
...
@@ -53,7 +52,6 @@ function Pen(map) {
...
@@ -53,7 +52,6 @@ function Pen(map) {
}
}
this
.
drawPolygon
=
function
(
listOfDots
,
color
,
des
,
id
)
{
this
.
drawPolygon
=
function
(
listOfDots
,
color
,
des
,
id
)
{
this
.
polygon
=
new
Polygon
(
listOfDots
,
this
.
map
,
this
,
color
,
des
,
id
);
this
.
polygon
=
new
Polygon
(
listOfDots
,
this
.
map
,
this
,
color
,
des
,
id
);
// this.deleteMis();
}
}
this
.
deleteMis
=
function
()
{
this
.
deleteMis
=
function
()
{
$
.
each
(
this
.
listOfDots
,
function
(
index
,
value
)
{
$
.
each
(
this
.
listOfDots
,
function
(
index
,
value
)
{
...
@@ -65,13 +63,6 @@ function Pen(map) {
...
@@ -65,13 +63,6 @@ function Pen(map) {
this
.
polyline
=
null
;
this
.
polyline
=
null
;
}
}
}
}
this
.
cancel
=
function
()
{
if
(
null
!=
this
.
polygon
)
{
(
this
.
polygon
.
remove
());
}
this
.
polygon
=
null
;
this
.
deleteMis
();
}
this
.
setCurrentDot
=
function
(
dot
)
{
this
.
setCurrentDot
=
function
(
dot
)
{
this
.
currentDot
=
dot
;
this
.
currentDot
=
dot
;
}
}
...
@@ -103,40 +94,62 @@ function Pen(map) {
...
@@ -103,40 +94,62 @@ function Pen(map) {
var
n
=
listOfDots
.
length
;
var
n
=
listOfDots
.
length
;
for
(
var
i
=
0
;
i
<
n
;
i
++
)
{
for
(
var
i
=
0
;
i
<
n
;
i
++
)
{
var
latLng
=
listOfDots
[
i
].
latLng
;
var
latLng
=
listOfDots
[
i
].
latLng
;
var
gk3_coords
=
proj4
(
fromProjection
,
toProjection
,
[
var
gk3_coords
=
proj4
(
fromProjection
,
toProjection
,
[
latLng
.
lng
(),
latLng
.
lat
()
]);
latLng
.
lng
(),
latLng
.
lat
()
]);
xs
.
push
(
gk3_coords
[
0
]
-
3500000
);
xs
.
push
(
gk3_coords
[
0
]
-
3500000
);
ys
.
push
(
gk3_coords
[
1
]
-
5000000
);
ys
.
push
(
gk3_coords
[
1
]
-
5000000
);
data
+=
"
(
"
+
(
gk3_coords
.
toString
()
+
"
)<br/>
"
);
data
+=
"
(
"
+
(
gk3_coords
.
toString
()
+
"
)<br/>
"
);
}
}
if
(
n
>
2
)
{
if
(
n
>
2
)
{
data
+=
"
<br/>
\n
Area :
"
data
+=
"
<br/>
\n
Area :
"
+
(
Math
.
round
(
polygonArea
(
xs
,
ys
)
/
1000
)
/
10
).
toString
()
+
"
ha<br/>
"
;
+
(
Math
.
round
(
polygonArea
(
xs
,
ys
)
/
1000
)
/
10
).
toString
()
+
"
ha<br/>
"
;
}
}
return
data
;
return
data
;
}
this
.
updateDot
=
function
(
marker
)
{
var
old_dot
=
this
.
listOfDots
[
marker
.
zIndex
];
old_dot
.
setLatLng
(
marker
.
getPosition
());
this
.
polyline
.
remove
();
this
.
polyline
=
new
Line
(
this
.
listOfDots
,
this
.
map
);
this
.
polyline
if
(
null
!=
this
.
polygon
)
{
(
this
.
polygon
.
remove
());
this
.
polygon
=
null
;
this
.
drawPolygon
(
this
.
listOfDots
);
}
this
.
refreshInfo
();
}
}
}
}
function
Dot
(
latLng
,
map
,
pen
)
{
function
Dot
(
latLng
,
i
,
map
,
pen
)
{
this
.
latLng
=
latLng
;
this
.
latLng
=
latLng
;
this
.
parent
=
pen
;
this
.
parent
=
pen
;
this
.
markerObj
=
new
google
.
maps
.
Marker
({
this
.
markerObj
=
new
google
.
maps
.
Marker
({
position
:
this
.
latLng
,
position
:
this
.
latLng
,
// draggable: true,
draggable
:
true
,
map
:
map
map
:
map
,
zIndex
:
i
});
});
this
.
addListener
=
function
()
{
this
.
addListener
=
function
()
{
var
parent
=
this
.
parent
;
var
parent
=
this
.
parent
;
var
thisMarker
=
this
.
markerObj
;
var
thisMarker
=
this
.
markerObj
;
var
thisDot
=
this
;
var
thisDot
=
this
;
google
.
maps
.
event
.
addListener
(
thisMarker
,
'
click
'
,
function
()
{
google
.
maps
.
event
.
addListener
(
thisMarker
,
'
click
'
,
function
()
{
// console.log("CLICKED");
parent
.
setCurrentDot
(
thisDot
);
parent
.
setCurrentDot
(
thisDot
);
parent
.
draw
(
thisMarker
.
getPosition
());
parent
.
draw
(
thisMarker
.
getPosition
());
});
});
}
}
this
.
addListener
();
this
.
addListener
();
this
.
addListener
=
function
()
{
var
parent
=
this
.
parent
;
var
thisMarker
=
this
.
markerObj
;
var
thisDot
=
this
;
google
.
maps
.
event
.
addListener
(
thisMarker
,
'
drag
'
,
function
()
{
// console.log("DRAGGED");
parent
.
updateDot
(
thisMarker
);
});
}
this
.
addListener
();
this
.
getLatLng
=
function
()
{
this
.
getLatLng
=
function
()
{
return
this
.
latLng
;
return
this
.
latLng
;
}
}
...
@@ -146,6 +159,9 @@ function Dot(latLng, map, pen) {
...
@@ -146,6 +159,9 @@ function Dot(latLng, map, pen) {
this
.
remove
=
function
()
{
this
.
remove
=
function
()
{
this
.
markerObj
.
setMap
(
null
);
this
.
markerObj
.
setMap
(
null
);
}
}
this
.
setLatLng
=
function
(
latLng
)
{
this
.
latLng
=
latLng
;
}
}
}
function
Line
(
listOfDots
,
map
)
{
function
Line
(
listOfDots
,
map
)
{
...
@@ -207,10 +223,9 @@ function Polygon(listOfDots, map, pen, color) {
...
@@ -207,10 +223,9 @@ function Polygon(listOfDots, map, pen, color) {
}
}
this
.
addListener
=
function
()
{
this
.
addListener
=
function
()
{
var
thisPolygon
=
this
.
polygonObj
;
var
thisPolygon
=
this
.
polygonObj
;
google
.
maps
.
event
.
addListener
(
thisPolygon
,
'
rightclick
'
,
google
.
maps
.
event
.
addListener
(
thisPolygon
,
'
rightclick
'
,
function
(
event
)
{
function
(
event
)
{
return
false
;
return
false
;
});
});
}
}
this
.
addListener
();
this
.
addListener
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Snippets