Maps

The core feature of the Sygic Android SDK is Maps. The key concepts covered in this section include adding a map to an Android application, changing the location displayed by the map and its various properties. The classes covered include MapFragment and MapView. The MapFragment is a standard Android Fragment derived component. MapView is a class for controlling the displayed map. To obtain an instance of MapView you call asynchronous MapFragment.getMapAsync():

In the preceding code the GeoCoordinates for the map center is created by a call to the new GeoCoordinates(double, double) constructor.

Map Handling

Once the MapView is initialized, it can be manipulated and interacted in a variety of ways. Some key attributes of the MapView are its orientation, tilt, geographical center (geoCenter), and zoom level (zoom). You can use these to customize the displayed map via the Camera class.

Zoom Level

The size of the geographical area displayed by Map can be controlled by changing the zoom level.

// Set the zoom to for example 18.5.
map.getCamera().setZoomLevel(18.5f);
// Get the zoom level, should be 18.5.
float zoom = map.getCamera().getZoomLevel();

Rotation

The map can be orientated in any direction. By default, the rotation is in a true North position. The following code changes the orientation to South-up.

Default map click handling

Touches on map are handled internally by MapFragment. If you want to perform an action on click (like displaying context menu, bubble over map, etc...) you have to register MapGestureListener. We also provide the MapGestureAdapter class, that provides default implementations, so you can override only those methods you need.

Map Schemes

There are some map schemes available to offer your application users a choice among different kinds of map appearance. The list of available schemes can be obtained by:

final List<String> availableSkins = map.getAvailableSkins();

Some of the options are "default", "day", "night", "car", "pedestrian". Schemes can be combined, as they are only incremental. More info on scheme configuration and possibility to create own schemes is coming soon.

map.setActiveSkin(Arrays.asList("day", "pedestrian", "default"));

Day skin Night Skin

Sygic SDK does not automatically switch map schemes during navigation mode. Before starting car or pedestrian navigation, be sure to save the current map scheme and switch to the appropriate navigation map scheme.

Gestures

The MapView class responds to a number of predefined touch gestures. The default behavior of the map for each gesture type may be used as-is, supplemented, or replaced entirely. The following table is a summary of the available gestures and their default behavior.

Set return value true if the listener has consumed the event, false otherwise. If false is returned, default gesture action will be executed.

Objects and Interaction

The Sygic Mobile SDK allows the addition of a variety of objects, each with a specific purpose, to a map view. The types of available object include map markers, routes, polylines, circles. To see all the objects check the MapObject.MapObjectType. Some objects are described in more detail below.

In order to display the map object on the map, the object needs to be added to an MapView by calling addMapObject().

MapCircle

Enables you to draw a circle on the map at a fixed geographical location. You can customize you circle's color, radius, lineColor - see the MapCircle API reference for more information.

MapPolyline

Enables you can draw one or more connected line segments on the map. The segment vertices are specified by a series of GeoCoordinates. The visual appearance of the polyline can be also customized. See the MapPolyline API reference for more information.

Offline Maps

Applications developed with the Sygic Android SDK have the ability to pre-load map data, allowing the use of maps, search, routing, and other features without an active data connection. To download any map, a MapEntry object must be obtained, via listing of continents and maps for continent.