Transcript
Page 1: Intro to apps with maps for series 40

Application Development with Nokia Maps and Location APIs for Series 40

Nokia Series 40

1 © Nokia 2012 Intro to Maps on Apps.pptx

Jason Fox Technical Support Engineer Maps Platform

Page 2: Intro to apps with maps for series 40

1. Introduction to Nokia Maps API for Java ME

2. Getting Started - Prerequisites 3. Basic Mapping Concepts 4. An Introduction to the Search and

Routing Services 5. An Introduction to positioning (JSR-179)

Agenda

2 © Nokia 2012 Intro to Maps on Apps.pptx

Page 3: Intro to apps with maps for series 40

Nokia Maps API for Java ME

3 © Nokia 2012 Intro to Maps on Apps.pptx

Page 4: Intro to apps with maps for series 40

What is Nokia Maps API for Java ME?

4 © Nokia 2012 Intro to Maps on Apps.pptx

Full details at : http://www.developer.nokia.com/Develop/Maps/Maps_API_for_Java_ME/

• API aimed at Series 40 Phones. Allows you to develop mobile applications based on Nokia Maps.

• Façade Pattern - hides all the “plumbing” code - the low level connection calls, image manipulation etc.

• Targets devices supporting MIDP 2.0 or higher.

• Not currently part of the SDK

• Single downloadable JAR around 150 kB.

• Faster App development. Better App performance

Page 5: Intro to apps with maps for series 40

Why use Nokia Maps API for Java ME?

5 © Nokia 2012 Intro to Maps on Apps.pptx

• Multiple map types optimised for mobile displays

• Low latency and reduced network traffic compared with static map image solutions.

• “Out-of-the box” support for common mapping use cases (Markers, Images, Polygons, Polylines, Pan and Zoom)

• In-built libraries to access search, routing and POI information services.

• Map Components are open to extension -

ability to customise and override standard API functionality.

• Advanced Features as standard, such as KML parsing and the addition of custom overlays

Page 6: Intro to apps with maps for series 40

Comparison of Nokia Maps for Java ME vs. Static Map Image Solutions

6 © Nokia 2012 Intro to Maps on Apps.pptx

Static Map (e.g. RESTful Map API) • one single http request per map ->one single image returned in response • new request for each alteration. Maps for Java ME • multiple http requests for individual map tiles. • Map tiles are cached. • Map tiles stitched together and objects

added to display result on screen • Additional requests only made if necessary.

Result • Reduced latency and lowered network traffic though built-in intelligent

map rendering, caching and tiling = Better for Mobile.

Page 7: Intro to apps with maps for series 40

Prerequisites

7 © Nokia 2012 Intro to Maps on Apps.pptx

Page 8: Intro to apps with maps for series 40

Prerequisites

8 © Nokia 2012 Intro to Maps on Apps.pptx

1. Install a Java Runtime Environment 6 http://www.java.com/en/download/index.jsp

2. Install an IDE (e.g. NetBeans) Netbeans.org

3. Install a Nokia SDK for Java (free) http://www.developer.nokia.com/Develop/Java/Tools/

Page 9: Intro to apps with maps for series 40

2.

Prerequisites

9 © Nokia 2012 Intro to Maps on Apps.pptx

4. Configure Nokia SDK in NetBeans

1.

3.

Page 10: Intro to apps with maps for series 40

Prerequisites

10 © Nokia 2012 Intro to Maps on Apps.pptx

5. Download the binary Jar http://www.developer.nokia.com/Develop/Maps/Maps_API_for_Java_ME/Getting_started/

Page 11: Intro to apps with maps for series 40

Prerequisites

11 © Nokia 2012 Intro to Maps on Apps.pptx

6. Register as a developer free at www.developer.nokia.com

Page 12: Intro to apps with maps for series 40

Prerequisites

12 © Nokia 2012 Intro to Maps on Apps.pptx

7. Obtain a free set of authentication credentials (App Id and Token) from: https://api.developer.nokia.com/ovi-api/ui/registration − A unique App ID and Token, are required for each application

