TomTom Mobile SDK QuickStart Guide

Similar documents
Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

Arise Documentation. Release 2.7. Arise.io

Lab 6: Google Maps Android API v2 Android Studio 10/14/2016

android-espresso #androidespresso

Hello guys, In this tutorial, I am going to tell you that how we can integrate a custom framework in our Xcode project using cocoa pods.

This tutorial is meant for software developers who want to learn how to lose less time on API integrations!

Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial

Building Mapping Apps for ios With Swift

Android DP SDK Integration Guide

Fragments and the Maps API

Use the API or contact customer service to provide us with the following: General ios Android App Name (friendly one-word name)

Programming with Android: The Google Maps Library. Slides taken from

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation

Linkify Documentation

Google Maps Troubleshooting

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

AdFalcon ios SDK Developer's Guide. AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group

Upon completion of the second part of the lab the students will have:

NATIVE APP INTERCEPTS on ios & ANDROID

IOS - TEXT FIELD. Use of Text Field. Important Properties of Text Field. Updating Properties in xib

Step 1: Open Xcode and select Create a new Xcode Project from the Welcome to Xcode menu.

Lecture 13 Mobile Programming. Google Maps Android API

INTRODUCTION TO ANDROID

BlackBerry Developer Global Tour. Android. Table of Contents

Android - Widgets Tutorial

Google Maps library requires v2.50 or above.

iphone Programming Touch, Sound, and More! Norman McEntire Founder Servin Flashlight CodeTour TouchCount CodeTour

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Miscellaneous Topics

Our First Android Application

(Refer Slide Time: 1:12)

Building Applications with ArcGIS Runtime SDK for ios - Part I. Divesh Goyal Mark Dostal

Android Tutorial: Part 3

SD Module-1 Android Dvelopment

Introduction To JAVA Programming Language

HPE AppPulse Mobile. Software Version: 2.1. Adding AppPulse Mobile to Your ios App

My First iphone App (for Xcode version 6.4)

Android Programming วรเศรษฐ ส วรรณ ก.

Tutorial on Basic Android Setup

Fragments. Lecture 11

Fragments. Lecture 10

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L

Mobile Programming Lecture 1. Getting Started

Getting Started with Android Development Zebra Android Link-OS SDK Android Studio

Cheetah Orion Ad Platform SDK Guide (for Android) V1.0

Create an App that will drop PushPins onto a map based on addresses that the user inputs.

Lifecycle Callbacks and Intents

Android Application Development using Kotlin

webrtcpeer-android Documentation

Software Engineering Large Practical: Preferences, storage, and testing

ios Core Data Example Application

EMBEDDED SYSTEMS PROGRAMMING Android Services

API Guide for Gesture Recognition Engine. Version 2.0

Intel Multi-OS Engine. Vitaly Adobe

IEMS 5722 Mobile Network Programming and Distributed Server Architecture

Android Application Development. By : Shibaji Debnath

EMBEDDED SYSTEMS PROGRAMMING Android NDK

ArcGIS Runtime SDK for Android: Building Apps. Shelly Gill

Sample Spark Web-App. Overview. Prerequisites

Arrays of Buttons. Inside Android

CS 4330/5390: Mobile Application Development Exam 1

Mobile Apps 2010 iphone and Android

Intents. Your first app assignment

1. Implementation of Inheritance with objects, methods. 2. Implementing Interface in a simple java class. 3. To create java class with polymorphism

Android/Java Lightning Tutorial JULY 30, 2018

ios SDK Documentation February 8 By Midtrans

Mobile Software Development for Android - I397

Android SDK Documentation January 27. By Midtrans

Mobile Application Development Android

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Participant Handbook

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

32. And this is an example on how to retrieve the messages received through NFC.

EMBEDDED SYSTEMS PROGRAMMING UI and Android

ListView Containers. Resources. Creating a ListView

Creating a Custom ListView

Tutorial on OpenCV for Android Setup

Android UI Development

IBM Case Manager Mobile Version SDK for ios Developers' Guide IBM SC

Navigation bar (Xcode version 4.5.2) 1. Create a new project. From the Xcode menu, select File > New > Project

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.

An Overview of the Android Programming

