次のコードを使用して、マップと表示を呼び出しています。逆ジオコードを実行し、対応する番地を出力する機能を追加したいと思います。関数に渡された長い/緯度の座標を取得できないようです。経度/緯度座標を住所に変換するにはどうすればよいですか?
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;
}
}
}