Skip to content

Custom styles

Jiří M. aka Menion edited this page Oct 9, 2016 · 1 revision

Basics

Every point or track in Locus may have own custom style.

Styles are defined in class ExtraStyle and every GeoData class (Waypoint and Track extends it) has defined public styleNormal (for common display of item) and styleHighlight (for highlight after selection) parameters. Let's look at them closer.

Use style container

To create style container for points/tracks, simply use

ExtraStyle style = new ExtraStyle()

and attach it to point/track with

point.styleNormal = style;

Set icon for points

To define icon for points, just set this icon to existing ExtraStyle container

style.setIconStyle("http://www.googlemapsmarkers.com/v1/009900/", 1.0f);

Recommended Uri value is defined as http:/ value, anyway local file with file:/ prefix is also supported. For smaller icons is also possible to use image encoded with Base64 as data:image/... value.

Optionally you may use

style.setIconStyle(iconUrl, color, heading, scale)

which allows to modify color of icon and also it's rotation (in degrees) on the map.

Styling PackWaypoints

Recommended method for using styles & more points, is styling directly PackWaypoints container. In this case, we may attach ExtraStyle like

pack.setExtraStyle(style);

or in this case is possible directly use Bitmap icons

pack.setBitmap(bitmap);

Set style for tracks

For tracks are prepared two main options

Styling track lines

To style color and width of lines, use

style.setLineStyle(color, width)

`method, where width is simple value in pixels, or more advanced

style.setLineStyle(style, color, width, units)

which allows to define special style coloring options (parameter style) and also choose if width will be defined in pixels or real metres (parameter units). Special style parameter is really powerful tool that allows to colorize track by speed, altitude, accuracy and some other parameters.

Styling track fill

In case, we wants to fill track area with certain color, use

style.setPolyStyle(color, fill, outline)
Clone this wiki locally