HERE iOS SDK Developer's Guide

Street-level Objects

This section outlines the APIs that you can use to work with street-level objects such as icons, billboards and buildings. You can use NMAStreetLevelView to add and remove objects, as well as use the NMAStreetLevelViewDelegate protocol to detect and handle user interactions on these objects.

The NMAStreetLevelViewDelegate Protocol

The NMAStreetLevelViewDelegate protocol represents a delegate to provide notification upon completion of a NMAStreetLevelView event, such as user interaction with a street-level object. The addition of the NMAStreetLevelViewDelegate should be performed after the NMAStreetLevelView is initialized as described in the code snippet below.


@interface MyViewController : UIViewController <NMAStreetLevelViewDelegate>

@property (nonatomic, strong) NMAStreetLevelView* streetLevelView;

@end

@implementation MyViewController

// Assume streetLevelView has been initialized

-(void)viewDidLoad {
  self.streetLevelView.delegate = self;
}

- (void)streetLevelView:(NMAStreetLevelView*)view
         didSelectObjects:(NSArray*)selectedObjects
{
   // handle selected street level objects
}

// Implement other delegate methods as required

@end

Removing the street-level view delegate can be performed as described in the code snippet below.

streetLevelView.delegate = nil;

Using Street-level Objects

The street-level view exposes access and allows interaction with two different types of objects that are part of the street-level scene:

  • NMAProxyObject - a type of object that is provided automatically in the street-level scene when it is loaded
  • NMAUserObject - a type of object that is created by the application, and can be added to the street-level scene

The supported street-level proxy objects are:

  • NMAStreetLevelBuilding - a building that is visible in the street-level scene
  • NMAStreetLevelLink - a navigation arrow that can be clicked by the user to navigate from one panorama to another

The following code snippet highlights the selected building from a street-level scene by implementing the didSelectObjects method in the NMAStreetLevelViewDelegate protocol.


- (void)streetLevelView:(NMAStreetLevelView*)view
     didSelectObjects:(NSArray*)selectedObjects
{
  // handle street level objects selected by the user
  for (NMAStreetLevelSelectedObject *object in selectedObjects)
  {
    if ( [object.streetLevelObject isKindOfClass:[NMAStreetLevelBuilding class]] )
    {
      // assess/manipulate NMAStreetLevelBuilding objects
      NMAStreetLevelBuilding* building = 
        (NMAStreetLevelBuilding*) object.streetLevelObject;
      building.highlight = 0.5f;
    }
  }
}

The supported street-level user objects are:

  • NMAStreetLevelIcon - an image that has a specified location on the street level map
  • NMAStreetLevelBillboard - a billboard that has a specified location on the street-level map
  • NMAStreetLevelRoute - represents an NMARoute in a street-level view
Note: NMAStreetLevelIcon and NMAStreetLevelBillboard can be attached to a NMAStreetLevelBuilding. The major differences between these two objects are the way the size is specified, and how they are rendered when a zoom operation is performed. The NMAStreetLevelBillboard has the size specified in meters, so it is always rendered relative to the size of the building, while NMAStreetLevelIcon has the size specified in pixels.
User objects can be managed using the following methods:
  • NMAStreetLevelView#addStreetLevelObject: (NMAStreetLevelObject *)object
  • NMAStreetLevelView#removeStreetLevelObject: (NMAStreetLevelObject *)object
  • NMAStreetLevelView#userObjects property
Note: When you add a user object to an NMAStreetLevelView, the view retains the object until it is removed, or until the view is destroyed. The same user object instance added is passed back in the didSelectObjects: protocol method and by the userObjects property. You cannot add the same user object more than once.

This code sample demonstrates some of the concepts described above. In the sample, NMAStreetLevelIcon objects are added to a street-level view when the user double-taps on the view. If the user taps on a building, the icon is attached to the building.


@interface MyViewController : UIViewController <NMAStreetLevelGestureDelegate>

@property (nonatomic, strong) NMAStreetLevelView* streetLevelView;

@end

@implementation MyViewController

// Assume streetLevelView has been initialized

-(void)viewDidLoad {
  self.streetLevelView.gestureDelegate = self;
}

-(void)streetLevelView:(NMAStreetLevelView *)view 
  didReceiveDoubleTapFromRecognizer:(UITapGestureRecognizer *)recognizer
{
  if (![self
    addStreetLevelIconAtScreenPoint:[recognizer 
      locationInView:self.streetLevelView]]) {
    NSLog(@"User tapped the sky!");
  }
}

-(BOOL)addStreetLevelIconAtScreenPoint:(CGPoint)point
{
  BOOL success = NO;

  // Get geo coordinates for the screen point
  NMAGeoCoordinates *coords = 
    [self.streetLevelView geoCoordinatesFromScreenPoint:point];

  // We get nil geo coordiantes if the screen point can't be converted (usually
  // because the screen point is in the sky)
  if (coords) {
    // Create an icon object
    NMAImage* img
      = [NMAImage imageWithUIImage:[UIImage imageNamed:@"myicon.png"]];
    NMAStreetLevelIcon *icon
      = [NMAStreetLevelIcon streetLevelIconWithGeoCoordinates:coords
                                 icon:img];

    // If there is a building at the screen point attach it to the icon object
    NSArray *objectsAtScreenPoint = 
      [self.streetLevelView streetLevelObjectsAtScreenPoint:point];
    for (NMAStreetLevelSelectedObject *selectedObject in objectsAtScreenPoint) {
      if ([[selectedObject 
        streetLevelObject]isKindOfClass:[NMAStreetLevelBuilding class]]) {
        icon.building = 
          (NMAStreetLevelBuilding*)[selectedObject streetLevelObject];
        break;
      }
    }

    success = [self.streetLevelView addStreetLevelObject:icon];
  }

  return success;
}

@end

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.