« MapYourBuddies - Working on Iteration 3 - (1/3) Welcome Page for IE | Main | MapYourBuddies - Working on Iteration 3 - (3/3) Preparation to highlight buddies in the friends list where we don't have an address & Google Map Marker »

MapYourBuddies - Working on Iteration 3 - (2/3) Fix for the Google Map Info Window sizing problem

How we already mentioned in the Iteration 2 Presentation of our MapYourBuddies project, we struggled - like some of you guys, too - with the "Google Map Info Window sizing problem". Basically the issue is to display an image in a Google Map Info Window (and the image is "loading to late" / takes longer than the JavaScript needs to run) and to size the Info Window to the right dimension.

This is the issue in our Iteration 2:

MapYourBuddies_I3_GoogleMapInfoWindowSizingIssue.jpg

And this is now how it already looks at the first load of the image with some CSS (and DIV) help ;)

MapYourBuddies_I3_GoogleMapInfoWindowSizingIssueSolution.jpg


The basic problem is that in some cases, the JavaScript runs faster (and creates the Info Window) than the image could be loaded (from facebook). As result does the browser not know, how much space he should plan for the image and therefore the Info Window is sometimes generated to small.

My solution to this problem is, because I know from the Facebook API documentation that our pictures we get from there are not higher than 75px.

"pic_small - URL of user profile picture, with max width 50px and max height 150px. May be blank."

Therefore I just designed the Info Window HTML with 3 <div> boxes and formated them with CSS ("height: 75px;"). Also I added the city, state and country information to the Info Window (Therefore I needed to do some JavaScript string conversions ... puh: that was fun ;)

And the issue was fixed ;)

-Joern