Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Html中调用Google map API Javascript的变量?_Javascript_Html_Google Maps - Fatal编程技术网

如何在Html中调用Google map API Javascript的变量?

如何在Html中调用Google map API Javascript的变量?,javascript,html,google-maps,Javascript,Html,Google Maps,我知道这是一个非常基本的编程问题,但我想用marker.position作为HTML格式中隐藏输入的值。我试着使用document.getElementById(“position”),但它不起作用,我不知道怎么做。如果有人能帮我,我会非常感激的。以下是我的相关代码行: function placeMarker(location) { var marker = new google.maps.Marker({ position: location, draggable

我知道这是一个非常基本的编程问题,但我想用marker.position作为HTML格式中隐藏输入的值。我试着使用document.getElementById(“position”),但它不起作用,我不知道怎么做。如果有人能帮我,我会非常感激的。以下是我的相关代码行:

function placeMarker(location) {
  var marker = new google.maps.Marker({
      position: location,
      draggable:true,
      animation:google.maps.Animation.DROP,
      map: map,
      icon: image
  });

 var Makepoint = google.maps.event.addListener(map, 'click', function(event) {
     placeMarker(event.latLng); 

    google.maps.event.removeListener(Makepoint);
  });
我的html是

<input class="text" name="here" value="posit" type="hidden">

它正在使用document.getElementById和他的小片段:

document.getElementById("hidden").value = "Your Value";
当然,您的HTML必须是这样的

<input id="hidden" class="text" name="here" value="posit" type="hidden" />

伟大的非常感谢你的回答。现在它工作了没问题,很高兴我能帮忙:)
document.getElementById("hidden").value = marker.position;