jquery - 如何将嵌入的 Google map 居中

标签 jquery google-maps fancybox jquery-ui-tabs

我有一个 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&amp;t=m&amp;q=<?= $geo['latitude'] ?>+<?= $geo['longitude'] ?>&amp;hl=ru&amp;output=embed"></iframe>

结果 map 在左上角显示搜索到的位置。我想将 map 以坐标 $geo['latitude']$geo['longitude'] 为中心。

我尝试添加不同的查询参数,例如 llsll,但没有成功。我还尝试将 Fancybox 的 iframe 预加载设置设置为 false - 没有结果。 我该怎么办?

最佳答案

考虑以下示例:

<iframe width="740" height="380" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Museum+near+Washington,+United+States&amp;aq=0&amp;sll=40.702863,-74.055748&amp;sspn=0.025669,0.055747&amp;ie=UTF8&amp;hq=Museum&amp;hnear=Washington+D.C.,+District+of+Columbia&amp;ll=38.913976,-77.05111&amp;spn=0.052698,0.111494&amp;t=h&amp;z=14&amp;iwloc=A&amp;cid=4718114823360363843&amp;output=embed"></iframe>

尝试使用 ll 参数来使 map 居中。

你也看过官方的Google Maps API吗? ?

关于jquery - 如何将嵌入的 Google map 居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18205745/

相关文章:

javascript - 检查复选框是否被选中

javascript - 如何为 jquery 调用 `$(some)` 创建 spy ?

jquery - fancybox 中的箭头定位

javascript - 如何在另一个 Fancybox 关闭后打开一个 Fancybox?

javascript - 如何在 onInit() 中获取缩略图中当前项目的数量 Fancybox 3

javascript - jQuery every 不适用于某些类或一般类?

ios - swift 3 : Google maps not setting markers in for loop

javascript - 如何在谷歌地图上以不同颜色显示路线上道路的优先级

asp.net - 使用没有 API key 的谷歌地图?

javascript - 使用具有多个下拉列表的 jQuery "find"和 "filter"进行过滤