forked from leonardoxc/leonardoxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EXT_google_maps.php
237 lines (185 loc) · 7.71 KB
/
EXT_google_maps.php
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?
//************************************************************************
// Leonardo XC Server, http://www.leonardoxc.net
//
// Copyright (c) 2004-2010 by Andreadakis Manolis
//
// This program is free software. You can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
//
// $Id: EXT_google_maps.php,v 1.16 2010/03/15 20:57:40 manolis Exp $
//
//************************************************************************
//$module_name = basename(dirname(__FILE__));
// $moduleAbsPath=dirname(__FILE__);
// $moduleRelPath=".";
// require "config.php";
require_once dirname(__FILE__)."/EXT_config_pre.php";
require_once dirname(__FILE__)."/config.php";
$CONF_use_utf=1;
require_once dirname(__FILE__)."/EXT_config.php";
$wpLon=makeSane($_GET['lon'],1);
$wpLat=makeSane($_GET['lat'],1);
$wpName=makeSane($_GET['wpName']);
$wpID=makeSane($_GET['wpID'],1);
# martin jursa 22.06.2008: enable configuration of map type
$GMapType='G_SATELLITE_MAP';
if ( in_array( $CONF['google_maps']['default_maptype'],
array('G_NORMAL_MAP', 'G_HYBRID_MAP', 'G_PHYSICAL_MAP', 'G_SATELLITE_MAP'))) {
$GMapType= $CONF['google_maps']['default_maptype'];
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<title>Google Maps</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://maps.google.com/maps?file=api&v=2&key=<?=$CONF_google_maps_api_key ?>" type="text/javascript"></script>
<script src="<?=$moduleRelPath?>/js/AJAX_functions.js" type="text/javascript"></script>
<script src="<?=$moduleRelPath?>/js/jquery.js" type="text/javascript"></script>
<script src="<?=$moduleRelPath?>/js/google_maps/polyline.js" type="text/javascript"></script>
<style type="text/css">
<!--
body{margin:0}
-->
</style>
</head>
<body>
<div name="map" id="map" style="width: 710px; height: 420px"></div>
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible() ) {
var lat=<?= $wpLat ?>;
var lon=<?=$wpLon ?>;
var wpID=<?=$wpID?>;
// Creates a marker whose info window displays the given description
function createMarker(point, id , description, iconUrl, shadowUrl ) {
if (iconUrl){
var baseIcon = new GIcon();
var sizeFactor;
if (id==wpID) sizeFactor=1.1;
else sizeFactor=1;
baseIcon.iconSize=new GSize(24*sizeFactor,24*sizeFactor);
baseIcon.shadowSize=new GSize(42*sizeFactor,24*sizeFactor);
baseIcon.iconAnchor=new GPoint(12*sizeFactor,24*sizeFactor);
baseIcon.infoWindowAnchor=new GPoint(12*sizeFactor,0);
var newIcon = new GIcon(baseIcon, iconUrl, null,shadowUrl);
var marker = new GMarker(point,newIcon);
} else {
var marker = new GMarker(point);
}
// Show this marker's index in the info window when it is clicked
GEvent.addListener(marker, "click", function() {
getAjax('EXT_takeoff.php?op=get_info&wpID='+id,null,openMarkerInfoWindow);
});
return marker;
}
function createFlightMarker(point, id , description, iconUrl, shadowUrl ) {
if (iconUrl){
var baseIcon = new GIcon();
var sizeFactor;
if (id==wpID) sizeFactor=1.1;
else sizeFactor=1;
baseIcon.iconSize=new GSize(24*sizeFactor,24*sizeFactor);
baseIcon.shadowSize=new GSize(42*sizeFactor,24*sizeFactor);
baseIcon.iconAnchor=new GPoint(12*sizeFactor,24*sizeFactor);
baseIcon.infoWindowAnchor=new GPoint(12*sizeFactor,0);
var newIcon = new GIcon(baseIcon, iconUrl, null,shadowUrl);
var marker = new GMarker(point,newIcon);
} else {
var marker = new GMarker(point);
}
// Show this marker's index in the info window when it is clicked
GEvent.addListener(marker, "click", function() {
loadFlightTrack(id);
/*
$.ajax({ url: 'GUI_EXT_flight_info.php?op=info_short&flightID='+id, dataType: 'html', context: document.body,
success: function(data) {
flightMarkers[id].openInfoWindowHtml(data);
}
});
*/
});
return marker;
}
function loadFlightTrack(id) {
$.ajax({ url: 'EXT_flight.php?op=polylineURL&flightID='+id, dataType: 'text',
success: function(polylineURL) {
drawFlightTrack(polylineURL);
// GDownloadUrl(polylineURL, process_polyline);
}
});
}
function drawFlightTrack(polylineURL) {
$.ajax({ url: polylineURL, dataType: 'text',
success: function(polylineStr) {
do_process_waypoints=false;
process_polyline(polylineStr);
}
});
}
function openFlightInfoWindow(htmlResult) {
//var results= eval("(" + jsonString + ")");
//var i=results.flightID;
//var html=results.html;
//flightMarkers[i].openInfoWindowHtml(html);
flightMarkers[i].openInfoWindowHtml(htmlResult);
}
function openMarkerInfoWindow(jsonString) {
var results= eval("(" + jsonString + ")");
var i=results.takeoffID;
var html=results.html;
takeoffMarkers[i].openInfoWindowHtml(html);
}
var map = new GMap2(document.getElementById("map"), {mapTypes:[G_NORMAL_MAP,G_HYBRID_MAP,G_PHYSICAL_MAP,G_SATELLITE_MAP]});
// map.addControl(new GSmallMapControl());
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GOverviewMapControl(new GSize(200,120)));
var takeoffPoint= new GLatLng(lat, lon) ;
map.setCenter(takeoffPoint , 8, <?=$GMapType?>);
var iconUrl = "http://maps.google.com/mapfiles/kml/pal2/icon5.png";
var shadowUrl = "http://maps.google.com/mapfiles/kml/pal2/icon5s.png";
// var takeoffMarker= createMarker(takeoffPoint,"<?= $wpName ?>",iconUrl,shadowUrl);
// map.addOverlay(takeoffMarker);
var takeoffMarkers=[];
function drawTakeoffs(jsonString){
var results= eval("(" + jsonString + ")");
// document.writeln(results.waypoints.length);
for(i=0;i<results.waypoints.length;i++) {
var takeoffPoint= new GLatLng(results.waypoints[i].lat, results.waypoints[i].lon) ;
if (results.waypoints[i].id ==wpID ) {
var iconUrl = "http://maps.google.com/mapfiles/kml/pal2/icon5.png";
var shadowUrl = "http://maps.google.com/mapfiles/kml/pal2/icon5s.png";
} else if (results.waypoints[i].type<1000) {
var iconUrl = "http://maps.google.com/mapfiles/kml/pal3/icon21.png";
var shadowUrl = "http://maps.google.com/mapfiles/kml/pal3/icon21s.png";
} else {
var iconUrl = "http://maps.google.com/mapfiles/kml/pal2/icon13.png";
var shadowUrl = "http://maps.google.com/mapfiles/kml/pal2/icon13s.png";
}
var takeoffMarker= createMarker(takeoffPoint,results.waypoints[i].id, results.waypoints[i].name,iconUrl,shadowUrl);
takeoffMarkers[takeoffPoint,results.waypoints[i].id] = takeoffMarker;
map.addOverlay(takeoffMarker);
}
}
var flightMarkers=[];
function drawFlights(jsonString){
var results= eval("(" + jsonString + ")");
// document.writeln(results.flights.length);
for(i=0;i<results.flights.length;i++) {
var takeoffPoint= new GLatLng(results.flights[i].firstLat, results.flights[i].firstLon) ;
var iconUrl = "http://maps.google.com/mapfiles/kml/pal4/icon19.png";
var shadowUrl = "http://maps.google.com/mapfiles/kml/pal4/icon19s.png";
var flightMarker= createFlightMarker(takeoffPoint,results.flights[i].flightID, results.flights[i].pilotName,iconUrl,shadowUrl);
flightMarkers[results.flights[i].flightID] = flightMarker;
map.addOverlay(flightMarker);
}
}
getAjax('EXT_takeoff.php?op=get_nearest&lat='+lat+'&lon='+lon,null,drawTakeoffs);
getAjax('EXT_flight.php?op=list_flights_json&lat='+lat+'&lon='+lon+'&distance=500&from_tm=10&pilotIDview=76',null,drawFlights);
}
//]]>
</script>
</body>
</html>