求助:Google Map 和 CI 集成,遇到JS的路径问题
本帖最后由 allankliu 于 2009-11-6 16:35 编辑我在用CI在翻新我原来的网站。该网站需要用到Google Map API。换而言之,大量的JS代码。
应该说CI和GMAP没有大的冲突。可是,遇到了一个难题。
由于我的服务器原因,我无法使用index.php,而是index.php?这种方式。所以我的网页地址是:http://www.ennovation.org/ci/index.php?/map/search/
该网页中包含了JS代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
......
<script src="http://www.ennovation.org/ci/js/geocoder.js]http://www.ennovation.org/ci/js/geocoder.js" type="text/javascript"></script>
<script src="http://www.ennovation.org/ci/js/gmarkers.js]http://www.ennovation.org/ci/js/gmarkers.js" type="text/javascript"></script>
<script src="http://www.ennovation.org/ci/js/dragzoom.js]http://www.ennovation.org/ci/js/dragzoom.js" type="text/javascript"></script>
......
在该网页中有一段代码是检索栏:
<form action="#" class="yform">
<fieldset>
<legend>请输入地址:</legend>
<input type="text" name="q" value="" class="address_input" size="40" />
<input type="submit" name="find" value="Search" />
</fieldset>
</form>
其中showLocation() 保存在geocoder.js中,但是一旦在搜索栏中键入“shanghai”,
地址栏中没有变成http://www.ennovation.org/ci/index.php?/map/search/#,而是
http://www.ennovation.org/ci/index.php?q=shanghai&find=Search#
导致的问题在于地址中有CI不允许的字符:
The URI you submitted has disallowed characters.
应该说将Form检索内容提交给当前路径下或者指定路径下的JS代码进行处理是非常普遍的事情。由于index.php?的问题,所以浏览器的理解就是http://www.ennovation.org/ci/index.php才是真正的文件路径,而后面的仅仅是参数而已。我不理解的是该源代码在GMAP例子(http://code.google.com/intl/zh-CN/apis/maps/documentation/examples/geocoding-extraction.html)中,并没有出现get的字串(q=shanghai&find=Search),为什么在CI中会被显式地写在URL中?
难道最终我不得不将该页面静态化,而不采用CI? 关注,过阵子准备学习一下Google的MAP API $config['enable_query_strings'] = FALSE; 是不是这个原因啊 有可能是打开了 get 传参,楼主还是贴一下代码吧,特别是 config.php 关注,没做过这方面的工作~
页:
[1]