InvalidValueError:不是HTMLInputElement的实例 [英] InvalidValueError: not an instance of HTMLInputElement

查看:258
本文介绍了InvalidValueError:不是HTMLInputElement的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅供参考,我不是一个JavaScript忍者,但觉得我会成为一个,当我最近做了很多基于谷歌地图的东西。



我实现了一张地图。用户可以搜索谷歌地点并为其添加标记。有一个文本框。或者用户可以点击地图将标记放置到他要查找的地方或拖动标记。



代码保持不变。设计改变了。输入字段的ID和名称也相同。没有改变JS代码。但这件事情没有奏效。



以下是网站



Google地图产生错误。

  InvalidValueError:不是HTMLInputElement的实例

我尝试了解决方案此处
但错误仍然存​​在。



可能的原因是什么?



以下是代码:

  var map; 
var marker;
var latLngC;

函数initialize()
{
latLngC = new google.maps.LatLng(14.5800,121.0000);
var mapOptions = {
center:latLngC,
zoom:12,
mapTypeId:google.maps.MapTypeId.ROADMAP,
};

map = new google.maps.Map(document.getElementById('source_map'),
mapOptions);

var marker = new google.maps.Marker({
position:latLngC,
map:map,
draggable:true
});

google.maps.event.addListener(marker,'dragend',function(x)
{
document.getElementById('src_lat')。value = x.latLng。 lat();
document.getElementById('src_long')。value = x.latLng.lng();
document.getElementById('pickup location')。innerHTML = x.latLng.lat()+ ','+ x.latLng.lng();
var geocoder = new google.maps.Geocoder;
var infowindow = new google.maps.InfoWindow;
geocodeLatLng(geocoder,map, infowindow,x.latLng.lat(),x.latLng.lng(),'source_point');
});

//获取坐标,地址单击地图中的某个位置(源地图)
//通过Sajeev
google.maps.event.addListener(地图,'点击',函数(x)
{
document.getElementById('src_lat')。value = x.latLng.lat();
document.getElementById('src_long')。value = x.latLng .lng();
document.getElementById('pickup location')。innerHTML = x.latLng.lat()+','+ x.latLng.lng();
var geocoder = new google。 maps.Geocoder;
var infowindow = new google.maps.InfoWindow;
geocodeLatLng(geocoder,map,infowindow,x.latLng.lat(),x.latLng.lng(),'source_point') ;
});

//点击地图时添加标记
//google.maps.event.addDomListener(map,'click',addMarker);
google.maps.event.addDomListener(map,'click',function(){addMarker(map);});



var places1 = new google.maps.places.Autocomplete(document.getElementById('source_point'));
google.maps.event.addListener(places1,'place_changed',function(){
var place1 = places1.getPlace();

var src_addr = place1.formatted_address;
var src_lat = place1.geometry.location.lat();
var src_long = place1.geometry.location.lng();

var mesg1 =地址:+ src_addr;
mesg1 + =\\\
Latitude:+ src_lat;
mesg1 + =\\\
Longitude:+ src_long;
// alert(mesg1);

document.getElementById('src_lat')。value = src_lat;
document.getElementById('src_long')。value = src_long;
document.getElementById('pickup location')。innerHTML = src_lat +' ,'+ src_long;
});
//在地方添加标记更改
//google.maps.event.addDomListener(places1,'place_changed',addMarker);
google.maps.event.addDomListener(places1,'place_changed',function(){addMarker(map);});


google.maps.event.addDomListener(window,'resize',initialize);
google.maps.event.addDomListener(window,'load',initialize);

我的HTML代码如下所示:

 < form role =formid =frm_sourcename =frm_sourcemethod =POSTaction =index_action.php> 

< div class =form-group>
< label for =source_point>< h2> Pickup Address< / h2>< / label>