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
72645e3f
Commit
72645e3f
authored
10 years ago
by
duminil
Browse files
Options
Download
Email Patches
Plain Diff
Refresh after each point for RegionChooser.
parent
138dffec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
website/polygon.js
+46
-41
website/polygon.js
with
46 additions
and
41 deletions
+46
-41
website/polygon.js
+
46
-
41
View file @
72645e3f
...
@@ -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
"
,
"
+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
()
{
...
@@ -32,19 +34,17 @@ function Pen(map) {
...
@@ -32,19 +34,17 @@ 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
);
$
(
'
#dataPanel
'
).
empty
();
this
.
refreshInfo
();
$
(
'
#dataPanel
'
).
append
(
"
WGS84 Coordinates<br/>
"
);
$
(
'
#dataPanel
'
).
append
(
this
.
getWGS84Data
()
+
"
<br/>
\n
"
);
$
(
'
#dataPanel
'
).
append
(
"
GSK3 Coordinates<br/>
"
);
$
(
'
#dataPanel
'
).
append
(
this
.
getGSK3DataAndArea
());
}
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
.
map
,
this
);
this
.
listOfDots
.
push
(
dot
);
this
.
listOfDots
.
push
(
dot
);
this
.
refreshInfo
();
if
(
this
.
listOfDots
.
length
>
1
)
{
if
(
this
.
listOfDots
.
length
>
1
)
{
this
.
polyline
=
new
Line
(
this
.
listOfDots
,
this
.
map
);
this
.
polyline
=
new
Line
(
this
.
listOfDots
,
this
.
map
);
}
}
...
@@ -53,7 +53,7 @@ function Pen(map) {
...
@@ -53,7 +53,7 @@ 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();
}
}
this
.
deleteMis
=
function
()
{
this
.
deleteMis
=
function
()
{
$
.
each
(
this
.
listOfDots
,
function
(
index
,
value
)
{
$
.
each
(
this
.
listOfDots
,
function
(
index
,
value
)
{
...
@@ -79,39 +79,43 @@ function Pen(map) {
...
@@ -79,39 +79,43 @@ function Pen(map) {
return
this
.
listOfDots
;
return
this
.
listOfDots
;
}
}
this
.
getWGS84Data
=
function
()
{
this
.
getWGS84Data
=
function
()
{
if
(
this
.
polygon
!=
null
)
{
var
data
=
""
;
var
data
=
""
;
var
paths
=
this
.
polygon
.
getPlots
();
for
(
var
i
=
0
;
i
<
this
.
getListOfDots
().
length
;
i
++
)
{
var
xs
=
[];
data
+=
this
.
getListOfDots
()[
i
].
latLng
+
"
<br/>
"
;
var
ys
=
[];
}
paths
.
getAt
(
0
).
forEach
(
function
(
value
,
index
)
{
data
+=
(
value
.
toString
()
+
"
<br/>
"
);
});
return
data
;
return
data
;
}
else
{
return
null
;
}
}
this
.
refreshInfo
=
function
()
{
$
(
'
#dataPanel
'
).
empty
();
$
(
'
#dataPanel
'
).
append
(
"
WGS84 Coordinates<br/>
"
);
$
(
'
#dataPanel
'
).
append
(
this
.
getWGS84Data
()
+
"
<br/>
\n
"
);
$
(
'
#dataPanel
'
).
append
(
"
GSK3 Coordinates<br/>
"
);
$
(
'
#dataPanel
'
).
append
(
this
.
getGSK3DataAndArea
());
}
}
this
.
getGSK3DataAndArea
=
function
(
referenceSystem
)
{
this
.
getGSK3DataAndArea
=
function
(
referenceSystem
)
{
if
(
this
.
polygon
!=
null
)
{
var
data
=
""
;
var
data
=
""
;
var
paths
=
this
.
polygon
.
getPlots
();
var
fromProjection
=
proj4
(
'
EPSG:4326
'
);
var
fromProjection
=
proj4
(
'
EPSG:4326
'
);
var
toProjection
=
proj4
(
'
EPSG:31467
'
);
var
toProjection
=
proj4
(
'
EPSG:31467
'
);
var
xs
=
[];
var
xs
=
[];
var
ys
=
[];
var
ys
=
[];
paths
.
getAt
(
0
).
forEach
(
function
(
value
,
index
)
{
var
listOfDots
=
this
.
getListOfDots
();
var
gk3_coords
=
proj4
(
fromProjection
,
toProjection
,
[
value
.
lng
(),
value
.
lat
()
]);
var
n
=
listOfDots
.
length
;
for
(
var
i
=
0
;
i
<
n
;
i
++
)
{
var
latLng
=
listOfDots
[
i
].
latLng
;
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/>
"
);
});
data
+=
"
<br/>
\n
Area :
"
+
(
Math
.
round
(
polygonArea
(
xs
,
ys
)
/
1000
)
/
10
).
toString
()
+
"
ha<br/>
"
;
return
data
;
}
else
{
return
null
;
}
}
if
(
n
>
2
)
{
data
+=
"
<br/>
\n
Area :
"
+
(
Math
.
round
(
polygonArea
(
xs
,
ys
)
/
1000
)
/
10
).
toString
()
+
"
ha<br/>
"
;
}
return
data
;
}
}
}
}
...
@@ -203,7 +207,8 @@ function Polygon(listOfDots, map, pen, color) {
...
@@ -203,7 +207,8 @@ 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
'
,
function
(
event
)
{
return
false
;
return
false
;
});
});
}
}
...
...
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