Google Maps InfoWindow Problem

I'm not sure what went wrong here, but Google Maps infoWindow seems to have stopped working in one of the API release.

At least, it stopped working in the way that it used to.

As is often the case, the fix was a simple one.  The symptoms I was getting was the info window seeming like it was appearing off the top left of the map when I had :-

google.maps.visualRefresh = true;

or not appearing at all if this was false.  No errors.  If I popped an alert into the click addListener, the alert popped up.  It looked like this for me :-
In the end, it seems that one can no longer assign a value to the infoWindow's "content" property :-

var infoWindow = new google.maps.InfoWindow();
infoWindow.content = "Some HTML";

This just failed.  Instead, a subtle change :-

var infoWindow = new google.maps.InfoWindow({content: "Some HTML"});

Worked perfectly.

I had done all sorts before like trying to alter the scope of variables.  I'd even got a working example next to the one which didn't work trying to spot the differences.

Now, there's a chance, probability, likelihood that at the point of declaring your infoWindow, you don't know what value the string will have.

Bizarrely, this works :-

var infoWindow = new google.maps.InfoWindow({content: ""});

//some passage of code...

infoWindow.content = "Some HTML";

But if the content isn't assigned in the declaration, you get the symptoms of the infoWindow appearing beyond the top left of the map's div or not appearing at all.

Strange.  But hopefully this post saves you some agony!

Comments

Popular posts from this blog

Morrisons Three Fish Roast

Get Friends and Family to Record Onto Your Yoto

How to Stop the Annoying Nag Message in Outlook Asking to Take Outlook Anywhere