谷歌地图addListener无法正常工作 [英] google maps addListener not working properly
问题描述
这是我的代码
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屋!