Tutorial: Marzipano Getting Started - Free 360 Image Viewer from Google

Marzipano is a free 360 image viewer from Google. It is known best for the online Marzipano tool that is used in making virtual tours.

Marzipano also works great as a standalone 360 image viewer.

Getting marzipano.js

The GitHub repo or releases do not contain the compiled marzipano.js file. Here is the compiled library, version v0.10.2.

Place the marzipano.js file in the root of your project.

Alternatively, there is a npm package for marzipano. You can use a package manager such as npm or yarn for more complex projects. To get this example simple, we’re just using the js file in the root of the project.

index.html with div “pano”

In the html file, set up a div with the id of pano. We’ll use this ID to get the viewer into the HTML.

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <div id="pano"></div>
    <script src="marzipano.js" ></script>
    <script src="index.js"></script>
  </body>
</html>

style.css

Set the size of the viewer to cover the full width and height of the browser.

#pano {
    position: absolute;
    width: 100%;
    height: 100%;
}

index.js

This is where most of the Marzipano configuration takes place.

// Create viewer.
var viewer = new Marzipano.Viewer(document.getElementById('pano'));

// Create source.
var source = Marzipano.ImageUrlSource.fromString(
  "https://theta-image-api.s3.amazonaws.com/theta_images/R0010217.JPG"
);

// Create geometry.
var geometry = new Marzipano.EquirectGeometry([{ width: 4000 }]);

// Create view.
var limiter = Marzipano.RectilinearView.limit.traditional(1024, 100*Math.PI/180);
var view = new Marzipano.RectilinearView({ yaw: Math.PI }, limiter);

// Create scene.
var scene = viewer.createScene({
  source: source,
  geometry: geometry,
  view: view,
});

// Display scene.
scene.switchTo();

serve up code

There are many ways to start a small web server locally. I used Python.

python -m http.server
Serving HTTP on :: port 8000 (http://[::]:8000/) ...

Then, open a web browser at http://localhost:8000

Live Site and Full Code Repo


Using Local 360 Images

I have some RICOH THETA images in the images folder.

In index.js, change the URL to a local file.

// Create source.
var source = Marzipano.ImageUrlSource.fromString(
  "images/room_5_5k.jpeg"
);

Other Viewers

See 5 Free 360° Image Viewers for JavaScript Web and Mobile by @shegz101

Next Steps

  1. Tutorial: Marzipano Switch Images - 360 Image Viewer
  2. Tutorial: Marzipano Zoom Controls
  3. Tutorial: Marzipano Switch Images - 360 Image Viewer
  4. Tutorial: Marzipano Hotspots for Virtual Tours
1 Like

This is a nice hint, thanks for posting this and providing the library on your repo. The npm package for Marzipano also looks good for testing, but it’s nice to have the compiled library and not have to deal with Node.js. At least for this first look-see.

yea, I noticed that the example from @shegz101 used Vite (React) and also @Phat_Ca was using npm for marzipano.

Although it’s better to use something like yarn, npm, vite for most projects, it does make the example a bit more complex.

I started to start small with Marzipano and build up to more complex examples.

It does seem that Marzipano code is high quality and it is powerful, possibly more powerful than pannellum.

The more I use Marzipano, the more I’m liking it.

You can also use a CDN. The cloudflare CDN uses the same version that I used when I built from source. For web apps with network access, using the CDN may be even easier.

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<title>Marz Minimal</title>
<link rel="icon" type="image/png" href="favicon.png">

</head>
<body>

<div id="pano"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/marzipano/0.10.2/marzipano.min.js"></script>
<script src="index.js"></script>

</body>
</html>

I was just at the Cloud Native San Francisco meetup last week, and CloudFlare was the main sponsor. They provided the space (101 Townsend, in SOMA, in San Francisco). Their developer platform (compute, media, databases, and now AI) seems pretty interesting. I haven’t tried it yet.

On Windows I am using FSP Viewer.
Welcome to the FSPViewer web pages

1 Like

I like and use FSP Viewer too.

That viewer is powerful with many customizations.

https://www.fsoft.it/FSPViewer/instructions/

For a while, the software was not being updated, but the developer has recently started to add features.

Here it is running on a Mac

@JoscTr thanks for bringing this up. Without your post, I would not have known that FSPViewer was recently updated.

1 Like