Google maps API:无法读取未定义的属性'__e3_' [英] Google maps API: Cannot read property '__e3_' of undefined

查看:126
本文介绍了Google maps API:无法读取未定义的属性'__e3_'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是我添加的监听器 -

  var map; 
var geocoder;
函数initialize(){
var myOptions = {
zoom:8,
center:new google.maps.LatLng(22,88),
mapTypeId:google .maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),myOptions);
}
//google.maps.event.addDomListener(window,'load',initialize);
google.maps.event.addListener(map,'click',function(event){
geocoder = new google.maps.Geocoder();
geocoder.geocode({'latLng' :event.latLng},function(results,status){

if(status == google.maps.GeocoderStatus.OK){
alert(results);
} else {
alert(由于以下原因Geocode不成功:+ status;
}
});
});

但它在控制台中产生这个错误 -

  Uncaught TypeError:无法读取未定义
的属性'__e3_'Ke
Ie
R.addListener
(匿名函数)

尝试搜索。但没有解决方案。

解决方案

将您的监听器移入初始化函数。

Here is the Listener I'm adding -

var map;
    var geocoder;
    function initialize() {
        var myOptions = {
          zoom: 8,
          center: new google.maps.LatLng(22, 88),
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
    }
    //google.maps.event.addDomListener(window, 'load', initialize);
    google.maps.event.addListener(map, 'click', function(event) {
        geocoder = new google.maps.Geocoder();
        geocoder.geocode( { 'latLng': event.latLng}, function(results, status) {

            if (status == google.maps.GeocoderStatus.OK) {
                alert(results);
            } else {
                alert("Geocode was not successful for the following reason: " + status);
            }
        });
    });

But it is generating this error in console -

Uncaught TypeError: Cannot read property '__e3_' of undefined
Ke
Ie
R.addListener
(anonymous function)

Tried searching. But got no solution.

解决方案

Move your listener into the initializer function.

这篇关于Google maps API:无法读取未定义的属性'__e3_'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