Class MapStyle

java.lang.Object
com.codename1.maps.vector.MapStyle

public final class MapStyle extends Object
An ordered list of 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.
  • Constructor Details

    • MapStyle

      public MapStyle(String name, int backgroundColor)
      Creates an empty style with the given background color (0xAARRGGBB).
  • Method Details

    • getName

      public String getName()
      The style name.
    • getBackgroundColor

      public int getBackgroundColor()
      The viewport background color as 0xAARRGGBB.
    • add

      public MapStyle add(StyleLayer layer)
      Appends a layer rule (rendered in insertion order, bottom to top).
    • light

      public static MapStyle light()
      A clean light basemap (sensible default for most apps).
    • dark

      public static MapStyle dark()
      A dark basemap suited to night mode.
    • fromJson

      public static MapStyle fromJson(String json)
      Parses a (subset of a) MapLibre GL style JSON document. Recognized: the top-level 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.