Weird Issue between Smarty and Google Maps

I’m doing some work on a site that uses the google maps API (which is clean, simple and absolutely fabulous, by the way) and I have bumped into a strange problem. When I draw the page that uses the google maps api with smarty everything works fine, generally. However if I put the {debug} tag into the template (which causes smarty to give you a nice little pop-up window of all of the variables it’s working with, and some other great info) google maps stops working.

This isn’t really that shocking, since there is a bunch of javascript that gets pushed into the page by debug, what is weird, and a pretty large problem is that once I do this, google maps continues not to load, even after the {debug} tag has been removed. I haven’t really dug into what is going on to carefully yet, but its an interesting issue.

Really lame solution found after the jump

Well, I dug into it, and as it turns out, it was not a problem with the debug statement at all. Rather it was an issue because I had done some line formatting in the javascript that called google maps, and put in some carriage returns in the middle of a string. (that string was producing HTML so I didn’t mind having some whitespace in the output). It turns out that this was what was making the map API puke. Just goes to show… make sure you have isolated the problem correctly!

Leave a Reply

Your email address will not be published. Required fields are marked *