I need to locate my self in my web app. I am using google maps to pin my location. The problem i have is with function that returns my current location:
function setLocation() {
var temp = { lat: 0, lng: 0 };
navigator.geolocation.getCurrentPosition(function (position, temp) {
//here is all ok, temp.lat and tem.lng are assigned correctly
temp.lat = position.coords.latitude;
temp.lng = position.coords.longitude;
});
//here temp.lat and temp.lng are again 0
return temp;
}
I put some comments in my code which describe the problem. What am I doing wrong? Thanks for reading this. p.s. I am new at java script.