2016-12-16 68 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函數。你在哪裏放置功能? –