0

你好我有一个小问题。

我如何将带有谷歌地图的 iframe 放入 html 中?

 <canvas id="google_map" width="600" height="400">
    <iframe width="600" height="390" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src=""></iframe>
 </canvas>
4

2 回答 2

1

你不需要把地图放在画布上试试这个......

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div style="width: 100%; margin-top: 50px;">
   <iframe src="https://www.google.com/maps/embed?pb=!1m16!1m12!1m3!1d2965.0824050173574!2d-93.63905729999999!3d41.998507000000004!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!2m1!1sWebFilings%2C+University+Boulevard%2C+Ames%2C+IA!5e0!3m2!1sen!2sus!4v1390839289319" width="100%" height="200" frameborder="0" style="border:0"></iframe>
</div>

于 2017-11-23T10:05:48.223 回答
0

不幸的是,您不能在 Canvas 标记内放置 iFrame。但是,您可以使用相对位置将 iFrame 覆盖在画布元素上:

<style type="text/css">
canvas {
    width: 600px;
    height: 400px;
}
iframe {
    position: relative;
    top: -400px;
    width: 600px;
    height: 400px;
}
</style>
<canvas></canvas>
<iframe src=""></iframe>

不过我要说的一件事是,使用框架通常是 Web 开发经验不足的标志。您对它们的使用可能会被规避。

于 2012-05-09T10:29:56.117 回答