我有一个 fancybox,可以通过 AJAX 加载远程页面。此页面使用 JQuery Tabs 插件。默认情况下未激活的选项卡上有一个嵌入的 Google map 。调用Google Maps的代码是
<iframe width="740" height="380" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?z=16&t=m&q=<?= $geo['latitude'] ?>+<?= $geo['longitude'] ?>&hl=ru&output=embed"></iframe>
结果 map 在左上角显示搜索到的位置。我想将 map 以坐标 $geo['latitude']
和 $geo['longitude']
为中心。
我尝试添加不同的查询参数,例如 ll
、sll
,但没有成功。我还尝试将 Fancybox 的 iframe 预加载设置设置为 false - 没有结果。
我该怎么办?
最佳答案
考虑以下示例:
<iframe width="740" height="380" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=Museum+near+Washington,+United+States&aq=0&sll=40.702863,-74.055748&sspn=0.025669,0.055747&ie=UTF8&hq=Museum&hnear=Washington+D.C.,+District+of+Columbia&ll=38.913976,-77.05111&spn=0.052698,0.111494&t=h&z=14&iwloc=A&cid=4718114823360363843&output=embed"></iframe>
尝试使用 ll
参数来使 map 居中。
你也看过官方的Google Maps API吗? ?
关于jquery - 如何将嵌入的 Google map 居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18205745/