Walkthrough: Binding an ios Objective-C Library

AdFalcon Android SDK Developer's Guide. AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group

Mobile and Ubiquitous Computing: Android Programming (part 3)

Android Sdk Setup For Windows 7 32 Bit Full Version

Hello World. Lesson 1. Create your first Android. Android Developer Fundamentals. Android Developer Fundamentals

Android Navigation Drawer for Sliding Menu / Sidebar

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

Screen Slides. The Android Studio wizard adds a TextView to the fragment1.xml layout file and the necessary code to Fragment1.java.

ANDROID APPS (NOW WITH JELLY BEANS!) Jordan Jozwiak November 11, 2012

Software Practice 3 Before we start Today s lecture Today s Task Team organization

Android Programming - Jelly Bean

Xcode 6 and ios 8 What s New for Software Developers

Software Engineering Large Practical: Storage, Settings and Layouts. Stephen Gilmore School of Informatics October 27, 2017

Getting Started with Apple ios Development Link-OS SDK Objective-C

Building MyFirstApp Android Application Step by Step. Sang Shin Learn with Passion!

Java & Android. Java Fundamentals. Madis Pink 2016 Tartu

Mobile Application Development

Transcription:

TomTom Mobile SDK QuickStart Guide

Table of Contents Introduction... 3 Migrate to TomTom ios... 4 Prerequisites...4 Initializing a map...4 Displaying a marker...4 Displaying traffic...5 Displaying a route/directions...5 Going further...6 Helpful links:...6 Migrate to TomTom Android... 7 Prerequisites...7 Initializing a map...7 Displaying a marker...7 Displaying traffic...8 Displaying a route/directions...8 Going further...9 Helpful links...9 Thank you... 10 2

Introduction Welcome to the TomTom Mobile SDK QuickStart Guide! This document compiles various handy tutorials from the TomTom developer page to get you started fast. The Migrate to TomTom section serves as a how-to for basics like displaying a map, adding custom markers, traffic and routing layers. Each section concludes with links to advanced examples to go even further. Let s get started! 3

Migrate to TomTom ios Prerequisites Before you start writing code, prepare your environment: 1. Ensure that XCode and ios simulator are installed. 2. Ensure that Cocoapods is installed on your system. The TomTom Maps SDK for ios is delivered as a Cocoapods pod. 3. Create a new Single View App project with a deployment target of 9.1 or higher. After the project has been successfully created, close it and create an empty Podfile by executing a 'pod init' command inside the project folder. 4. Open the Podfile and paste the following lines inside a 'target' section: pod 'TomTomOnlineSDKMaps' pod 'TomTomOnlineSDKRouting' pod 'TomTomOnlineSDKMapsUIExtensions' 5. Save and close the Podfile. 6. Execute the command 'pod install'. Cocoapods will install all of the required dependencies. 7. Open a *.xcworkspace file in Xcode. 8. Obtain an API Key Initializing a map Provide TomTom API key inside the Info.plist file. <key>onlinemap.key</key> <string>your_key_goes_here</string> <key>onlinetraffic.key</key> <string>your_key_goes_here</string> <key>onlinerouting.key</key> <string>your_key_goes_here</string> 1. Import the appropriate header inside the ViewController.h file: #import <TomTomOnlineSDKMaps/TomTomOnlineSDKMaps.h> 2. Add a TTMapView property inside the ViewController.m file. Initialize the map by instantiating a TTMapView object and switching the ViewController view to the TTMapView view @interface ViewController () @property TTMapView* mapview; @end @implementation ViewController - (void)viewdidload { [super viewdidload]; self.mapview = [[TTMapView alloc] initwithframe:self.view.frame]; CLLocationCoordinate2D amsterdamcoords = CLLocationCoordinate2DMake(52.377271, 4.909466); [self.mapview centeroncoordinate:amsterdamcoords withzoom:11]; self.view = self.mapview; Displaying a marker Use a TTAnnotation object to display a marker: TTAnnotation *annotation = [TTAnnotation annotationwithcoordinate:amsterdamcoords]; [self.mapview.annotationmanager addannotation:annotation]; 4

