-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathol.html
158 lines (146 loc) · 6.84 KB
/
ol.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
<!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 type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.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 type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.min.js">
</script>
<script src="http://openlayers.org/api/OpenLayers.js" type="text/javascript">
</script>
<!--script src="lib/Google.js" type="text/javascript">
</script>
<script src="lib/v3.js" type="text/javascript">
</script-->
<script src="lib/OpenLayers.Format.KMLTimeline.js" type="text/javascript">
</script>
<script src="timeline.js" type="text/javascript">
</script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&v=3.6">
</script>
<script type="text/javascript" src="https://www.google.com/jsapi">
</script>
<script src="src/googleearthforol.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
});
gsat.events.register( 'loadstart', gsat, function(){console.log('loadstart')});
gsat.events.register( 'visibilitychanged', gsat, function(){console.log('visibilitychanged')});
gsat.events.register( 'added', gsat, function(){console.log('added')});
gsat.events.register( 'loadend', gsat, function(){console.log('loadend')});
map.addLayers([gsat]);
// map.setBaseLayer(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);
google.maps.event.addListenerOnce( gsat.mapObject, 'resize', function(){
// layer.events.register( 'loadend', gsat, function(){
console.log('load Google Earth')
// do something only the first time the map is loaded
try
{
googleEarth = new GoogleEarth(map, document.getElementById('earth'));
}
catch( e )
{
// Google Earth hasn't been loaded or supported on this system
alert(e);
return;
}
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,
onFeatureInsert: function(){
googleEarth.refresh_();
}
});
GoogleEarth.trackOverlays_( timeline.display_layer );
googleEarth.map_.setMapTypeId(GoogleEarth.MAP_TYPE_ID);
timeline.cumulative = true;
$("#cumulative").attr("checked", "checked");
$.ajax({
type: "GET",
url: "data/nzemperor.kml",
dataType: "xml",
success: function(data){
$("#status").text("Data loaded");
timeline.initTimeline(data);
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus + ' ' + errorThrown);
}
});
});
}
function toggleCumulative(){
if ($("#cumulative").attr("checked")) {
timeline.cumulative = true;
}
else {
timeline.cumulative = false;
}
timeline.update();
}
$(document).ready(function(){
google.load('earth', '1', {
"callback": init
});
});
</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 id="earth" class="smallmap" style="width:48%">
</div>
</div>
</body>
</html>