Get Started

Thank you for using the HERE SDK for iOS. The HERE SDK is tailored to bring the best and freshest assets from the HERE platform to your mobile applications. It supports a broad range of devices allowing you to reach millions of users worldwide. Below you can find more details:

Get Your Credentials

The HERE SDK for iOS requires two strings - one unique ID and a secret key - to operate. No other credentials or tokens are needed to use the HERE SDK. To obtain your personal AccessKeyId and AccessKeySecret, do the following:

Please contact your HERE representative to receive access including a set of evaluation credentials. For now, the Navigate Edition is only available upon request.

See also the below section Authenticating Applications to learn more details on how to set the credentials for your app.

Try the Example Apps

The easiest way to get started, is to try one of the many example projects that are available for the HERE SDK.

Choose an example of your choice, then:

  1. Add the HERE SDK framework to the app's root folder.
  2. Add your HERE credentials (AccessKeyId and AccessKeySecret) to the Info.plist file.

Now you are ready to open the Xcode project and you can instantly execute the app on your device or simulator.

Did you know that almost every topic of this Developer's Guide is available as executable app?

Feel free to experiment with the code of the examples. You can also follow the below guide to get a more thorough introduction on how to develop apps with the HERE SDK.

Create a New iOS Project

As a very first step-by-step example, we will develop a "Hello Map" iOS application that shows - yes! - a map. If you want to integrate the SDK into an existing application, you can skip this step. No specific SDK code is involved here. We recommend using Xcode as the IDE. If you are new to iOS development, please follow the guides on developer.apple.com to help you get started with the first steps.

Note: The example code for "HelloMap" is available from here.

Start Xcode (for this guide, we have used version 11.3) and Create a new Xcode project:

  • For the template, it is sufficient to choose iOS => Application => Single View App.
  • Click next.
  • Provide a project name, e.g. "HelloMap" and select Swift as the language.
  • Click next and choose an appropriate directory in which to save the project.
  • Select a simulator or a real device (which is recommended).

For the example below, we have kept the default orientation settings. When running the existing example apps, make sure the Deployment target is set to a version you have installed - we have used iOS 11.

Now, build and run the current scheme and confirm that your plain project executes as expected. If all goes well, you should see a blank view without any content.

Say Hello Map!

Once we have a working iOS app, it's time to include the HERE SDK and to show a map on your emulator or device. Here's an overview of the next steps:

  1. Integrate the HERE SDK.
  2. Set required credentials in your plist file.
  3. Add a map view by code or by adding it to a storyboard.
  4. Add the code to load your first map scene.

Note: While all of the functionalities of the HERE SDK are accessible from the simulator, usage of a real device is strongly recommended. The overall performance will be better, and some features like gestures are just easier to use on a multi-touch enabled hardware. The rendering of the map view is optimized for mobile device GPUs.

Let's begin with the first step to see how we can add the HERE SDK to our project.

Integrate the HERE SDK

On developer.here.com you can find the latest release artifacts including the HERE SDK framework to include in your application (named xx.yy.zz.release_date).

Copy the heresdk.xcframework folder to your app's root folder.

In Xcode, open the General settings of the App target and add the heresdk.xcframework to the Embedded Binaries section (Click "+", then "Add other..." -> "Create folder references").

Note that this guide is based on HERE SDK version 4.3.3.0. If your framework version is different from the version used for this guide, the steps may vary and you may need to adapt the example's source code.

Set Your HERE Credentials

When using the HERE SDK, your application must be authenticated with a set of credentials you add to the Info.plist file of your project.

Once you have your credentials at hand, add a new Dictionary entry called "HERECredentials" to your Information Property List file (Info.plist). Inside "HERECredentials", add the following key/value pairs for AccessKeyId and AccessKeySecret. Alternatively, you can also open the file "as source" and add the following XML tags inside the existing <dict> element:

<key>HERECredentials</key>
<dict>
    <key>AccessKeyId</key>
    <string>YOUR_ACCESS_KEY_ID</string>
    <key>AccessKeySecret</key>
    <string>YOUR_ACCESS_KEY_SECRET</string>
</dict>

Note: The credentials are not tied to the name of your app, but to the account used to obtain the credentials. This makes it possible to use the same set of credentials for multiple apps.

Tip: Alternatively, you can set your credentials programmatically, for example, if you don't want to hardcode your credentials in the property list for security reasons.

Add the Map View

Now that we have the SDK integrated into the project and added the required credentials, we can add a new MapView instance.

The map view of the Explore Edition is rendered with the HERE Rendering Engine. A special light-weighted rendering architecture that is optimized for resource-constrained devices is available as part of the Lite Edition.

There are two alternative ways to do this. We will first show how to add a MapView programmatically, then we will show how to add a MapView using a Storyboard.

Note that multiple MapView instances can be created and rendered on the same screen.

Whichever method you choose, you will need to add the following line to your ViewController.swift file:

import heresdk

Add the Map View Programmatically

