views:

1042

answers:

2

Hi!

I'm experiencing this problem:

I want to add the Google Maps API to my Zend Framework application using the HeadScript Helper in the bootstrap:

$view->headScript()
->appendFile('/static/js/jquery-1.3.2.min.js')
->appendFile('/static/js/jquery-ui-1.7.1.min.js')
->appendFile("http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAfINi4Ug3nkoREt524GX3ABSFqzY8bf3muCS1IE0M5aBPGVvVxRRzm1PmTbIwi_tXaNcSoONdlIx_sA");

But for some reason everytime I try this I get an empty alert box as error. The weird part now is, that when I insert the same script with the same key using plain HTML, so a "wrong key" from Google is not the problem:

<script src="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=ABQIAAAAfINi4Ug3nkoREt524GX3ABSFqzY8bf3muCS1IE0M5aBPGVvVxRRzm1PmTbIwi_tXaNcSoONdlIx_sA" type="text/javascript"></script>

I do not get that empty alert box. Did you experience anything similar?

+1  A: 

Weird I can only imagine it's a subtle difference in what's actually output - have you compared the output source of the two methods (using the headScript helper, and just hard coding the script tag) and seeing if there's any subtle difference?

Andru
+2  A: 

I had this same issue - ZF encodes the script URI automatically, so & becomes &amp;

Try

$view->headScript()
->appendFile('/static/js/jquery-1.3.2.min.js')
->appendFile('/static/js/jquery-ui-1.7.1.min.js')
->appendFile("http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAfINi4Ug3nkoREt524GX3ABSFqzY8bf3muCS1IE0M5aBPGVvVxRRzm1PmTbIwi_tXaNcSoONdlIx_sA");
David Caunt
That did the trick for me! Thanks. I should have noticed that problem though... But thanks again :)
Sebastian Hoitz
It's difficult to spot :) Good luck!
David Caunt