Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
5af70bab
Commit
5af70bab
authored
Dec 22, 2014
by
duminil
Browse files
Repair small RegionChooser bug.
parent
16885631
Changes
1
Hide whitespace changes
Inline
Side-by-side
website/polygon.js
View file @
5af70bab
...
@@ -7,9 +7,11 @@ function PolygonCreator(map) {
...
@@ -7,9 +7,11 @@ 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
"
,
"
+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0
"
proj4
.
defs
(
"
EPSG:31467
"
,
+
"
+ellps=bessel +datum=potsdam +units=m +no_defs
"
);
// http://spatialreference.org/ref/epsg/31467/proj4js/
"
+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0
"
this
.
event
=
google
.
maps
.
event
.
addListener
(
thisOjb
.
map
,
'
click
'
,
function
(
event
)
{
+
"
+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
)
{
thisOjb
.
pen
.
draw
(
event
.
latLng
);
thisOjb
.
pen
.
draw
(
event
.
latLng
);
});
});
this
.
destroy
=
function
()
{
this
.
destroy
=
function
()
{
...
@@ -33,7 +35,8 @@ function Pen(map) {
...
@@ -33,7 +35,8 @@ function Pen(map) {
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
&&
this
.
currentDot
==
this
.
listOfDots
[
0
])
{
if
(
this
.
currentDot
!=
null
&&
this
.
listOfDots
.
length
>
1
&&
this
.
currentDot
==
this
.
listOfDots
[
0
])
{
this
.
drawPolygon
(
this
.
listOfDots
);
this
.
drawPolygon
(
this
.
listOfDots
);
this
.
refreshInfo
();
this
.
refreshInfo
();
}
else
{
}
else
{
...
@@ -94,13 +97,16 @@ function Pen(map) {
...
@@ -94,13 +97,16 @@ 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
,
[
latLng
.
lng
(),
latLng
.
lat
()
]);
var
gk3_coords
=
proj4
(
fromProjection
,
toProjection
,
[
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 :
"
+
(
Math
.
round
(
polygonArea
(
xs
,
ys
)
/
1000
)
/
10
).
toString
()
+
"
ha<br/>
"
;
data
+=
"
<br/>
\n
Area :
"
+
(
Math
.
round
(
polygonArea
(
xs
,
ys
)
/
1000
)
/
10
).
toString
()
+
"
ha<br/>
"
;
}
}
return
data
;
return
data
;
}
}
...
@@ -113,8 +119,10 @@ function Pen(map) {
...
@@ -113,8 +119,10 @@ function Pen(map) {
this
.
polygon
=
null
;
this
.
polygon
=
null
;
this
.
drawPolygon
(
this
.
listOfDots
);
this
.
drawPolygon
(
this
.
listOfDots
);
}
}
this
.
polyline
.
remove
();
if
(
null
!=
this
.
polyline
)
{
this
.
polyline
=
new
Line
(
this
.
listOfDots
,
this
.
map
);
this
.
polyline
.
remove
();
this
.
polyline
=
new
Line
(
this
.
listOfDots
,
this
.
map
);
}
this
.
refreshInfo
();
this
.
refreshInfo
();
}
}
}
}
...
@@ -222,9 +230,10 @@ function Polygon(listOfDots, map, pen, color) {
...
@@ -222,9 +230,10 @@ 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
'
,
function
(
event
)
{
google
.
maps
.
event
.
addListener
(
thisPolygon
,
'
rightclick
'
,
return
false
;
function
(
event
)
{
});
return
false
;
});
}
}
this
.
addListener
();
this
.
addListener
();
}
}
...
...
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