用于方向的Google Maps Embed API-缩放以适合起点和终点

问题描述 投票:2回答:1

Embed API的Google地图directions并不总是在框架中显示起点和终点。有时默认缩放级别会放大太多。

<iframe 
    src="https://www.google.com/maps/embed/v1/directions?     
        origin=%2020858%20King%20Hezekiah%20Way%20%20Bend%20Oregon%20United%20States&amp;
        destination=1180%20SE%203rd%20Street%2C%20Bend%2C%20OR&amp;
        key=******************************" 
    width="281" 
    height="370">
</iframe>

(添加了空格以提高可读性。)

example embed directions zoomed in too far, by default

几乎解决方案:

这是它的外观(例如,使用zoom=14-手动缩小):

enter image description here

这里是一个live example

Embed API中是否有任何解决方案或解决方法?这是bug吗?

UPDATE在2018年2月似乎已得到解决。也就是说,在live example上,错误映射现在看起来与解决方法相同。猜想这比答案或Mea culpa更好。

zoom directions google-maps-embed
1个回答
0
投票
<div style="height: 400px">
  <iframe width="100%" height="100%" 
    src="https://www.google.com/maps/embed/v1/directions?     
    origin=%2020858%20King%20Hezekiah%20Way%20%20Bend%20Oregon%20United%20States&amp;
    destination=1180%20SE%203rd%20Street%2C%20Bend%2C%20OR&amp;
    key=******************************"  allowfullscreen>
  </iframe>
</div>

您可以尝试这样。只需将宽度和高度设置为不>]

© www.soinside.com 2019 - 2024. All rights reserved.