<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<!--meta name= "format-detection" content= "Telephone=no"/>
<meta name= "viewport" content= "Width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"-
<title> positioning </title>
<script type= "Text/javascript" src= "./js/jquery-2.0.3.min.js" ></script>
<!--<link href= "./css/style.css" rel= "stylesheet" type= "Text/css"/>-->
<script>
function getuserlocation () {
Check if the Geolocation object is supported,if so get position
if (navigator.geolocation)
navigator.geolocation.getCurrentPosition (displaylocation,displayerror);
Else
document.getElementById ("Locationdata"). Innerhtml= "Sorry-your browser doesn ' t support geolocation!";
}
function displaylocation (position) {
$.post (' process.php ', ' latitude= ' + position.coords.latitude + ' &longitude= ' + position.coords.longitude , function (d) {
Console.log (d);
var arr = json.parse (d);
alert (arr[0].name);
var x;
for (x in arr)
{
document.write (' ID: ' + arr[x].id + ' shop name: ' +arr[x].name + ' distance ' +arr[x].distance + ' address ' +arr[x].address + ' <br/> ')
}
document.getElementById ("Locationdata"). Innerhtml=arr;
});
}
function DisplayError (error) {
//get A reference to the HTML element ForWriting result
var locationelement =$ ("Locationdata");
//find out which error we have, output message accordingly
Switch (error.code) {
case error. Permission_denied:
locationelement.innerhtml= "Permission was denied";
break;
case error. Position_unavailable:
locationelement.innerhtml= "location data not available";
break;
case error. TIMEOUT:
locationelement.innerhtml= "Location request Timeout";
break;
case error. Unknown_error:
locationelement.innerhtml= "An unspecified error occurred";
break;
Default:
locationelement.innerhtml= "Who knows, what happened ...";
break;
}
}
</script>
<body>
<input type= "button" value= "Get Location" onclick= "getuserlocation ()"/>
<div id= "Locationdata" >
Location data here
</div>
</body>
<?php
/**
* Background Processing
* Nearby Branch API for McDonald's
*/
Header (' Content-type:application/json; Charset=utf-8 ');
Require "config.php";
Require "android_get_mkq_shop_controller.php";
$latitude = $_request[' latitude '); Dimension of
$latitude = 39.90403; Dimension of
$longitude = $_request[' longitude '); Longitude
$longitude = 116.4075; Longitude
$data = Get_mkq_shop ($latitude, $longitude);
$memcache = new Memcache;
if ($memcache->connect (' localhost ', 11211) && Use_memcache) {
$memcache _key = ' android_mkq_get_mkq_shop '. $latitude. ' _ '. $longitude;
if (! $data = $memcache->get ($memcache _key)) {
$data = Get_mkq_shop ($latitude, $longitude);
$memcache->set ($memcache _key, $data, false,900); Cache time mins
}
}else{
$data = Get_mkq_shop ($latitude, $longitude);
}
echo Json_encode ($data);
?>
HTML5 on the implementation of positioning function