forked from josefzamrzla/JTSK_Converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
160 lines (144 loc) · 3.83 KB
/
test.html
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="http://api4.mapy.cz/loader.js"></script>
<script type="text/javascript">Loader.load();</script>
<script type="text/javascript" src="src/Converter.js"></script>
</head>
<body>
<div>
<h1>JTSK_Converter test page</h1>
<select id="selectAddress" onchange="showMap(this.value)">
<option value="-1">select address</option>
</select>
</div>
<div id="m" style="width:500px;height:500px;"></div>
<script type="text/javascript">
// some random addresses from cuzk.cz
var addresses = [
// Prague
{
address: "Kosmická 739/5, Praha 4",
x: 1050242.27,
y: 735765.68
},
{
address: "Lipovická 143/19, Praha 4",
x: 1053432.57,
y: 740992.28
},
{
address: "U Pernikářky 1520/11, Praha 5",
x: 1044000.00,
y: 745909.00
},
{
address: "Svatavina 513/8, Praha 6",
x: 1041469.00,
y: 750057.00
},
{
address: "Šaldova 545/4, Praha 8",
x: 1042826.40,
y: 740251.40
},
{
address: "Splavná 996, Praha 9",
x: 1041692.68,
y: 732470.58
},
{
address: "Vrátkovská 2070/4, Praha 10",
x: 1044813.90,
y: 737591.71
},
{
address: "Kazín 173, Praha 5",
x: 1057512.37,
y: 750000.66
},
{
address: "Kamencová 593, Praha 9",
x: 1044698.00,
y: 733166.00
},
{
address: "Písnice 577, Praha 4",
x: 1054440.71,
y: 740892.17
},
// Brno
{
address: "Hlinky 148/76, Brno",
x: 1161143.55,
y: 599939.33
},
{
address: "Zeiberlichova 75/34, Brno",
x: 1154445.35,
y: 596395.86
},
{
address: "Gellnerova 567/39, Brno",
x: 1158865.60,
y: 602047.20
},
{
address: "Podzimní 666/30, Brno",
x: 1158075.00,
y: 594489.81
},
{
address: "Pivodova 282/11, Brno",
x: 1163700.01,
y: 592739.78
},
{
address: "Touškova 981/10, Brno",
x: 1159891.38,
y: 595666.06
},
{
address: "Mečířova 1760/2, Brno",
x: 1157608.02,
y: 599407.89
},
{
address: "Křivánky 710/34, Brno",
x: 1162003.92,
y: 603264.60
}
];
function showMap (adId)
{
var jtsk = addresses[adId];
if (!(jtsk.x && jtsk.y)) return;
var conv = new JTSK_Converter();
var wgs = conv.JTSKtoWGS84(jtsk.x, jtsk.y);
var center = SMap.Coords.fromWGS84(wgs.lon, wgs.lat);
var m = new SMap(JAK.gel("m"), center, 16);
m.addDefaultLayer(SMap.DEF_BASE).enable();
m.addDefaultControls();
var layer = new SMap.Layer.Marker();
m.addLayer(layer);
layer.enable();
var options = {};
var marker = new SMap.Marker(center, "myMarker", options);
layer.addMarker(marker);
}
setTimeout(function () {
var selectElm = document.getElementById('selectAddress');
for (var i = 0; i < addresses.length; i++){
var opt = document.createElement('option');
opt.value = i;
opt.innerHTML = addresses[i].address;
selectElm.appendChild(opt);
}
// initial display
selectElm.value = 0;
showMap(0);
});
</script>
</body>
</html>