Getting Ready

Include the Google Maps Api and pitchpeek.js in the head of your page.

<script src="//"></script>
<script src="//"></script>

Somewhere on your page, create a div with an id, with width & height.

<div id="sample-panorama" style="width:500px;height:280px;">
  you can put placeholder text or an image in your div

Hello World

Now we're ready to create our first pitchpeek object using the id of our div.

  var pano = new pitchpeek('sample-panorama');

You can click the buttons in this tutorial to watch the code work on the sandbox div to the right, and interact with your new pano object. This seems easiest on a wide screen.

Setting Options

Now we have created the "Hello World" of pitchpeek. A bit more has happened behind the scenes, so now is a good time to understand what we've created and how to work with it. We've created a new object named pano, and we can use that name to access it's properties and call functions on it. We could also have another div somewhere else on the page named example and it would have it's own properties and functions. For the sake of simplicity, we'll just be using one right now and we'll call it pano.

Let's set some fun options and reload the tour. From now on we're just using javascript so remember to code in a js file or wrap your code inside of a <script> tag.


We just set some properties, and then called the public function tour() which loads the Streetview again using the new values. This is very handy when you want to start with an initial tour and then make some changes based on user interactions, like we're doing right now in the sandbox. But sometimes you just need to set your options once when the page loads and then leave it. So you can pass your options to the pitchpeek constructor, which will override the default values as it's loading the tour.

