elie kazad
Joined
Activity
Great Video Chris, I would like to know how can i get each users position (lon and lat) "Using HTML Geolocation"
here is my codes in the app.js
var x = document.getElementById("location");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.watchPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"
Longitude: " + position.coords.longitude;
}
here is the codes in my controller.erb
def location
if current_user = find_driver
respond_to do |format|
format.js {render :application =>"getLocation();" }
end
end
end