Reputation: 1451
Im trying to add some callback to my code, so when clicking on a picture outside the map, the maps get centered to the position that image contains, so I try this.
Gmaps4Rails.callback = function() {
var event = document.getElementsByClassName("link-s");
event.onclick = showEvent;
function showEvent(pos) {
var pos = -25.363882,131.044922;
Gmaps4Rails.map.setCenter(pos.latLng);
};
};
it doesnt throw any error, im using "pos" for testing purposes, but i cant make it work.
Upvotes: 1
Views: 662
Reputation: 115511
It's just a question of javascript:
Gmaps4Rails.callback = function() {
var events = document.getElementsByClassName("link-s");
for (var i = 0; i < events.length; ++i) {
events[i].onclick = function() { showEvent(); };
}
function showEvent() {
Gmaps4Rails.map.setCenter(new google.maps.LatLng(-25.363882,131.044922));
};
}
Upvotes: 3