javascript - 谷歌地图 addListener 无法正常工作

标签 javascript google-maps google-maps-api-3

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

这是我的代码

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.LatLng 没有“官方”属性 mbnb(这就是 e.latLng 是)。这些属性将由 API 内部使用,这些属性的名称可能会在下一刻、下一个小时或下一天发生变化。

要检索纬度和经度,请使用 e.latLnglat()lng() 方法

关于javascript - 谷歌地图 addListener 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23757325/

相关文章:

google-maps-api-3 - 查找当前在 Google map v3 map 的视口(viewport)中可见的图 block

javascript - 预加载大面积的google map

javascript - 如何向我的 Chrome 扩展程序添加弹出窗口?

javascript - tsc out 创建空输出文件

android - 谷歌地图错误 : Marker's position is not updated after drag

javascript - Google Maps API v3,删除标记图标或更改为 "null"?

android - 添加或删除 Google Maps V2 黑屏时闪烁

google-maps-api-3 - 如何使用 Google 的第 3 版 API 设置多边形的可见性?

javascript - ng升级两个版本的Highcharts,错误16

javascript - 发射光源不影响其他物体的着色 Three.js