admin管理员组文章数量:1431955
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:
/
Are there url parameters or something to center the map on the tooltip?
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/V2SVa/
Are there url parameters or something to center the map on the tooltip?
Share Improve this question asked Feb 17, 2011 at 20:07 anonymousanonymous 1,5397 gold badges26 silver badges37 bronze badges2 Answers
Reset to default 3Well, 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./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.
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./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
本文标签: javascriptAn easy question about Google MapscenteringStack Overflow
版权声明:本文标题:javascript - An easy question about Google Maps - centering - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745590396a2665160.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论