关于谷歌地图的一个简单问题 - 居中

发布于 2024-10-18 05:21:09 字数 213 浏览 2 评论 0原文

每次我从 Google 地图嵌入 iframe 时,它​​都会将标记保留在中间。

即使有工具提示并且只是剪切工具提示数据,它也会这样做:

http://jsfiddle.net/V2SVa/

是否有 url 参数或其他东西可以使地图在工具提示上居中?

Every time I embed an iframe from Google Maps it keeps the marker in the middle.

And it does even if there's a tooltip and just CUTS the tooltip data:

http://jsfiddle.net/V2SVa/

Are there url parameters or something to center the map on the tooltip?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深爱不及久伴 2024-10-25 05:21:09

那么,如果您使用的是 API,那么您可以发出对 map.setCenter()

但是,如果您像示例中那样包含内联地图,那么您只需更改初始起点。

您用来嵌入地图的 URL 是:

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

只需调整某些参数即可。

您需要调整的参数是ll = 中心位置z = 缩放级别spn/sspn = 跨度/屏幕跨度。令人惊讶的是,很难找到有关它们的信息,但此处提供了一些有关参数的详细信息。如果您只需要更改中心,请先尝试摆弄 ll 参数。

Well, if you are using the API, then you can issue a call to map.setCenter().

If however you are including the maps inline as in your example, then you just need to change the initial starting point.

The URL you are using to embed the map is:

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

Just a matter of adjusting certain parameters.

The parameters you need to adjust are ll = center location, z = zoom level and spn/sspn = span / screen span. Surprisingly awkward to find information on them, but there is some details on the parameters here. Try fiddling with the ll parameter first if you need to change just the centre.

叶落知秋 2024-10-25 05:21:09

这对我有用:

HTML

<div style="height: 400px; overflow: hidden;">
  <iframe width="425" height="700" 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>
</div>

JQUERY(甚至没有必要)

$("iframe").load(function (){
  $('iframe').css({"height": '400px'});
});

演示:http://tinker.io/9ace5

This works for me:

HTML

<div style="height: 400px; overflow: hidden;">
  <iframe width="425" height="700" 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>
</div>

JQUERY (not even necessary)

$("iframe").load(function (){
  $('iframe').css({"height": '400px'});
});

Demo: http://tinker.io/9ace5

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文