Google maps api 3 谷歌地图API V3返回异常;类型错误“;在执行geocoder.geocode时使用Internet Explorer
最近,我开发了一个Asp.net web应用程序,它使用Google Map API V3脚本来生成街景和所传递地址的全景。该代码和应用程序与Chrome、FireFox、Safari完美配合,但在Internet Explorer上我遇到了一个例外Google maps api 3 谷歌地图API V3返回异常;类型错误“;在执行geocoder.geocode时使用Internet Explorer,google-maps-api-3,Google Maps Api 3,最近,我开发了一个Asp.net web应用程序,它使用Google Map API V3脚本来生成街景和所传递地址的全景。该代码和应用程序与Chrome、FireFox、Safari完美配合,但在Internet Explorer上我遇到了一个例外 "Type Error : Object doesn't support this property or method " while executing the API's ***geocoder.geocode*** function.
"Type Error : Object doesn't support this property or method "
while executing the API's ***geocoder.geocode*** function.
我曾尝试在IE7和IE8上运行相同的程序,但都抛出了相同的错误
代码片段
问题与发布的代码无关。您确定在Chrome、Firefox和Safari的javascript控制台中没有出现错误吗?IE在抱怨什么?(可能是一个显示问题的JSFIDLE,或者一个实时链接会有所帮助)。。同样的功能在firefox和chrome上也能完美运行。。当脚本尝试执行上面详述的geocoder.geocode(..)函数时,出现了异常。它在firefox和chrome中“完美”工作的事实并不意味着没有报告javascript错误。代码非常类似于我在IE中使用的代码。如果它可以在浏览器中运行,就更容易知道发生了什么。唯一值得怀疑的是,您的变量没有用“var”声明,这将导致IE中出现问题,如果存在id为“”的HTML元素,但您没有提供足够的上下文(即您的HTML)。hei谢谢。。这确实帮助我找到了那个异常的原因。。引发异常的不是地理代码。。它是一个附加到“var”的trim()函数,包含导致异常的地址。。但是这里也有..trim()函数在firefox中运行良好。在您发布的代码中没有trim函数。对。。这不是谷歌地图api的问题。。这是关于变量的作用域和针对某个变量使用的trim()函数的问题,Internet Explorer正在对该变量引发异常。
geocoder.geocode({'address': addresstoshow}, function (results, status) {
//alert(google.maps.GeocoderStatus.OK);
if (status == google.maps.GeocoderStatus.OK) {
mapStreetView.setCenter(results[0].geometry.location);
marker = new google.maps.Marker({
position: results[0].geometry.location,
map: mapStreetView,
animation: google.maps.Animation.DROP,
title: results[0].geometry.location.description
});
marker.setAnimation(google.maps.Animation.BOUNCE);
google.maps.event.addListener(marker, 'click', toggleBounce);
panormacenter = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng());
myOptionForPanorama = {
position: panormacenter,
pov: {
heading: 34,
pitch: 10,
zoom: 1
}
};
myOptionForPlace = {
location: panormacenter,
radius: '1000',
types: ['lodging']
};