Reputation: 20183
I need to embed this tour to a site:
But the thing is that
<iframe src="https://www.google.es/maps/@39.566752,2.649834,3a,75y,113.38h,90t/data=!3m5!1e1!3m3!1s86s2yikaJz6n9Ezi7bJmTw!2e0!3e2"></iframe>
Wont display anything
Any suggestion?
Upvotes: 0
Views: 1775
Reputation: 972
For the new version of Google maps, in order to show your map you need to past the integration version of the link, you can't just past the share URL inside of an iframe because with classic google maps it is trivial to convert from a share link to the iframe embed URL because it essentially has the same URL parameters, you just add an output=embed
URL parameter so that Google will output the embed layout rather than the desktop site layout.
So that, I think you should use Safari browser, since Google maps is not updated in it for some reason. For you're case : You need to prcess the url : 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
And here'd how I do it :
$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>";
this will generate something like this :
<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>
The iframee generated it only give you the area selected by google maps, it you want the google tour add this 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>
Upvotes: 2