谷歌地图 addListener 无法正常工作 [英] google maps addListener not working properly

查看:31
本文介绍了谷歌地图 addListener 无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个单独的谷歌地图 v3 代码.只是为了在我点击它时在我的 google fusion kml 层中显示 infowindow 信息框.昨天我的代码工作正常.我没有做任何改变.但今天我的 addListner 不起作用.当我复制我的备份项目时,与代码相同.它再次工作,但明天再次发生.我的 addListener 不起作用.

i have a separate code for google maps v3. Just for show infowindow infobox in my google fusion kml layer when i click on it. Yesterday my code is work fine. i didn't make any change. but today my addListner not working. when i copy my back up project, same as code. it work again but tomorrow that happens again. My addListener not work.

这是我的代码

infoBubble = new InfoBubble({
  map: map,
  shadowStyle: 1,
  padding: 5,
  borderRadius: 4,
  arrowSize: 20,
  borderWidth: 1,
  borderColor: '#2c2c2c',
  disableAutoPan: true,
  hideCloseButton: false,
  backgroundClassName: 'phoney',
  arrowStyle: 2,
});

function get_details(mode,id,lati,lng)
  {
     $('#loading').show();
        if (xhr != null)
        {
           xhr.abort();
        }
        xhr = $.ajax({
           type: "GET",
            url: "realisasi2.php?id="+id,
           data: "m="+mode+"&id="+id,
           success: function(ret){
                ajaxres = JSON.parse(ret);
                iconpos = new google.maps.LatLng(lati,lng);
                psbchurndata = ajaxres.detail;
                var html = psbchurndata+"<i><a class='ajax' href='#' onclick=layer22("+id+","+lati+","+lng+") style='font-family: Arial;font-size: 12px; color:#00CC29;'>Lihat Datel </a></i>";
                infoBubble.setContent('<div class="infowindow"><br />'+html+'</div>');
                infoBubble.setPosition(iconpos);
                infoBubble.close();
                infoBubble.open(map);
                 $('#loading').hide();
           }
         });
  }


layer.setMap(map);   
google.maps.event.addListener(layer, 'click', function(e) { 

alert(JSON.stringify(e, null, 4)); //UNDIFINED not Working

  var lati = e.latLng['mb'];  
  var lng = e.latLng['nb'];  
  var x = e.row['id_witel'].value;
  get_details('w',e.row['id_witel'].value,lati,lng);    
});


}

感谢您的帮助

推荐答案

google.maps 没有官方"属性 mbnb.LatLng(这就是 e.latLng 的意思).这些属性将由 API 内部使用,这些属性的名称可能会在下一时刻、小时或一天发生变化.

There are no "official" properties mb and nb for a google.maps.LatLng(that's what e.latLng is) . These properties will be used internally by the API, the names of these properties may change the next moment, hour or day.

使用e.latLng

这篇关于谷歌地图 addListener 无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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