Royi Namir
Royi Namir

Reputation: 148744

change google map v3 click event to jquery?

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

Answers (1)

Blazemonger
Blazemonger

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

Related Questions