How to embed a photosphere in a website?

2019-06-04 04:55发布

问题:

I took a photosphere with google street view app and shared it on google maps.

When I try to get the code to embed it on a website (clicking "share or integrate" option when I visualise it on a browser), I only have the option to share the link. How can I get the HTML code to embed it ?

Here is the link to the photosphere : https://www.google.com/maps/@45.3189037,5.605167,3a,75y,109.64h,85.35t/data=!3m8!1e1!3m6!1s-xnB-GGXEh-Q%2FVv0xzYTJj5I%2FAAAAAAAAHnY%2Fgt_bfWvfbrUUkkA04-jtntYU4PZXuzR9w!2e4!3e11!6s%2F%2Flh4.ggpht.com%2F-xnB-GGXEh-Q%2FVv0xzYTJj5I%2FAAAAAAAAAAA%2Fut7S6Ntzdyg%2Fno%2Fphoto.jpg!7i12800!8i3206

回答1:

Basically you may embed these panoramas by creating a StreetViewPanorama

You must provide either the location via the position-property
( would be {lat: 45.318904,lng:5.605167})

or the panorama-ID via the pano-property. ( would be F:-xnB-GGXEh-Q/Vv0xzYTJj5I/AAAAAAAAHng/_boZWR43M0QLwPNphf-ROOJLOqaPUEeQw)

For the given photosphere it only works for me(don't ask me why) when I set the (still undocumented) google.maps.streetViewViewer-property to photosphere

 google.maps.event.addDomListener(window, 'load', function() {

   google.maps.streetViewViewer = 'photosphere';
   new google.maps.StreetViewPanorama(document.getElementById('pano'), {

     pano: 'F:-xnB-GGXEh-Q/Vv0xzYTJj5I/AAAAAAAAHng/_boZWR43M0QLwPNphf-ROOJLOqaPUEeQw'
   });
 });
html,
body,
#pano {
  margin: 0;
  padding: 0;
  height: 100%;
}
<script src="http://maps.google.com/maps/api/js?v=3"></script>
<div id="pano"></div>