-
Notifications
You must be signed in to change notification settings - Fork 11
/
kml.html
102 lines (92 loc) · 4.24 KB
/
kml.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.13.custom.css" type="text/css" />
<link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<script src="lib/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="lib/jquery-ui-1.8.14.custom.min.js" type="text/javascript"></script>
<script src="http://openlayers.org/api/OpenLayers.js" type="text/javascript"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="lib/OpenLayers.Format.KMLTimeline.js" type="text/javascript"></script>
<script src="timeline.js" type="text/javascript"></script>
<script type="text/javascript">
var map, timeline;
function init(){
map = new OpenLayers.Map('map');
var gsat = new OpenLayers.Layer.Google("Google Satellite", {
type: google.maps.MapTypeId.SATELLITE,
numZoomLevels: 17
});
map.addLayers([gsat]);
map.setCenter(new OpenLayers.LonLat(174.785, -41.322).
transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), 5);
var ts_funct = function(d) {
return ((new Date(d)).getTime() / 1000);
}
var in_options = {
'internalProjection': map.baseLayer.projection,
'externalProjection': new OpenLayers.Projection("EPSG:4326")
};
var kml_options_in = OpenLayers.Util.extend({
extractAttributes: true,
extractStyles: true,
extractTracks: true,
trackAttributes: true,
maxDepth: 2
}, in_options);
timeline = new OpenLayers.Timeline({map: map,
timeline: "#timeline",
name_key: "name",
date_key: "published",
date_funct: ts_funct,
format: OpenLayers.Format.KML,
format_options: kml_options_in,
timedelta: 60*60*24,
});
$.ajax({
type: "GET",
url: "data/nzemperor.kml",
dataType: "kml",
success: function(data) {
$("#status").text("Data loaded");
timeline.initTimeline(data);
}
});
}
function toggleCumulative() {
if ($("#cumulative").attr("checked")) {
timeline.cumulative = true;
}
else {
timeline.cumulative = false;
}
timeline.update();
}
$(document).ready(function() {
init();
timeline.cumulative = true;
$("#cumulative").attr("checked", "checked");
});
</script>
</head>
<body>
<h1 id="title">OpenLayers Timeline KML Demo</h1>
<div id="container">
<p>You're are seeing the timeline of <a href="data/nzemperor.kml">nzemperor.com</a> by <a href="http://www.sirtrack.com">Sirtrack</a></p>
<p id="status">Loading...</p>
<div id="controls">
<input type="button" onclick="timeline.togglePlay();" value="Play/Pause" />
<input type="button" onclick="timeline.fasterAnimation();" value="Faster" />
<input type="button" onclick="timeline.slowerAnimation();" value="Slower" />
<label for="cumulative">Cumulative</label>
<input id="cumulative" type="checkbox" onChange="toggleCumulative();" />
</div>
<div id="timeline"></div>
<div id="map" class="smallmap"></div>
</div>
</body>
</html>