Displaying traffic TomTom provides two kinds of traffic information: Traffic flow shows the difference between current and free flow speed. Green indicates that the speeds are the same, meaning there are no traffic jams. Red indicates that traffic is much slower than free flow, meaning that there are traffic jams. Traffic incidents indicates specific traffic problems such as closed roads, rain, or accidents. 1. You can show traffic incidents, traffic flow, or both: self.mapview.trafficincidentsstyle = TTTrafficIncidentsStyleRaster; self.mapview.trafficincidentson = YES; self.mapview.trafficflowon = YES; Displaying a route/directions 1. Import the 'TomTomOnlineSDKRouting.h' header in ViewController.h: #import <TomTomOnlineSDKRouting/TomTomOnlineSDKRouting.h> 2. Update ViewController.h so that it conforms to the TTRouteResponseDelegate protocol. @interface ViewController : UIViewController <TTRouteResponseDelegate> - (void)route:(ttroute *)route completedwithresult:(ttrouteresult *)result; - (void)route:(ttroute *)route completedwithresponseerror:(ttresponseerror *)responseerror; @end 3. Create and initialize TTRoute and TTRouteQuery objects inside the viewdidload method in ViewController.m. CLLocationCoordinate2D routestart = CLLocationCoordinate2DMake(52.376368, 4.908113); CLLocationCoordinate2D routestop = CLLocationCoordinate2DMake(52.372281, 4.846595); TTRouteQuery *routequery = [[[TTRouteQueryBuilder alloc] initwithdest:routestop withorig:routestart] build]; TTRoute *route = [[TTRoute alloc] init]; [route planroutewithquery:routequery withasyncdelegate:self]; The code above builds a TTRouteQuery object from two route points. It then initializes a TTRoute object and sends the 'planroutewithquery'message to it. The message has two parameters: the newly created routequery object and a pointer to the ViewController instance to allow the 'completedwithresult' method to be called. 4. Finally, provide an implementation for the 'completedwithresult' method inside of the ViewController.m file: - (void)route:(ttroute *)route completedwithresult:(ttrouteresult *)result { for(ttfullroute *fullroute in result.routes) { TTMapRoute *maproute = [TTMapRoute routewithroutedata:fullroute]; [self.mapview.routemanager addroute:maproute]; maproute.active = YES; }} The above method provides a TTRouteResult object containing TTFullRoute objects. It then loops through the TTFullRoute collection. For each TTFullRoute object, it creates a new TTMapRoute instance and adds it to the MapView. 5

Going further Now you're ready to explore more awesome TomTom functionality with some more advanced tutorials and examples: Map tiles Traffic layers Routing examples Search examples Helpful links Getting a free API key and creating a local setup for the TomTom Maps SDK for ios. Source code on GitHub 6

Migrate to TomTom Android Prerequisites Before you start writing code, prepare your environment: 1. Install Android Studio. During installation, make sure that the component "Android Virtual Device" is selected. 2. If possible, start a new project (minimum SDK API 19 Android 4.4 KitKat ) with an Empty activity. You can use your own project as long as it meets the minimum Android SDK API level requirement 3. Update the Source Compatibility and Target Compatibility to 1.8 in the Project Structure dialog (click File > Project Structure). 4. Add the TomTom repository to your project's gradle.build file: allprojects { repositories { google() jcenter() maven { url "https://maven.tomtom.com:8443/nexus/content/repositories/releases/" }}} 5. Create and add an API key to AndroidManifest.xml: Copy and paste the API key to your AndroidManifest.xml inside the <application> tag: <meta-data android:name="onlinemaps.key" android:value="<your_key_goes_here>" /> <meta-data android:name="onlinetraffic.key" android:value="<your_key_goes_here>" /> <meta-data android:name="onlinesearch.key" android:value="<your_key_goes_here>" /> <meta-data android:name="onlinerouting.key" android:value="<your_key_goes_here>" /> Initializing a map 1. Add dependencies to your module's gradle.build file: api("com.tomtom.online:sdk-maps:2.085@aar") { transitive = true} 2. Add a map fragment to the main activity layout: <fragment android:id="@+id/mapfragment" android:name="com.tomtom.online.sdk.map.mapfragment" android:layout_width="match_parent" android:layout_height="match_parent" /> Displaying a marker 1. Define field map in MainActivity: private TomtomMap map; 2. Implement an OnMapReadyCallback interface in your MainActivity class and override the onmapready method: @Override public void onmapready(@nonnull TomtomMap tomtommap) { this.map = tomtommap; LatLng amsterdam = new LatLng(52.37, 4.90); SimpleMarkerBalloon balloon = new SimpleMarkerBalloon("Amsterdam"); tomtommap.addmarker(new MarkerBuilder(amsterdam).markerBalloon(balloon)); tomtommap.centeron(cameraposition.builder(amsterdam).zoom(7).build());} 7

