-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeoLocationPanel.js
78 lines (78 loc) · 3.48 KB
/
GeoLocationPanel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"use strict";
/***********************************************************************/
var mylocation = { lat: new Angle(0), lng: new Angle(0) };
var TheLocation = new GeoLocation();
/***********************************************************************/
function updateCoordSelect(axis) {
DOM$.i(axis + "deg").selectedIndex = mylocation[axis].get(Angle.DEG);
DOM$.i(axis + "min").selectedIndex = mylocation[axis].get(Angle.MIN);
DOM$.i(axis + "sec").selectedIndex = mylocation[axis].get(Angle.SEC);
DOM$.i(axis + "dir").selectedIndex = mylocation[axis].get(Angle.DIR);
DOM$.i(axis + "dec").value = mylocation[axis].get(Angle.DEC).toFixed(6);
}
/***********************************************************************/
function updateLocationFlags() {
var temp = TheLocation.isLocationResponse();
DOM$.i("isLocationResponse").checked = temp;
DOM$.i("isLocationResponse").disabled = temp;
DOM$.i("isLocationResponseWaiting").checked = TheLocation.isLocationResponseWaiting();
}
/***********************************************************************/
TheLocation.onset = function (pos) {
mylocation.lat.dec = pos.lat;
mylocation.lng.dec = pos.lng;
updateCoordSelect("lat");
updateCoordSelect("lng");
updateLocationFlags();
updateGeoHack();
};
/***********************************************************************/
function clickCurrentLocation() {
if (DOM$.i("isLocationResponse").checked) {
TheLocation.setPosition({ lat: 0, lng: 0 });
DOM$.i("isLocationResponseWaiting").checked = true;
TheLocation.getLocation();
}
}
/***********************************************************************/
function updateGeoHack() {
const scale = 10000;
DOM$.i("GeoHack").href = "javascript:window.open('https://geohack.toolforge.org/geohack.php?params=" +
(mylocation.lat.get(Angle.DEG)) + "_" +
(mylocation.lat.get(Angle.MIN)) + "_" +
(Math.round(mylocation.lat.get(Angle.SEC))) + "_" +
((mylocation.lat.get(Angle.SIG) >= 0) ? "N" : "S") + "_" +
(mylocation.lng.get(Angle.DEG)) + "_" +
(mylocation.lng.get(Angle.MIN)) + "_" +
(Math.round(mylocation.lng.get(Angle.SEC))) + "_" +
((mylocation.lng.get(Angle.SIG) >= 0) ? "E" : "W") + "_" +
"scale:" + scale +
"', '_blank')";
DOM$.i("GeoHack").innerHTML = "GeoHack(" + (mylocation.lat.get(Angle.DEC).toFixed(6)) + "," + (mylocation.lng.get(Angle.DEC).toFixed(6)) + ")";
}
/***********************************************************************/
function changeCoordElement(axis, field) {
if (field == "dec") {
mylocation[axis].set(Angle.DEC, parseFloat(DOM$.i(axis + field).value));
updateCoordSelect(axis);
}
else {
mylocation[axis].set(eval("Angle." + field.toUpperCase()), DOM$.i(axis + field).selectedIndex);
DOM$.i(axis + "dec").value = mylocation[axis].get(Angle.DEC).toFixed(6);
}
TheLocation.setPositionAngle(mylocation);
updateLocationFlags();
updateGeoHack();
}
/***********************************************************************/
function initLocationPanel() {
DOM$.select.fillRange("latdeg", 0, 90);
DOM$.select.fillRange("latmin", 0, 59);
DOM$.select.fillRange("latsec", 0, 59);
DOM$.select.fillRange("lngdeg", 0, 180);
DOM$.select.fillRange("lngmin", 0, 59);
DOM$.select.fillRange("lngsec", 0, 59);
TheLocation.setPosition({ lat: 0, lng: 0 });
DOM$.i("isLocationResponseWaiting").checked = true;
TheLocation.getLocation();
}