close button in map infowindow doesn't work: b.M is not a function Line 71

633 views
Skip to first unread message

Lothaire Ruellan

unread,
Nov 12, 2011, 7:02:24 PM11/12/11
to google-map...@googlegroups.com
I have an issue that I have been unable to troubleshoot with my infowindows. You can view the page where the problem occurs at http://www.queenofnewyork.com/
Click any marker on the map, and as soon as it appears, a javascript error is registered, which prevents the infowindow from closing.

My map code is contained in a javascript class (http://www.queenofnewyork.com/wp-content/themes/queenofnewyork/js/map.js)
Inside, I have a method called showMarkers which takes as argument an array, as follows:

    this.showMarkers = function (places) {
        for ( var i = 0 ; i < places.length ; i++) {
            var marker = new google.maps.Marker({
              position: places[i]['LatLng'],
              map: this.map,
              title: places[i]['title'],
              icon: icon,
              html: places[i]['html']
            })
            google.maps.event.addListener(marker, 'click', function () {
                infoWindow.setContent(this.html) ;
                infoWindow.open(map, this);
            });
            markersArray.push(marker);                         
        }

My markers and infowindow appear as expected, but I'm stuck with this javascript error which prevents the infowindow from closing.
Any idea what I am doing wrong?
Thanks in advance for your help.

Lothaire

Magnus Jonneryd

unread,
Jan 8, 2012, 3:24:37 PM1/8/12
to Google Maps JavaScript API v3
Hi, I had the same issue and it bothered me no end. I found your post
and realized you're using the same appproach as me (more or less). So
I thought I'd share my solution with you.
Try replacing: infoWindow.open(map, this);
With:
infoWindow.open(marker.getMap(), marker);
This solved it for me. Only thing that troubbles me is that i don't
really understand why! If it works for you perhaps you can help me
explaint it? Or is there someone else out there who can help shed some
light on this?

On Nov 13 2011, 1:02 am, Lothaire Ruellan
<webmas...@queenofnewyork.com> wrote:
> I have an issue that I have been unable to troubleshoot with my
> infowindows. You can view the page where the problem occurs athttp://www.queenofnewyork.com/

Chad Holewinski

unread,
Jan 27, 2012, 11:39:49 PM1/27/12
to Google Maps JavaScript API v3
I had the same exact issue, and put the "marker.getMap()" into my code
and whalla, it worked perfectly. No idea the difference, but thanks
for the information. I spent 2 hours looking up this solution.

On Jan 8, 2:24 pm, Magnus Jonneryd <magnus.jonne...@gmail.com> wrote:
> Hi, I had the same issue and it bothered me no end. I found your post
> and realized you're using the same appproach as me (more or less). So
> I thought I'd share my solution with you.
> Try replacing:infoWindow.open(map, this);
> With:infoWindow.open(marker.getMap(), marker);
> This solved it for me. Only thing that troubbles me is that i don't
> really understand why! If it works for you perhaps you can help me
> explaint it? Or is there someone else out there who can help shed some
> light on this?
>
> On Nov 13 2011, 1:02 am, Lothaire Ruellan
>
>
>
>
>
>
>
> <webmas...@queenofnewyork.com> wrote:
> > I have an issue that I have been unable to troubleshoot with my
> > infowindows. You can view the page where the problem occurs athttp://www.queenofnewyork.com/
> > Click any marker on themap, and as soon as it appears, a javascript error
> > is registered, which prevents theinfowindowfrom closing.
>
> > Mymapcode is contained in a javascript class
> > (http://www.queenofnewyork.com/wp-content/themes/queenofnewyork/js/map.js)
> > Inside, I have a method called showMarkers which takes as argument an
> > array, as follows:
>
> >     this.showMarkers =function(places) {
> >         for ( var i = 0 ; i < places.length ; i++) {
> >             var marker = new google.maps.Marker({
> >               position: places[i]['LatLng'],
> >              map: this.map,
> >               title: places[i]['title'],
> >               icon: icon,
> >               html: places[i]['html']
> >             })
> >             google.maps.event.addListener(marker, 'click',function() {
> >                infoWindow.setContent(this.html) ;
> >                infoWindow.open(map, this);
> >             });
> >             markersArray.push(marker);
> >         }
>
> > My markers andinfowindowappear as expected, but I'm stuck with this
> > javascript error which prevents theinfowindowfrom closing.
Reply all
Reply to author
Forward
0 new messages