【发布时间】:2017-02-06 18:07:23
【问题描述】:
如何将我的谷歌地图添加到 svg 元素中? 我想用地图填充 svg。
地图出现,但被拉伸并超出 svg 形状
要测试代码,您必须在 iframe 中插入 src 链接。
我的代码:
svg
{
stroke: red;
}
<svg viewBox="0 0 100 100" preserveAspectRatio="none">
<foreignObject id="map" width="560" height="349">
<iframe width="560" height="349" frameborder="0" style="border:0" src="LINK + API_KEY" allowfullscreen></iframe>
</foreignObject>
<path fill="url(#map)" d="M 50 15, 100 25, 100 100, 50 100, 0 100, 0 25Z" />
</svg>
谢谢
【问题讨论】:
-
欢迎来到 SO!提供示例代码时,请将其设为minimal, complete, verifiable example(因此,请给我们一个有效的 iframe 示例)。我正确理解您的最小问题是可以使用 svg 来掩盖 iframe,对吗?
-
是的,就是这个!我没有显示有效的 iframe,因为谷歌地图的 api 键。
-
酷。如果这是问题所在,那么谷歌地图并不重要,任何工作的 iframe 都可以
标签: css iframe svg google-maps-api-3