I am using the following code to call up a map and display. I would like to add the the function to do a reverse geocode and print out the corresponding street address. I cannot seem to get the long/lat coords passed over to the function. How can I get the long/lat coordinates converted to a street address?
function getMyLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
displayLocation, displayError, {
enableHighAccuracy: true,
timeout: 9000
});
var watchButton = document.getElementById("watch");
watchButton.onclick = watchLocation;
var clearWatchButton = document.getElementById("clearWatch");
clearWatchButton.onclick = clearWatch;
}
else {
alert("Oops, no geolocation support");
}
}
function displayLocation(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var div = document.getElementById("location");
div.innerHTML = "You are at Latitude: " + latitude + ", Longitude: " + longitude;
div.innerHTML += " (with " + position.coords.accuracy + " meters accuracy)";
var km = computeDistance(position.coords, ourCoords);
var distance = document.getElementById("distance");
distance.innerHTML = "You are " + km + " km from the WickedlySmart HQ";
if (map == null) {
showMap(position.coords);
prevCoords = position.coords;
}
else {
var meters = computeDistance(position.coords, prevCoords) * 1000;
if (meters > 20) {
scrollMapToPosition(position.coords);
prevCoords = position.coords;
}
}
}