Reputation: 148744
I have this working code :
google.maps.event.addListener(marker, 'click', (function (marker, i)
{
return function ()
{
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
howEver , I want to change it to jQuery.
I tried , but with no success.
$(google.maps.event).on('click', marker, function ()
{
(function (marker, i)
{
return function ()
{
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i)
});
any help ?
Upvotes: 1
Views: 715
Reputation: 92983
You're trying to treat google.maps.event
as a DOM element, which it isn't. .addListener
is a method unique to the Google Maps API and can't be controlled by jQuery.
However, there are several jQuery plugins designed to make manipulating the Google Maps API easier. I myself have recently used gMap 2 with great success. A Google search for "jquery plugin google maps" will return many similar plugins, including one of Google's own.
Upvotes: 3