2014-02-17 50 views

回答

1

您必須在點擊添加監聽器:

var handler = Gmaps.build('Google'); 
handler.buildMap({ provider: { }, internal: {id: 'map'}}, function(){ 
    // I assume this is the way you retrieve the amrkers array 
    var json_data = <%=raw @hash.to_json %>; 
    var markers = handler.addMarkers(json_data); 

    _.each(json_data, function(json, index){ 
    var marker = markers[index]; 
    json.marker = marker; 
    google.maps.event.addListener(marker.getServiceObject(), 'click', function(){ 
     console.log(json); 
     //whatever you need here 
    }); 
    }); 

}); 
+0

犯規它回答? – apneadiving

+0

謝謝你。這回答我的問題我希望我有足夠的代表upvote :( – ominousbit

+0

好吧,所以請接受答案:) http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – apneadiving

相關問題