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

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

问题描述

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



这是我的代码

  infoBubble = new InfoBubble({
map:
shadowStyle:1,
padding:5,
borderRadius:4,
arrowSize:20,
borderWidth:1,
borderColor:'#2c2c2c',
disableAutoPan:true,
hideCloseButton:false,
backgroundClassName:'phoney',
arrowStyle:2,
});
$ b $ function get_details(mode,id,lati,lng)
{
$('#loading')。show();
if(xhr!= null)
{
xhr.abort();

xhr = $ .ajax({
类型: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);
});


}

感谢任何帮助

解决方案

没有官方属性 mb nb 对于 google.maps.LatLng (这就是 e.latLng 是)。这些属性将在API内部使用,这些属性的名称可能会改变下一时刻,小时或天。



要检索经度和纬度,请使用<$ e.latLng lat() lng() p>

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.

here's my code

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);    
});


}

thank's for any help

解决方案

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.

To retrieve latitude and longitude use the methods lat() and lng() of e.latLng

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

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