-
Notifications
You must be signed in to change notification settings - Fork 1
/
einbetten.html
105 lines (81 loc) · 3.18 KB
/
einbetten.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" href="assets/css/embed.css"/>
<link rel="stylesheet" href="assets/css/tooltip.css"/>
</head>
<body>
<table border="0">
<tr>
<td>
<div class="logo"></div>
</td>
<td>
<div class="amt trn">bfe</div>
<div class="amt trn">meteoschweiz</div>
<div class="amt trn">swisstopo</div>
</td>
</tr>
</table>
<h2><span class="trn">embedTitle</span></h2>
<span class="trn"></span>
<p><b><span class="trn">embedStep1</span></b></p>
<span class="trn">embedBreite</span>: <input type="number" name="breite" id="breite" min="600" max="1500" value="650" onchange="changeSize();"><br>
<span class="trn">embedHoehe</span>: <input type="number" name="hoehe" id="hoehe" min="450" max="1500" value="450" onchange="changeSize();"><br><br>
<p><b><span class="trn">embedStep2</span></b></b></p>
<div id="map" style="width: 650px; height: 370px" onmouseleave="changeSize();"></div><br>
<!--
<p><b><span class="trn">embedStep3</span></b></p>
<button onclick="vorschau();"><span class="trn">embedVorschau</span></button><br><br>
-->
<p><b><span class="trn">embedStep4</span></b></p>
<textarea rows="6" cols="75" id="myTextarea"></textarea>
<script src="//api3.geo.admin.ch/loader.js?lang=en" type="text/javascript"></script>
<script src="assets/js/jquery-3.5.1.min.js"></script>
<script src="assets/js/jquery.translate.0.9.1.js"></script>
<script src="assets/js/permalink.js"></script>
<script src="assets/js/translations.js"></script>
<script src="assets/js/embed.js"></script>
<script>
initembed();
//Karte initialisieren
var layer1 = ga.layer.create('ch.swisstopo.pixelkarte-grau');
var layer2 = ga.layer.create('ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill');
var map = new ga.Map({
target: 'map',
layers: [layer1,layer2],
view: new ol.View({
resolution: 500
})
});
function changeSize() {
if(document.getElementById("breite").value < 600) {
document.getElementById("breite").value = 600;
}
if(document.getElementById("hoehe").value < 450) {
document.getElementById("hoehe").value = 450;
}
//Aendere Groesse des div
document.getElementById("map").style = "width: " + document.getElementById("breite").value + "px; height: " + (document.getElementById("hoehe").value - 50 - 30) + "px";
//Karte neu rendern sonst verzogen
map.updateSize();
updateTextarea();
}
function updateTextarea() {
var langs = ['de', 'fr', 'it', 'en'];
var permalink = addPermalink();
var lang = (langs.indexOf(permalink.lang) != -1) ? permalink.lang : langs[0];
var center = map.getView().getCenter();
var coordX = 2000000 + Math.round(center[0]);
var coordY = 1000000 + Math.round(center[1]);
//Textarea aktualisieren
document.getElementById("myTextarea").value =
"<iframe id='sonnendachCH' width='" + document.getElementById("breite").value + "' height='" +
document.getElementById("hoehe").value + "' src='//www.uvek-gis.admin.ch/BFE/sonnendach/loader.html?E=" + coordX + "&N=" + coordY + "&zoom=" + map.getView().getZoom() + "&lang=" + lang + "' style='outline: none; border: 0;' frameborder='0'></iframe>";
}
//Textfeld initialisieren
updateTextarea();
</script>
</body>
</html>