-
Notifications
You must be signed in to change notification settings - Fork 0
/
no_iframe.html
82 lines (77 loc) · 1.94 KB
/
no_iframe.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hikes, Climbs and Ski Tours - No Iframe Version - lienhard.io</title>
<style>
body {
padding: 0;
margin: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="//api3.geo.admin.ch/loader.js?version=4.4.2"></script>
<script src="//code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.bundle.min.js"></script>
<div id="map"></div>
<script>
let map = new ga.Map({
target: "map",
view: new ol.View({
resolution: 300,
center: [2660000, 1190000]
})
});
// Create a background/map layer.
let layer_bg = ga.layer.create("ch.swisstopo.pixelkarte-farbe");
map.addLayer(layer_bg);
// Add KML layer.
let layer_outings = new ol.layer.Vector({
source: new ol.source.Vector({
url: "/map.lienhard.io.kml",
format: new ol.format.KML({
projection: "EPSG:21781"
})
})
});
map.addLayer(layer_outings);
// Popup
let popup = new ol.Overlay({
element: $('<div title="Outing Information"></div>')[0]
});
map.addOverlay(popup);
// Display feature information.
map.on("singleclick", function(evt) {
let pixel = evt.pixel;
let coordinate = evt.coordinate;
let features = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
return feature;
});
let element = $(popup.getElement());
element.popover("dispose");
if (features) {
popup.setPosition(coordinate);
element.popover({
"placement": "top",
"animation": false,
"html": true,
"content": features.get("description")
});
element.popover("show");
}
});
// Change cursor style when hovering a feature.
map.on("pointermove", function(evt) {
let feature = map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) {
return feature;
});
map.getTargetElement().style.cursor = feature ? "pointer" : "";
});
</script>
</body>
</html>