<head>
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
});
// I can do alert(marker.postion); here... but, I want that value I want in the body
</head>
我如何document.write()
身体中的var marker.position
。我可以在头部提醒它,但不能把它写到身上。我需要该值将LatLng输入数据库。
答案 0 :(得分:-1)
您可能需要将变量分配给输入字段的值或标记的innerhtml(例如span,div,...)
示例javascript代码:
document.getElementById('marker1').value = marker.position;
document.getElementById('marker2').innerHTML = marker.position;
示例html:
<input type="text" id="marker1" value=""/>
<div id="marker2"></div>