Jquery 将位置详细信息从谷歌地图插入表格-添加新行

Jquery 将位置详细信息从谷歌地图插入表格-添加新行,jquery,google-maps,Jquery,Google Maps,我在向表中添加新行时遇到问题。 我使用谷歌地图,我想在表中添加一些关于地图上插入点的信息(来自谷歌数据库、地址和名称)。 (用户单击point和next ballon show按钮“添加信息”,我想在单击按钮后将此信息显示到表中 <table style="width: 100%" id="myTable"> <tr><td>Row 1</td></tr> <tr><td>Row 2</td&g

我在向表中添加新行时遇到问题。 我使用谷歌地图,我想在表中添加一些关于地图上插入点的信息(来自谷歌数据库、地址和名称)。 (用户单击point和next ballon show按钮“添加信息”,我想在单击按钮后将此信息显示到表中

<table style="width: 100%" id="myTable">
   <tr><td>Row 1</td></tr>
   <tr><td>Row 2</td></tr>
   <tr><td>Row 3</td></tr>
</table>
<a href="#" name="addRow">Add Row</a>

一排
第2排
第3排
函数“addRow”:

$(“a[name=addRow]”)。单击(函数(){
$(“table#myTable tr:last”)。在('HERE INFORMATION POINT')之后;
返回false;
});
显示点的气球的功能:

google.maps.event.addListener(marker, 'click', function() {

       geocoder = new google.maps.Geocoder();
       geocoder.geocode({'latLng': placeLoc}, function(results, status) {
         if (status == google.maps.GeocoderStatus.OK) {
        addressLoc = results[0].formatted_address;
         contentString = '<h3>place.name+'</h3>'+addressLoc+'<br/><br/><a href="#" name="addRow">Add Information</a>';

         }
       });
google.maps.event.addListener(标记,'click',函数(){
geocoder=新的google.maps.geocoder();
geocoder.geocode({'latLng':placeLoc},函数(结果,状态){
if(status==google.maps.GeocoderStatus.OK){
addressLoc=结果[0]。格式化的\u地址;
contentString='place.name+''+addressLoc+'

; } });
一切正常,但谷歌地图不起作用。

您需要使用该方法,因为您动态添加了“添加信息”元素。您的
a
元素
在添加时不会有单击事件,因为
。单击()
在调用时只绑定一次事件,所有未来的元素都不会有该事件

对live()的描述。:为当前和将来匹配当前选择器的所有元素附加事件处理程序

$([name=addRow]).live('click',function()){
$(“table#myTable tr:last”)。在('HERE INFORMATION POINT')之后;
返回false;
});
google.maps.event.addListener(marker, 'click', function() {

       geocoder = new google.maps.Geocoder();
       geocoder.geocode({'latLng': placeLoc}, function(results, status) {
         if (status == google.maps.GeocoderStatus.OK) {
        addressLoc = results[0].formatted_address;
         contentString = '<h3>place.name+'</h3>'+addressLoc+'<br/><br/><a href="#" name="addRow">Add Information</a>';

         }
       });
$("a[name=addRow]").live('click', function() {
    $("table#myTable tr:last").after('<tr><td>HERE INFORMATION POINT</td></tr>');
    return false;
});