我需要将此导览嵌入网站:
但问题是那个
<iframe src="https://www.google.es/maps/@39.566752,2.649834,3a,75y,113.38h,90t/data=!3m5!1e1!3m3!1s86s2yikaJz6n9Ezi7bJmTw!2e0!3e2"></iframe>
不显示任何内容
有什么建议吗?
答案 0 :(得分:2)
对于新版Google地图,为了显示您的地图,您需要通过链接的集成版本,您不能只是通过iframe内的共享网址,因为使用经典的谷歌地图,它是微不足道的从共享链接转换为iframe嵌入网址,因为它实际上具有相同的网址参数,您只需添加output=embed
网址参数,以便Google输出嵌入布局而不是桌面网站布局。
所以,我认为你应该使用Safari浏览器,因为谷歌地图由于某些原因没有更新。 对于你的情况:你需要访问网址:https://maps.google.es/maps?ll=39.566752,2.649834&spn=0.369997,0.837021&cbll=39.566752,2.649834&layer=c&panoid=86s2yikaJz6n9Ezi7bJmTw&cbp=12,113.38,,0,0&t=m&z=11
这就是我如何做到的:
$url = $options["url"];
$url = parse_url($url);
$query = array();
parse_str( $url['query'], $query );
$iframe = "<iframe marginheight=\"0\" marginwidth=\"0\" ";
$iframe .= "src=\"https://maps.google.com/maps?f=q";
$iframe .= "&source=s_q";
$iframe .= "&hl=fr";
$iframe .= "&geocode=";
if(isset($query['q'])) $iframe .= "&q=".$query['q'];
$iframe .= "&aq=";
if(isset($query['sll'])) $iframe .= "&sll=".$query['sll'];
if(isset($query['sspn'])) $iframe .= "&sspn=".$query['sspn'];
$iframe .= "&t=m";
$iframe .= "&ie=UTF8";
if(isset($query['hq'])) $iframe .= "&hq=".$query['hq'];
if(isset($query['hnear'])) $iframe .= "&hnear=".$query['hnear'];
if(isset($query['ll'])) $iframe .= "&ll=".$query['ll'];
if(isset($query['spn'])) $iframe .= "&spn=".$query['spn'];
if(isset($query['z'])) $iframe .= "&z=".$query['z'];
if(isset($query['iwloc'])) $iframe .= "&iwloc=".$query['iwloc']; else $iframe .= "&iwloc=";
$iframe .= "&output=embed\">";
$iframe .= "</iframe>";
这将生成如下内容:
<iframe src="https://maps.google.com/maps?f=q&source=s_q&hl=fr&geocode=&aq=&t=m&ie=UTF8&ll=39.566752,2.649834&spn=0.369997,0.837021&z=11&iwloc=&output=embed" marginwidth="0" marginheight="0" scrolling="no" s12546768360786571550="true" replaced="true"></iframe>
iframee生成它只会给你谷歌地图选择的区域,你想要google tour添加这个iframe:
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.es/maps?cbll=39.566752,2.649834&layer=c&panoid=86s2yikaJz6n9Ezi7bJmTw&cbp=12,113.38,,0,0&ie=UTF8&ll=39.566752,2.649834&spn=0.369997,0.837021&t=m&z=11&source=embed&output=svembed"></iframe><br /><small><a href="https://maps.google.es/maps?cbll=39.566752,2.649834&layer=c&panoid=86s2yikaJz6n9Ezi7bJmTw&cbp=12,113.38,,0,0&ie=UTF8&ll=39.566752,2.649834&spn=0.369997,0.837021&t=m&z=11&source=embed" style="color:#0000FF;text-align:left">Agrandir le plan</a></small>