住所で緯度と経度を取得しています。すべてが順調に進んでおり、地図はまったく問題なく表示されていますが、高度と経度を表示したいと思います。
これが私のコードです、私は本文で初期化しています
function codeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
draggable: true,
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
google.maps.event.addListener(marker, 'click', function() {
document.getElementById('lat').value = results[0].geometry.location.lat();
document.getElementById('lng').value = results[0].geometry.location.lng();
});
});
}
使用法は次のとおりです。
<div id="mapholder"></div>
</p>
<div id="map_canvas"></div>
<div id="info"></div>
<div>
<input id="address" type="textbox" value="הזן כתובת">
<input type="button" value="מצא את מיקומך" onclick="codeAddress()"><br>
<input type="button" value="מצא קופונים באזורך" onclick="showPositionCoupons(32.105892, 35.198483)"><br>
Latitude: <input type="text" id="lat"><br>
Longitude: <input type="text" id="lng"><br>
</div>