-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocationtest.html
109 lines (97 loc) · 3.62 KB
/
locationtest.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
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/common.css">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/dropList.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="scripts/jquery.dropList.1.0.0.js"></script>
<script>
$( document ).ready(function() {
var byName = $.getUrlVar('address');
$('#dlist3').dropList({
search : true
});
var request= $.ajax({
type: "GET",
url: "http://maps.googleapis.com/maps/api/geocode/json",
async: false,
data: {address: byName , sensor :"false"},
dataType: "json",
});
request.done(function( msg ) {
var lat = msg.results[0].geometry.location.lat;
var longitude = msg.results[0].geometry.location.lng;
var formatted_address =msg.results[0].formatted_address;
//alert(msg.results.geometry.location.lat);
$( "#lat" ).html( "Latitude:"+lat );
$( "#lng" ).html("Longitude:"+longitude );
//window.location ="displaylocation.php?lat="+lat+"&lng="+longitude+"&radius=100";
$( "#formattedAddress" ).html("Your Location:"+formatted_address );
var coords = new google.maps.LatLng(lat,longitude);
var mapOptions = { zoom:15,
center:coords,
mapTypeControl:false,
navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL},
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);
var marker = new google.maps.Marker({ position:coords,
map:map,
title:"Your current location!"
});
});
});
$.extend({
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
getUrlVar: function(name){
return $.getUrlVars()[name];
}
});
</script>
</head>
<body>
<div class="container">
<div id="formbody" >
<form action="findlocation.html" method="get">
<table>
<td>
<input type="text" id="address" class="tb5" name="address"></td><td>
<div id="dwrapper3" >
<select id="dlist3" >
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
<option value="Hyndai">Hyndai</option>
<option value="Honda">Honda</option>
<option value="Ferrari">Ferrari</option>
<option value="Ducati">Ducati</option>
<option value="Tesla">Tesla</option>
<option value="volkswagon">volkswagon</option>
<option value="Mclaren">Mclaren</option>
</select>
</div></td><td>
<input type="submit" class="inputbutton" value="Find"></td>
</table>
</form>
</div>
<div id="formattedAddress" class="formattedAddress"></div>
<div id="lat" class="lat"></div>
<div id="lng" class="lng"></div>
<div id="map_canvas" style="width:600px;height:400px;"></div>
</div>
</body>
</html>