var myOptions={
var pano=new pitchpeek('sample-panorama',myOptions);

And for minimalists, the one-liner...

var pano = new pitchpeek('sample-panorama',{initialPano:'YuxV_6KDjN0AAAQYn87sYg', rotatingStart:true, rotatingSpeed:-.3});

There are 47 different options that can be set. Most of them apply to styling the menus and hotspots. The reference section describes what they all do and their defaults. If you find yourself always using the same options in every tour on your site, then edit the defaults in your pitchpeek.js and you can shorten your one-liners down to very little. You can probably get away with just setting initialPano or xml. That's the beauty of open source, you can customize this file to your needs, just keep the license and copyright intact.

Public Functions

We've already learned one public function, tour() to reload the Streetview. There are several private functions running inside of the pitchpeek object that you can't control from your pano object, but the public ones can be called from it.


setView takes a complete or partial "view" object, and uses whatever parts you've given to update the Point-of-View and Node. Here is a complete setView call with all four parts, they can be in any order.


Note that the entire pano didn't need to reload, and tour() wasn't called. (And if you reload the entire page and click this before loading any pitchpeek it won't work) That's a little clearer when we just change the zoom. You can also go back and click on a previous example, then come back and click "Zoom to Level 2", and it will zoom in on whatever Node you're currently on.


Maps Api Functions

The functions use the existing functions in the Google Maps Api. This one is just too convenient, so I made it a public function and allowed partial views. But it's really not cool to "wrap" api functions! The Google Maps Api and the Streetview Service are just too amazing to conceal, but luckily we can access everything in the api right through pitchpeek. The pano object we made holds a very special object named panorama. It's the same StreetViewPanorama object that you get when you use the api alone. So we can access all of the awesomeness of the api even though we've created it with the pitchpeek constructor.


The maps api is huge and we're barely going to scratch the surface, so you should really go and check it out. Here's one more that we'll use later, I'm using jquery to put the results into our "console" but you don't need jquery for this to work. (We'll get into the real console later.) For some example code we'll use alert.


Notice how you can move from node to node, and getPano returns a different panoid. We're going to build on that next.

XML Menus

You can store your tour data in xml. So we're going to need to make some xml before we can even try this. We know that to jump to a particular view, we need those 4 peices of information. Let's write a quick function, we'll pass it our pano.panorama object and use the Maps Api to grab those 4 values, and then generate some xml to put in in the console. We can use \t for tabs, and \n for new lines.

function getViewXml(panorama){
  var pov=panorama.getPov();
  var pano=panorama.getPano();
  var output='<VIEW>\n'+
  '\t<TITLE>Title Here</TITLE>\n'+
  return output;

So if we navigate to some nice places, click the button below, and copy the xml to a new xml file, we're almost ready to load up that xml in pitchpeek.

Ok, by now you have some xml ready to become menus. You've probably even updated the titles, if you forgot what they are then you might want to just give them different names so you can see what you're doing next. Take your xml, wrap it inside of this TOUR tag, and save your file as menu1.xml so it looks similar to what you see below.

<?xml version="1.0" encoding="ISO-8859-1"?>
    <TITLE>Hostess Station</TITLE>

Awesome, now we can use our menu1.xml file to generate the menus!

var pano = new pitchpeek('sample-panorama',{xml:'menu1.xml'});

Hopefully you got that to work, and by setting some of our special options, we can have our new tour land on any of the views in our file or stick with the initialPano. Hey, I just remembered about the great view of the stage, but I only want to show that sometimes... I can load a second xml file using another public function, loadXMLDoc().


And we can call xml files all day long! Click it a couple times to add stage over and over. Want to reset? Give it a tour() call, and it will reload with just one file, the last one you set in options.xml.


XML Sandbox

Drop the peg-person, use previews in the sandbox, get your xml, and wrap it up!

You can copy the wrapped xml into a file. If you've understood the tutorial, you have everything you need to get started.

XML Hotspots

Hotspots can be loaded in the same xml file. I'll let you figure out how to build your hotspot xml on your own. Here's the spec.

  <CONTENT><![CDATA[<p>Take a <b>big leap</b> and learn to swim.</p>]]></CONTENT>

Add these HOTSPOT tags right after your VIEW tags in your xml. The panoids that you list inside of SHOW control where this hotspot will be shown, so you can see a hotspot as you walk around but can remove it if you go around a corner or your view of the object you're highlighting is obscured. The hotspots will scale, so if you're walking towards one and it's turned on it several panos, it will grow as you approach. The height (anchor), scaling, colors, and the svg paths of the icons can all be changes by setting options.

pano = new pitchpeek('sample-panorama',{xml:'hotspot.xml', hotspotScale:1});

One last thing before we jump into options. There is a real console in Chrome that you can use on any page. Press F12 to launch the developer tools, and on the top menu click on Console. The console knows what public properties and functions are available to you and will help you finish your own thoughts! Try typing in some of the functions discussed in this tutorial, for example, pano.panorama.getPano() and watch it spit back the panoid. This is very useful for debugging, because you can unit test your functions right on the same page where the action is happening. Ok, that's all for the tutorial, check out the options below and download your copy of pitchpeekJS. Don't forget that there's a new donate button floating around!

All Option Defaults

StreetViewPanorama Settings

	renderMode:'html5', //( webgl | html4 | html5 )
	disableDefaultUI: false,
	addressControl: false,
	zoomControl: false,
	clickToGo: false,
	linksControl: true,
	panControl: false,
	enableCloseButton: false,

These settings are passed directly into the Google Maps Api, so updated information on them can be found in the amazingly detailed Street View Service Documentation

PitchPeek Startup Settings

	initTour:true, //false and tour() won't be called, allowing you to set additional options before calling tour() manually
	initialPano:'dwFEQYodwY0AAAQXL2YgRA', //you can set this to one of your own panos, it will load if xml fails
	xml:null, //null will skip xml loading, set a path to xml file to enable loading
	menuFirstId:0, //if set to 0, the first view in your xml file will be loaded. if set to -1, the second view will be loaded, -2 for the third ect... If you want a view that won't be in your menu, set it to any positive integer and your tour will load with initialPano


	rotatingStart:false, //true will enable rotating
	rotatingStopOnHover:true, //false and it won't stop
	rotatingFramerate:33, //wait in milliseconds before advancing rotation
	rotatingSpeed:.1, //speed of rotation, bigger numbers go faster, negative numbers go counter-clockwise


	menuPosition:'LEFT_TOP', //see below for accepted values
	menuButtonBorder:'2px solid #fff',
	menuButtonBoxShadow:'0 2px 6px rgba(0,0,0,.3)',
	menuButtonTitlePrepend:'Click to go to ', //before your slide title
	menuButtonTitleAppend:'.', //after your slide title

Accepted Menu Positions

  • TOP_CENTER top center
  • TOP_LEFT top left, with buttons flowing towards the top center
  • TOP_RIGHT top right, with buttons flowing towards the top center
  • LEFT_TOP top left, but below any TOP_LEFT elements
  • RIGHT_TOP top right, but below any TOP_RIGHT elements
  • LEFT_CENTER left side, centered between the TOP_LEFT and BOTTOM_LEFT positions
  • RIGHT_CENTER right side, centered between the TOP_RIGHT and BOTTOM_RIGHT positions
  • LEFT_BOTTOM bottom left, but above any BOTTOM_LEFT elements
  • RIGHT_BOTTOM bottom right, but above any BOTTOM_RIGHT elements
  • BOTTOM_CENTER bottom center
  • BOTTOM_LEFT bottom left, with buttons flowing towards the bottom center
  • BOTTOM_RIGHT bottom right, with buttons flowing towards the bottom center


	infowindowMaxWidth:null, //400   don't write px
	contentBefore:'<div id="content">', //before and after wrap content
	hotspotDraggable:false, //true will allow dragging hotspot icons
	hotspotScale:2, //blow up your vector icons
	hotspotAnchorX:0, //position your icon left or right
	hotspotAnchorY:0, //position your icon up or down
	hotspotSvgIcon:'M16,1.466C7.973,1.466,1.466,7.973,1.466,16c0,8.027,6.507,14.534,14.534,14.534c8.027,0,14.534-6.507,14.534-14.534C30.534,7.973,24.027,1.466,16,1.466z M14.757,8h2.42v2.574h-2.42V8z M18.762,23.622H16.1c-1.034,0-1.475-0.44-1.475-1.496v-6.865c0-0.33-0.176-0.484-0.484-0.484h-0.88V12.4h2.662c1.035,0,1.474,0.462,1.474,1.496v6.887c0,0.309,0.176,0.484,0.484,0.484h0.88V23.622z' //accepts an svg icon path

Need a bunch of svg icon paths to choose from? I got the default one here.

Simple Fullscreen Webpage Example

<!DOCTYPE html>
    <script src=""></script>
    <script src="pitchpeek.min.js"></script>
    <div id="sample-panorama" style="position:absolute; left:0px; top:0px; width:100%; height:100%;" >
      oops, it hasn't loaded
      var pano = new pitchpeek('sample-panorama',{renderMode:'html5'});

View FullScreen Sample