Google Maps SDK for iOS

Street View

Google Maps Street View lets you explore places around the world through 360-degree, street-level imagery. You can explore world landmarks, view natural wonders, navigate a trip, or show the outside of your business.

Overview

Google Street View provides panoramic 360-degree views from designated roads throughout its coverage area. The coverage available through the SDK is the same as that for the Google Maps for iOS app or https://maps.google.com/. The list of currently supported cities for Street View is available at the Google Maps Help Center.

The Google Maps SDK for iOS provides a Street View service for obtaining and manipulating the imagery used in Google Maps Street View. Street View images are returned as panoramas and are viewed from within the Street View viewer — an object of type GMSPanoramaView.

Street View Panoramas

Each Street View panorama is an image, or set of images, that provides a full 360-degree view from a single location. Images conform to the equirectangular (Plate Carrée) projection, which contains 360 degrees of horizontal view (a full wrap-around) and 180 degrees of vertical view (from straight up to straight down). The resulting 360 degree panorama defines a projection on a sphere with the image wrapped to the two-dimensional surface of that sphere.

Street View panoramas are viewable with the GMSPanoramaView object. This object provides a viewer that will render the panorama as a sphere, with a camera at its center. You can programmatically control the orientation of the camera, as well as several properties customizing the viewer.

Accessing Street View Data

Street View panoramas are identified by one of two pieces of meta-data:

panoramaID
The unique ID of a Street View panorama. This panoramaID may change over time, and are not suitable as long term, or hard-coded, references. The panoramaID is best used to provide programmatic access to different Street View images. Note: Innerspace and Photo Sphere panoramas are not supported at this time.
coordinate
The precise location of this image, expressed as a CLLocationCoordinate2D. Use a coordinate for persistent storage of a panorama location, or to translate user actions on the map into a Street View image.

Both the panoramaID and the coordinate are stored as properties of the GMSPanorama object. You can request a GMSPanorama from the GMSPanoramaService using either the coordinate or panoramaID. The resulting object will include both pieces of meta-data, as well as an array of links to nearby panoramas.

Viewing Street View images

Add a Street View viewer

The basic steps for adding a viewer are:

  1. (Once) Follow the steps in Getting Started to get the SDK, obtain a key and add the required frameworks.
  2. Create or update a ViewController. If the panorama will be displayed when this view controller becomes visible, be sure to create it within the loadView method.
  3. Create and instantiate a GMSPanoramaView class using the GMSPanoramaView initWithFrame: method. If this is to be used as the view controller's only view, then CGRectZero could be used as the map's frame — the map will be resized automatically.
  4. Set the GMSPanoramaView object as the view controller's view, e.g. self.view = panoView_;.
  5. Set the location of the Street View image using a method such as moveNearCoordinate:.

The below example adds a Street View viewer to an app.

#import "ViewController.h"
#import <GoogleMaps/GoogleMaps.h>

@implementation ViewController {
    GMSPanoramaView *panoView_;
}

- (void)loadView {
    panoView_ = [[GMSPanoramaView alloc] initWithFrame:CGRectZero];
    self.view = panoView_;

    [panoView_ moveNearCoordinate:CLLocationCoordinate2DMake(-33.732, 150.312)];
}
@end

Customize the viewer

You can customize the viewer by restricting which gestures are available. By default, panning, zooming and traveling to adjacent panoramas are all enabled. Individual gestures are controlled through properties of GMSPanoramaView. These properties enable or disable user controlled gestures; programmatic changes are still possible when the gesture is disabled.

orientationGestures
Whether the user will be able to re-orient the camera by tapping or dragging. Set to NO to disable orientation changes to the camera.
zoomGestures
Whether the user will be able to pinch to zoom. Set to NO to disable zoom.
navigationGestures
Whether the user will be able to change which panorama is visible. Users may use a single tap on navigation links or double tap the view to change panoramas Set to NO to disable navigation changes.

You can enable or disable all of the gestures at once with the setAllGesturesEnabled: method.

[panoView_ setAllGesturesEnabled:NO];

Launch Street View with the URL Scheme

Google Street View imagery is viewable from within the Google Maps for iOS application. You can launch the Google Maps for iOS application in street view mode with the comgooglemaps URL Scheme by setting the mapmode parameter to streetview. An example of a URL that will launch Street View appears below. For more information, refer to the URL Scheme documentation.

comgooglemaps://?center=46.414382,10.013988&mapmode=streetview

Street View Locations and Point-of-View (POV)

The GMSPanoramaCamera allows you to set the point-of-view of the Street View camera as a combination of heading, pitch and zoom.

The below snippet sets will orient the camera south, and slightly downwards.

GMSPanoramaView *panoView_;
panoView_.camera = [GMSPanoramaCamera cameraWithHeading:180
                                              pitch:-10
                                               zoom:1];

Orientation

The Street View location defines the placement of the camera focus for an image, but it does not define the orientation of the camera for that image. For that purpose, the GMSOrientation object defines two properties:

  • heading defines the rotation angle around the camera locus in degrees relative from true north. Headings are measured clockwise: true north is 0, east is 90, south is 180, west is 270.
  • pitch (default 0) defines the angle variance "up" or "down" from the camera's initial default pitch, which is often (but not always) flat horizontal. (For example, an image taken on a hill will likely exhibit a default pitch that is not horizontal.) Pitch angles are measured with positive values looking up (to +90 degrees straight up and orthogonal to the default pitch) and negative values looking down (to -90 degrees straight down and orthogonal to the default pitch).

Zoom

Street View supports different levels of image detail through the use of zoom. You can set the zoom level programmatically, or users can change the level in the viewer by pinching to zoom.

Moving the camera

Once you've created the GMSPanoramaView, and it has either a configured or default camera, you can change it in one of several ways. When you change the camera, you have the option of animating the resulting camera movement. The animation interpolates between the current camera attributes and the new camera attributes.

You can modify the GMSPanoramaCamera object, and set it on the GMSPanoramaView's camera property. This will snap the camera to the new point of view with no animation. A GMSCameraPosition may be created to configure any combination of orientation and zoom.

GMSPanoramaView *panoView_;
panoView_.camera = [GMSPanoramaCamera cameraWithHeading:180 pitch:-10 zoom:1];

You can animate a transition by calling the animateToCamera:animationDuration: method of GMSPanoramaView. Additionally, you can control the camera using Core Animation. This is made available through the custom CALayer on GMSPanoramaView, GMSPanoramaLayer.

Markers within Street View

The GMSPanoramaView object is able to display map markers. You can use the same GMSMarker object on either a GMSMapView or a GMSPanoramaView object by setting its corresponding properties:

// Create a marker at the Eiffel Tower
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(48.858,2.294);
GMSMarker *marker = [GMSMarker markerWithPosition:position];

// Add the marker to a GMSPanoramaView object named panoView_
marker.panoramaView = panoView_;

// Add the marker to a GMSMapView object named mapView_
marker.map = mapView_;

Markers will scale in size as a function of the distance between the marker's position and the GMSCameraView's location. If this distance becomes too great, the marker will become too small to display and will be hidden from view.

Set the panoramaView property to nil to remove it from the GMSPanoramaView.

marker.panoramaView = nil;

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.