Zend Framework won't let me include Google Maps API

两盒软妹~` 提交于 2019-12-22 08:52:44

问题


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;v=2&amp;key=ABQIAAAAfINi4Ug3nkoREt524GX3ABSFqzY8bf3muCS1IE0M5aBPGVvVxRRzm1PmTbIwi_tXaNcSoONdlIx_sA" type="text/javascript"></script>

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


回答1:


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&v=2&key=ABQIAAAAfINi4Ug3nkoREt524GX3ABSFqzY8bf3muCS1IE0M5aBPGVvVxRRzm1PmTbIwi_tXaNcSoONdlIx_sA");



回答2:


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?



来源:https://stackoverflow.com/questions/921811/zend-framework-wont-let-me-include-google-maps-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!