-
Notifications
You must be signed in to change notification settings - Fork 0
/
findlocation.html
90 lines (82 loc) · 2.87 KB
/
findlocation.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
<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>
<script>
$( document ).ready(function() {
var byName = $.getUrlVar('address');
//var useraddress = $.url().param('address');
//alert('hi');
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;
$( "#lat" ).html(lat );
$( "#lng" ).html(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!"
});
});
var lattxt = $('#lat').text();
var lngtxt =$('#lng').text();
var requestLocation= $.ajax({
type: "GET",
url: "/mysqlclass.php",
async: false,
data: {lat: lattxt , lng :lngtxt},
dataType: "html",
});//alert(requestLocation.responseText);
$('#nearstores').html(requestLocation.responseText);
//alert($('#lat').text())
});
$.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 id="formbody" >
<form action="findlocation.html" method="get">
<input type="text" id="address" class="tb5" name="address">
<input type="submit" class="inputbutton" value="Find">
</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 id="nearstores" ></div>
</body>
</html>