Tour Namespace

Sample custom tour.

const connect = function(sdk) {
  const mpSdk = sdk;

  mpSdk.Tour.Event.on(Tour.Event.STEPPED, function(tourIndex){
    console.log('Tour index ' + tourIndex);
  });
  mpSdk.Tour.Event.on(Tour.Event.STARTED, function(){
    console.log('Tour started');
  });
  mpSdk.Tour.Event.on(Tour.Event.STOPPED, function(){
    console.log('Tour stopped');
  });

  mpSdk.Tour.getData()
    .then(function(tour) {
      console.log('tour has ' + tour.length + ' stops');
      return mpSdk.Tour.start(0);
    })
    .then(function(){
      // console 'Tour started'
      // console -> 'Tour index 0'
      return mpSdk.Tour.next();
    })
    .then(function(){
      // console -> 'Tour index 1'
      return mpSdk.Tour.step(3);
    })
    .then(function(){
      // console -> 'Tour index 3'
      return mpSdk.Tour.prev();
    })
    .then(function(){
      // console -> 'Tour index 2'
      // console -> 'Tour stopped'
      return mpSdk.Tour.stop();
    });
}
Usage of the SDK constitutes your agreement with the Matterport SDK Agreement. Email developers@matterport.com with any questions.

Index

Enumerations

Types

Methods

Types

Snapshot

Snapshot: object

Type declaration

  • imageUrl: string
  • is360: boolean
  • mode: Mode | undefined
  • name: string
  • position: Vector3
  • rotation: Vector3
  • sid: string
  • thumbnailUrl: string
  • zoom: number

Methods

getData

  • This function returns an array of Snapshots.

    mpSdk.Tour.getData()
      .then(function(snapshots) {
        // Tour getData complete.
        if(snapshots.length > 0){
          console.log('First snapshot sid: ' + snapshots[0].sid);
          console.log('First snapshot name: ' + snapshots[0].name);
          console.log('First snapshot position: ' + snapshots[0].position);
        }
      })
      .catch(function(error) {
        // Tour getData error.
      });
    

    Returns Promise<Tour.Snapshot[]>

next

  • next(): Promise<void>
  • This function moves the camera to the next snapshot in the tour.

    mpSdk.Tour.next()
      .then(function() {
        // Tour next complete.
      })
      .catch(function(error) {
        // Tour next error.
      });
    

    Returns Promise<void>

prev

  • prev(): Promise<void>
  • This function moves the camera to the previous snapshot in the tour.

    mpSdk.Tour.prev()
      .then(function() {
        // Tour prev complete.
      })
      .catch(function(error) {
        // Tour prev error.
      });
    

    Returns Promise<void>

start

  • start(index?: undefined | number): Promise<void>
  • This function start the tour.

    const tourIndex = 1;
    
    mpSdk.Tour.start(tourIndex)
      .then(function() {
        // Tour start complete.
      })
      .catch(function(error) {
        // Tour start error.
      });
    

    Parameters

    • Optional index: undefined | number

    Returns Promise<void>

step

  • step(index: number): Promise<void>
  • This function moves the camera to a specific snapshot in the tour.

    const myStep = 2;
    mpSdk.Tour.step(myStep)
      .then(function() {
        //Tour step complete.
      })
      .catch(function(error) {
        // Tour step error.
      });
    

    Parameters

    • index: number

    Returns Promise<void>

stop

  • stop(): Promise<void>
  • This function stop the tour.

    mpSdk.Tour.stop()
      .then(function() {
        // Tour stop complete.
      })
      .catch(function(error) {
        // Tour stop error.
      });
    

    Returns Promise<void>