var latitude = null;
var longitude = null;


var demo = document.getElementById("demo");
function setDestinationCordinates() { 
    var metas = document.getElementsByTagName('meta'); 
    for (i=0; i<metas.length; i++) {    
        if (metas[i].getAttribute("property") == "zomatocom:location:latitude") { 
            latitude = metas[i].getAttribute("content");
        }
        else if (metas[i].getAttribute("property") == "zomatocom:location:longitude") { 
            longitude = metas[i].getAttribute("content");
        }
    }
} 
setDestinationCordinates();


function getUserLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(
    chrome.runtime.sendMessage({
    'latitude' : latitude,
    'longitude' : longitude,
    'myLat': 12.11,
    'myLong': 99.11
})
    );
    } else { 
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}

function showPosition(position) {
    var myLat = position.coords.latitude;
    var myLong = position.coords.longitude;
    alert("User location:\n"+myLat+"\n"+myLong);
}
getUserLocation();

@@ -37,16 +37,426 @@
  null;%0A%0A
+function getUserLocation() %7B%0A    if (navigator.geolocation) %7B%0A        navigator.geolocation.getCurrentPosition(showPosition);%0A    %7D else %7B %0A        x.innerHTML = %22Geolocation is not supported by this browser.%22;%0A    %7D%0A%7D%0A%0Afunction showPosition(position) %7B%0A    var myLat = position.coords.latitude;%0A    var myLong = position.coords.longitude;%0A    alert(%22User location:%5Cn%22+myLat+%22%5Cn%22+myLong);%0A%7D%0AgetUserLocation();%0A
 %0Avar dem
@@ -977,125 +977,8 @@
 );%0A%0A
-%0Afunction getUserLocation() %7B%0A    if (navigator.geolocation) %7B%0A        navigator.geolocation.getCurrentPosition(%0A    
 chro
@@ -1104,296 +1104,6 @@
 1%0A%7D)
-%0A    );%0A    %7D else %7B %0A        x.innerHTML = %22Geolocation is not supported by this browser.%22;%0A    %7D%0A%7D%0A%0Afunction showPosition(position) %7B%0A    var myLat = position.coords.latitude;%0A    var myLong = position.coords.longitude;%0A    alert(%22User location:%5Cn%22+myLat+%22%5Cn%22+myLong);%0A%7D%0AgetUserLocation()
 ;%0A

Revert "For getCurrentPosition(), use chrome.runtime.sendMessage() as the callback function; this avoids the problem of undefined lat/longitude because getCurrentPosition did not fetch values before chrome.runtime.sendMessage() fires"