Add a map view variable by adding the following variable declaration to your ViewController class:

var mapView: MapView!

In your viewDidLoad() method, add the following code to initialize the map view:

override func viewDidLoad() {
    super.viewDidLoad()

    // Initialize MapView without a storyboard.
    mapView = MapView(frame: view.bounds)
    view.addSubview(mapView)
}

This gives the MapView the same size as the parent view and then adds it as a subview.

Add the Map View to a Storyboard

You might prefer not to initialize the MapView programmatically as shown above, but rather to build your UI from Xcode's Interface Builder using storyboards. In this case, you don't need to add the above lines to your view controller.

Instead, open your Main.storyboard and select the main view (nested under ViewController). In the Identity Inspector, under Custom Class, type MapView. For Module, type heresdk.

Now, open the Assistant editor, control-click the map view and drag it to your ViewController to create an outlet. The outlet window will pop up; for the name, type mapView and click connect. This will add the following line to your view controller:

@IBOutlet var mapView: MapView!

Now you have an IBOutlet accessible from your view controller which you can start to use. Note that this procedure does not contain any SDK specific actions. MapView behaves exactly like any other UIView.

Alternatively, can I use the map view together with SwiftUI? Yes, since the map view is a UIView subclass, you can wrap the view in a SwiftUI view that conforms to the UIViewRepresentable protocol as shown in this tutorial. Note that SwiftUI requires iOS 13 or higher.

Load a Map Scene

For this first app using the HERE SDK, we want to load one of the default map styles the SDK is shipped with.

In the viewDidLoad() method of our ViewController, we add the following code to load the scene with a map scheme representing a normalDay map render style:

mapView.mapScene.loadScene(mapScheme: MapScheme.normalDay, completion: onLoadScene)

As completion handler we can optionally implement a method that notifies us if loading the scene has succeeded:

// Completion handler when loading a map scene.
private func onLoadScene(mapError: MapError?) {
    guard mapError == nil else {
        print("Error: Map scene not loaded, \(String(describing: mapError))")
        return
    }

    // Configure the map.
    let camera = mapView.camera
    camera.lookAt(point: GeoCoordinates(latitude: 52.518043, longitude: 13.405991),
                  distanceInMeters: 1000 * 10)
}

Note that the completion handler is called on the main thread when loading the scene is done. MapError values other than nil will indicate what went wrong.

From MapView, you can access the Camera to set some custom map parameters like the location where you want the map centered on, and a zoom level which is specified by the camera's distance to earth:

let camera = mapView.camera
camera.lookAt(point: GeoCoordinates(latitude: 52.518043, longitude: 13.405991),
              distanceInMeters: 1000 * 10)

Note: You can setup the Camera as soon as you have a MapView instance available. However, you can see the changes only taking effect after the completion handler for loading a scene has finished.

As an exercise, you can try to replace the above map scheme with the following: .satellite. What do you get? Try out also other map schemes, like the normal night scheme.

Lastly, it is a good practice to handle the didReceiveMemoryWarning() of your view controller. The SDK provides the handleLowMemory() method to safely clean up any unused resources when it is requested by the OS:

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    mapView.handleLowMemory()
}

Now, it's time to build and run the app. If all goes well, you should see a HERE map covering the whole area of the screen. Congratulations, you have just mastered your first steps in using the HERE SDK for iOS.

Screenshot: Showing main map scheme.

Screenshot: Showing satellite map scheme.

Prepare your App for Distribution

The HERE SDK framework is a fat binary, built for device (arm64) and simulator (x86_64). Therefore it contains both architectures. This allows easy deployment on a simulator and on a real device.

Since the HERE SDK framework conforms to Apple's XCFramework bundle type (XCFW), it is ready to be used for the distribution of your app. As it is the practice, in Xcode you have to select a development team to sign your app, select a Generic iOS Device and select Product -> Archive.

Note: Signing is only needed when you plan to distribute your app to others, for example, to publish it on Apple's App Store. During the development phase of your app, this is not needed: You can directly deploy your app to an attached iOS device or run it on an iOS simulator.

Troubleshooting

When you run into trouble, please make sure to first check the minimum requirements and the supported devices.

  • I see only a blank white map: Make sure that your HERE credentials are valid and set as described in the Get Started section above. Also, make sure that your device is able to make an internet connection. With slower internet connections, it may take a while until you see the first map tiles loaded.
  • Xcode complains that MapView is not known: Make sure to integrate the HERE SDK framework as described in the Get Started section above.

Need Help?

If you need assistance with this or any other HERE product, select one of the following options.

  • If you have a HERE representative, contact them when you have questions/issues.
  • If you manage your applications and accounts through developer.here.com, log into your account and check the pages on the SLA report or API Health.
  • If you have more questions, please check stackoverflow.com/questions/tagged/here-api.
  • If you have questions about billing or your account, Contact Us.
  • If you have purchased your plan/product from a HERE reseller, contact your reseller.

results matching ""

    No results matching ""