8. After creating a new NetBeans project, You must add a reference to the Nokia Maps API binary jar itself - Maps_API.jar. This reference is added under the ”Resources” folder in theNetBeans project.

Page 13: Intro to apps with maps for series 40

Basic Mapping Concepts

13 © Nokia 2012 Intro to Maps on Apps.pptx

• The Minimal Map

• An Introduction to Map Types

• Map Languages

• Markers

• Polylines and Polygons

• Interaction

Page 14: Intro to apps with maps for series 40

The Minimal Map

14 © Nokia 2012 Intro to Maps on Apps.pptx

A Pannable Zoomable Map in five lines of code 1. Set credentials in the ApplicationContext

2. Create a MapCanvas

3. Set it as the current Display

Page 15: Intro to apps with maps for series 40

Map Types

15 © Nokia 2012 Intro to Maps on Apps.pptx

Pick the right map type for your app

Page 16: Intro to apps with maps for series 40

Map Types – Simple Method

16 © Nokia 2012 Intro to Maps on Apps.pptx

The Standard Map Schemes

The Code

Page 17: Intro to apps with maps for series 40

Map Types – Advanced Method

17 © Nokia 2012 Intro to Maps on Apps.pptx

1) Implement a MapSchemeListener and call getAvailableMaps()

2) Handle Success and Failure

3) Set the BaseMapType from MapProviders received

Page 18: Intro to apps with maps for series 40

Map Languages

18 © Nokia 2012 Intro to Maps on Apps.pptx

• Currently eight map Languages available Arabic, Chinese, German, English, French, Italian, Russian and Spanish

• Just set the DefaultLanguage in the ApplicationContext

• By default Maps are displayed in English

Page 19: Intro to apps with maps for series 40

Map Markers

19 © Nokia 2012 Intro to Maps on Apps.pptx

Markers highlight points of interest at a specified location on the map - two types exist: • MapStandardMarker

• Various Geometric Shapes plus Balloon • Easy to add text, change color (and opacity)

• MapMarker • Used to add graphical icons. • Need to define an anchor point.

• Use the MapFactory to created instances of MapStandardMarkers and MapMarkers

• Default marker is a ‘Nokia Blue’ Balloon

Page 20: Intro to apps with maps for series 40

Polylines and Polygons

20 © Nokia 2012 Intro to Maps on Apps.pptx

• A MapPolyline is a series of connected points

• A MapPolygon is the area within a closed loop of points

• Every instance of a MapPolygon or MapPolyline is created using the MapFactory

• Both objects have an implicit GeoBoundingBox.

Page 21: Intro to apps with maps for series 40

MapCanvas MapDisplay MapObject

21 © Nokia 2012 Intro to Maps on Apps.pptx

• MapCanvas holds a MapFactory and a MapDisplay

• Use the MapFactory to create MapObjects

• Can also use MapFactory to create

a MapDisplay directly e.g. for automatic caching of Static Maps

• The MapDisplay contains MapObjects but is also a

MapObject itself.

• MapObjects may be also be contained within a MapContainer

Page 22: Intro to apps with maps for series 40

Map Events

22 © Nokia 2012 Intro to Maps on Apps.pptx

• Create a MapComponent to interact with your MapDisplay

• Add an EventListener to your MapComponent to receive notifications of screen interactions and key presses

Page 23: Intro to apps with maps for series 40

An Introduction to Location-Based Services

23 © Nokia 2012 Intro to Maps on Apps.pptx

• Search (Geocoding and Reverse Geocoding)

• Places Search

• Routing

• Sharing

Page 24: Intro to apps with maps for series 40

Geocoding Search

24 © Nokia 2012 Intro to Maps on Apps.pptx

• Finds a location on the Map from a given Address

• Search can be either synchronous or asynchronous.

• Asynchronous search is preferred.

1. Implement a GeoCodeRequestListener

2. Create a GeoCodeRequest

3. Handle Success or Failure

Page 25: Intro to apps with maps for series 40

Reverse Geocoding Search

25 © Nokia 2012 Intro to Maps on Apps.pptx

• Finds the Address for a given geographic location. • Search can be either synchronous or asynchronous. • Asynchronous search is preferred.