3. Inside the MainActivity oncreate method, get the map fragment instance and set a callback object on MainActivity so that the onmapready method is called: MapFragment mapfragment = (MapFragment) getsupportfragmentmanager().findfragmentbyid(r.id.mapfragment); mapfragment.getasyncmap(this); Displaying traffic Create two simple buttons to work with traffic on the map. One enables the traffic layer, and the other disables it. TomTom provides two services that offer traffic information: Traffic flow shows the difference between current and free flow speed. Green indicates that the speeds are the same, meaning there are no traffic jams. Red indicates that traffic is much slower than free flow, meaning that there are traffic jams. Traffic incidents indicates specific traffic problems such as closed roads, rain, ice on the road, or accidents. 1. Create the buttons to handle traffic visualization and call the turnonrastertrafficincidents and turnonrastertrafficflowtiles methods on the map UiSettings object, choosing whether to display traffic flow tiles, traffic incident tiles, both, or none. Button btntrafficon = findviewbyid(r.id.btntrafficon); btntrafficon.setonclicklistener(new View.OnClickListener() { @Override public void onclick(view v) { map.getuisettings().turnonrastertrafficincidents(); map.getuisettings().turnonrastertrafficflowtiles(); } }); Button btntrafficoff = findviewbyid(r.id.btntrafficoff); btntrafficoff.setonclicklistener(new View.OnClickListener() { @Override public void onclick(view v) { map.getuisettings().turnofftraffic(); } }); Displaying a route/directions 1. Add a dependency to the module's gradle.build file: api("com.tomtom.online:sdk-routing:2.085@aar") {transitive = true } 2. Now add a button for displaying the route to the main activity layout XML file: <Button android:id="@+id/btnrouteshow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="8dp" android:layout_marginend="8dp" android:layout_marginstart="8dp" android:text="route SHOW" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintend_toendof="parent" app:layout_constraintstart_tostartof="parent" /> 3. Finally, add a proper handler for our new button: Planning a route requires at least two location points (e.g.: your house and the store). Create an instance of the RoutingApi object by calling OnlineRoutingApi.create method. Then construct a route query using the 8

selected location points. There are other options that allow the app to plot different kinds of routes (fastest, shortest, etc). The planroute returns an observable RouteResult object. You can get FullRoute objects from the RouteResult.getRoutes() method, create a new RouteBuilder object from each of them, and add them to your map. Button btnrouteshow = findviewbyid(r.id.btnrouteshow); btnrouteshow.setonclicklistener(new View.OnClickListener() { @Override public void onclick(view v) { LatLng amsterdam = new LatLng(52.37, 4.90); LatLng hague = new LatLng(52.07, 4.30); RoutingApi routingapi = OnlineRoutingApi.create(getApplicationContext()); RouteQuery routequery = new RouteQueryBuilder(amsterdam, hague).withroutetype(routetype.fastest); routingapi.planroute(routequery).subscribeon(schedulers.newthread()).observeon(androidschedulers.mainthread()).subscribe(routeresult -> { for (FullRoute fullroute : routeresult.getroutes()) { RouteBuilder routebuilder = new RouteBuilder( fullroute.getcoordinates()).isactive(true); map.addroute(routebuilder); } }); }}); Going further Now you're ready to explore more awesome TomTom functionality with some more advanced tutorials and examples: Map tiles Traffic layers Routing examples Search examples Helpful links Getting a free API key and creating a local setup for the TomTom Maps SDK for Android. Source code on Github 9

Thank you Thank you for using TomTom. We hope this guide was helpful and look forward to seeing what you will build. Thank you! 10