Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class MapStyle
- Object
- MapStyle
StyleLayer rules plus a background color, describing
how a vector tile is painted. The built-in light and dark styles
target the common OpenMapTiles/Protomaps source-layer names and also the
simplified names used by the bundled screenshot fixtures, so they render
real basemaps and the offline fixtures alike.Constructors
public MapStyle(String name, int backgroundColor) | Creates an empty style with the given background color (0xAARRGGBB). |
Methods
public String getName() | The style name. |
public int getBackgroundColor() | The viewport background color as 0xAARRGGBB. |
public MapStyle add(StyleLayer layer) | Appends a layer rule (rendered in insertion order, bottom to top). |
public static MapStyle light() | A clean light basemap (sensible default for most apps): muted land, soft water and parks, and roads that read by their importance – main roads wider and faintly tinted, every road edged so that it stands off the land, side streets and buildings only once the map is close enough for them to mean something. |
public static MapStyle dark() | A dark basemap suited to night mode. |
public static MapStyle fromJson(String json) | Parses a (subset of a) MapLibre GL style JSON document. |
Inherited methods
Constructor details
MapStyle
public MapStyle(String name, int backgroundColor)Method details
getName
public String getName()getBackgroundColor
public int getBackgroundColor()add
public MapStyle add(StyleLayer layer)light
public static MapStyle light()A clean light basemap (sensible default for most apps): muted land, soft water and parks, and roads that read by their importance – main roads wider and faintly tinted, every road edged so that it stands off the land, side streets and buildings only once the map is close enough for them to mean something. Settlement names are joined by the names of main roads and parks from zoom 12, side streets from zoom 14 and points of interest from zoom 16, when the tile source supplies those names.
Every colour falls back to the value baked in here but is overridable
through a theme constant (a CSS color string) so an app can recolour the
map without supplying a whole style: mapLightWaterColor,
mapLightLandcoverColor, mapLightLanduseColor, mapLightParkColor,
mapLightRoadColor, mapLightMajorRoadColor, mapLightRoadCasingColor,
mapLightBuildingColor, mapLightBackgroundColor, mapLightLabelColor,
mapLightRoadLabelColor, mapLightLabelHaloColor. e.g. a theme constant
mapLightWaterColor=#1e88e5.
dark
public static MapStyle dark()light(), with the same
order of importance in dark tones: each colour is overridable via a
theme constant (mapDarkWaterColor, mapDarkLandcoverColor,
mapDarkLanduseColor, mapDarkParkColor, mapDarkRoadColor,
mapDarkMajorRoadColor, mapDarkRoadCasingColor,
mapDarkBuildingColor, mapDarkBackgroundColor, mapDarkLabelColor,
mapDarkRoadLabelColor, mapDarkLabelHaloColor).fromJson
public static MapStyle fromJson(String json)layers array with type of background/fill/
line/symbol, each layer’s source-layer, minzoom/maxzoom,
a simple ["==", key, value] filter, and the common paint/layout
properties (background-color, fill-color, line-color,
line-width, text-field, text-color, text-size). Unsupported
constructs are ignored rather than failing.