简体   繁体   中英

Zend Framework won't let me include Google Maps API

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?

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");

很奇怪我只能想象它实际输出的细微差别 - 您是否比较了两种方法的输出源(使用headScript助手,只是硬编码脚本标签)并查看是否存在任何细微差别?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM