Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (25 sloc) 815 Bytes
This function will be able to get the current location
<script src = ""></script>
function getLocation(){
if (navigator.geolocation){
navigator.geolocation.getCurrentPostion(savePostion, postionError, {timeout:10000});
//geolocation is not supported by the browser
function positionError(error){
var errorCode = error.code;
var message = error.message;
function savePosition(position){
$_post("geolocation.php", {lat: postion.coords.latitude, lng: position.coords.longitude});
<button onclick= "getLocation(); "> Current Location</button>
You can’t perform that action at this time.