2016-12-16 34 views
-1

我想在google地图标记的infowindow上按钮点击事件信息窗口。以下是我的代码,但Click事件不会调用函数信息窗口按钮点击不调用函数

function createmarker(map, marker) { 
    var request = $http({ 
    method: "post", 
    url: "example.com", 
    data: { 
    email: localStorage.getItem("email_id") 
    }, 
    headers: { 
    'Content-Type': 'application/x-www-form-urlencoded' 
    } 
    }); 

    request.success(function(response) { 
    for (i = 0; i < response.length; i++) { 

    marker = new google.maps.Marker({ 
     position: new google.maps.LatLng(response[i].curlat, response[i].curlng), 
     map: map, 
     animation: google.maps.Animation.DROP 
    }); 

    google.maps.event.addListener(marker, 'click', (function(marker, i) { 
     return function() { 
     var infowindow = new google.maps.InfoWindow({ 
     content: "<input type='button' value='View' onclick='joinFunction()'>" + "<input type='button' value='Join' onclick='alert(\"infoWindow\")'>" 
     }); 
     // infowindow.setContent('<button onclick="viewFunction()">View</button>'); 
     infowindow.open(map, marker); 
     } 
    })(marker, i)); 
    } //for loop close 

    }); //http close 
    }; //create marker close 
    function joinFunction() { 

    } 
+0

地方事件侦听器的功能之外被显示为 – madalinivascu

回答

1

可以使用设置:

infowindow.setContent('<input type="button" value="View" onclick="joinFunction()"><input type="button" value="Join" onclick="alert(\"infoWindow\")">'); 

它将工作

+0

警报消息但join函数不叫 – Kingslayer

+0

它调用join函数。你在哪里放置功能? –