Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
383 views
in Technique[技术] by (71.8m points)

javascript - google maps addListener not working properly

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...