-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworking_maps6.html
202 lines (177 loc) · 6.69 KB
/
working_maps6.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
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
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps AJAX + postgres/PHP Example</title>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/dot-luv/jquery-ui.css" />
<style>
#slider-range,#SlideMax{width:400px;}
#slider-range,#time, #SlideMax, table{margin:10px;display:block;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://maps.google.com/maps/api/js?key=AIzaSyCsJ7iyDD0LNjODMeSR3PwWMUQG3iXVXBc"
type="text/javascript"></script>
<script type="text/javascript">
var startTime;
var endTime;
//<![CDATA[
var customIcons = {
source: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png'
},
destination: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png'
},
both: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_green.png'
}
};
function load() {
var submit = document.getElementById("scheduleSubmit").value;
var dateValue = document.getElementById("datepicker").value;
var cont = document.getElementById("continent").value;
var typeValue = document.getElementById("type").value;
//ip_maps.php?scheduleSubmit="+submit+"&startTime="+startTime+"&endTime="+endTime+"&date="+dateValue
var finalUrl = "working_maps6.php?Submit1="+submit+"&startTime="+startTime+"&endTime="+endTime+"&date="+dateValue+"&continent="+cont+"&type="+typeValue ;
console.log(startTime);
console.log(endTime);
console.log(dateValue)
console.log(finalUrl);
console.log(cont)
var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(38.62452, 10.18514),
zoom: 2,
mapTypeId: 'roadmap'
});
var infoWindow = new google.maps.InfoWindow;
// Change this depending on the name of your PHP file
downloadUrl(finalUrl, function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var ip_prefixes = markers[i].getAttribute("ip_prefixes");
var city_location = markers[i].getAttribute("city_location");
var isp = markers[i].getAttribute("isp");
var type = markers[i].getAttribute("type");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var html = "<b>" + ip_prefixes + "</b>" +",\n" + city_location +",\n" + isp + ",\n" + type;
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon,
shadow: icon.shadow
});
bindInfoWindow(marker, map, infoWindow, html);
}
});
}
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request,request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
//]]>
</script>
</head>
<body onload="load()">
<div id="slider-range"></div>
<span id="SlideMax"></span>
<span id="time"></span>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
$("#slider-range").slider({
range: true, min: 0, max: 2879, values: [540, 1020], step:5, slide: slideTime, change: checkMax
});
function slideTime(event, ui){
var val0 = $("#slider-range").slider("values", 0),
val1 = $("#slider-range").slider("values", 1),
minutes0 = parseInt(val0 % 60, 10),
hours0 = parseInt(val0 / 60 % 24, 10),
minutes1 = parseInt(val1 % 60, 10),
hours1 = parseInt(val1 / 60 % 24, 10);
startTime = getTime(hours0, minutes0);
endTime = getTime(hours1, minutes1);
$("#time").text(startTime + ' - ' + endTime);
}
function getTime(hours, minutes) {
//var time = null;
minutes = minutes + "";
if (minutes.length == 1) {
minutes = "0" + minutes;
}
return hours + ":" + minutes //+ " " + time;
}
function checkMax() {
var size = $("#slider-range").slider("values", 1) - $("#slider-range").slider("values", 0);
if( size >= 1435) {
$("#slider-range div")
.addClass("ui-state-error")
.removeClass("ui-widget-header");
$("#scheduleSubmit")
.attr("disabled","disabled")
.addClass("ui-state-disabled")
.removeClass("ui-state-default");
$("#SlideMax").text("Cannot be more than 24 hours");
}
else {
$("#slider-range div")
.addClass("ui-widget-header")
.removeClass("ui-state-error");
$("#scheduleSubmit")
.removeAttr("disabled")
.addClass("ui-state-default")
.removeClass("ui-state-disabled");
$("#SlideMax").text("");
}
}
slideTime();////////////////////////////////////////////////// Date starts from here!
$(function() {
$( "#datepicker" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd"
});
});
</script>
<form method="get">
<select name="Continents" id="continent">
<option value="North America">North America</option>
<option value="Asia">Asia</option>
<option value="Europe">Europe</option>
<option value="Oceania">Oceania</option>
<option value="South America">South America</option>
<option value="Africa">Africa</option>
<option value="Antartica">Antartica</option>
</select>
<br><br>
<select name="Type" id="type">
<option value="source">source</option>
<option value="destination">destination</option>
<option value="both">both</option>
</select>
<br><br>
<p>Date: <input type="text" id="datepicker" ></p>
<input type="button" name="scheduleSubmit" value="HIT" id="scheduleSubmit" class="ui-button ui-state-default ui-corner-all" onclick="load()"/>
</form>
<div id="map" style="width: 1000px; height: 800px"></div>
</body>
</html>