1

I have a Google Map that suddenly stopped working for no apparent reason (I hadn't touched the code for months, but the wrapper code from our CMS may have changed without Corporate telling me).

http://www.democratandchronicle.com/section/builder

(sorry about the nasty HTML outside the map, most of that comes from our corporate parent...)

I've narrowed it down to this part of my drawMarker function:

GEvent.addListener(marker, 'click', function() {
  marker.openInfoWindowHtml(html, { maxWidth: 500 });
});

Of note:

  • alert(html); displays the correct HTML for the infowindow.
  • The HTML in the html variable is indeed valid.
  • The click event is firing (confirmed by alert('test'); within it)
  • Another map I host on the same site works fine, despite similar code.
  • No JavaScript errors in Firebug or IE that I can see.

I've been bashing my head against this for a while. What am I missing?

ceejayoz
  • 176,543
  • 40
  • 303
  • 368
  • I am having the same problem despite the fact that I changed the API version I am still not able to make it work. How did you eventually resolve the issue ? – Omayr Jul 26 '11 at 13:00

5 Answers5

2

I've had random problems with Google Maps API at times and more than once it has been fixed by going back one API version. i.e. if your google maps API javascript inclusion string is like this http://maps.google.com/maps?file=api&v=2.xd&key=XXXXX change the 2.x to something a few versions back (back when it was working) like 2.132 or something

Daniel Beardsley
  • 19,907
  • 21
  • 66
  • 79
2

try:

GEvent.addListener(marker, 'click', function() {
  this.openInfoWindowHtml(html, { maxWidth: 500 });
});

remember the scope of the object "marker" is outside your function

Keith Fitzgerald
  • 5,651
  • 14
  • 43
  • 58
2

I recently had this issue, event handlers definitely ran, etc. Turned out there were two instances of the Google Maps <script> tag on the page. Removing one fixed it.

Stu
  • 198
  • 1
  • 7
0

Try forcing JavaScript to make a new variable out of your HTML:

GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html+'', { maxWidth: 500 });
});
Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176
0

This resolved itself. I suspect an update to the API broke something for a version or two.

ceejayoz
  • 176,543
  • 40
  • 303
  • 368
  • If they updated it why isn't the change effective in my map, any ideas ? I am pretty much sure everything else is working fine. The problem is almost a replica of your problem. The event handler is working fine. I have check the html, its fine too. – Omayr Jul 26 '11 at 15:17
  • I have no idea. This was almost two years ago. You should start a new question and include an example link that demonstrates the issue. – ceejayoz Jul 26 '11 at 15:22