1. Implement a ReverseGeocodeRequestListener

2. Create a ReverseGeoCodeRequest

3. Handle Success or Failure

Page 26: Intro to apps with maps for series 40

Places Search

26 © Nokia 2012 Intro to Maps on Apps.pptx

• Flexible Local Search • General Text Search (e.g. “Pizza”) • Category Search (e.g. restaurant) • Combined Search (e.g. “Italian” + restaurant)

• Drill down to get more details

• Contact Details • Opening Times • Description and Reviews • Images etc.

Page 27: Intro to apps with maps for series 40

Places Search

27 © Nokia 2012 Intro to Maps on Apps.pptx

1. Implement a PlaceSearchRequestListener

2. Create a PlaceSearchRequest

3. Handle Success or Failure

4. More details can be obtained by interrogating the Result

Page 28: Intro to apps with maps for series 40

Routing Service

28 © Nokia 2012 Intro to Maps on Apps.pptx

• Routing Service consists of creating a route between two or more Waypoints.

• Responses from the Routing service can take time. Make your RouteRequests asynchronously.

1. Implement a RouteListener

2. Create a RouteRequest

3. Handle Success or Failure

Page 29: Intro to apps with maps for series 40

• Routing Type – default is RoutingType.Shortest

• Mode of Transport – default is TransportMode.CAR

• Additional Restrictions – None are selected by default

Routing Service

29 © Nokia 2012 Intro to Maps on Apps.pptx

• The preferred route calculation can be optimized by altering the parameters of the RoutingMode

Page 30: Intro to apps with maps for series 40

Sharing Manager

30 © Nokia 2012 Intro to Maps on Apps.pptx

• Creates short encrypted URLs for the RESTful Maps API

• Send URL as an SMS for a client to receive a static map.

• Service forwards to maps.nokia.com or m.maps.nokia.com on capable browsers

Page 31: Intro to apps with maps for series 40

Positioning

31 © Nokia 2012 Intro to Maps on Apps.pptx

• Separate Optional Package for Positioning (JSR-179)

• Frequently combined with the Nokia Maps API for Java ME, though not part of the API itself

• Two location methods maybe available • Cell ID positioning • GPS

Page 32: Intro to apps with maps for series 40

Cell-ID Location

32 © Nokia 2012 Intro to Maps on Apps.pptx

• A MIDlet can obtain an approximate position using the Cell-ID location method.

• The method consists of passing the ID of the cell the device is currently connected to, on to a look-up service. The service will then return the well-known position of the given cell-ID.

• This Cell ID location provides a method of positioning mobile devices which do not contain a GPS unit.

Note: the degree of uncertainty can vary of a few meters to hundreds of kilometers, depending upon the infrastructure of the local network and the data available to the look-up service for that region

Page 33: Intro to apps with maps for series 40

Cell-ID Example

1) Create a Cell-ID LocationProvider using LocationUtils Note: The second parameter of getLocationProvider() is currently always null. This leaves the library open for future extension

2) Make a call to getLocation() and process the result

The attributes of the QualifiedCoordinate class map directly onto the GeoCoordinate class.

Set up a loop and poll to obtain location updates.

© Nokia 2012 Intro to Maps on Apps.pptx 33

Page 34: Intro to apps with maps for series 40

LocationUtil • The preferred Location method(s) can

be any combination of the methods defined in JSR-179:

Useful Combinations • Offline Cell ID

• Standalone GPS

• Assisted GPS

• Online Cell ID an/or WLAN

© Nokia 2012 Intro to Maps on Apps.pptx 34

Page 35: Intro to apps with maps for series 40

GPS Example

1. Create a GPS LocationProvider

2. Set the provider to start polling

3. Retrieve and process the result

© Nokia 2012 Intro to Maps on Apps.pptx 35

Page 36: Intro to apps with maps for series 40

For More Information

Download the latest Nokia SDK for Java http://developer.nokia.com Consult the Nokia Developer Library http://library.developer.nokia.com Nokia Maps API http://developer.nokia.com/Maps

36 © Nokia 2012 Intro to Maps on Apps.pptx


Top Related