Documentation for maplib/Map.kt

data class RGBA

Color representation

RGBA color

fun constructor(R: Int, G: Int, B: Int, A: Int)

Main constructor

Параметры
  • R – R a red color

  • G – G a green color

  • B – B a blue color

  • A – A an alpha color

val R : Int

R a red color

val G : Int

G a green color

val B : Int

B a blue color

val A : Int

A an alpha color

class MapDocument

MapDocument class.

The ordered array of layers.

fun constructor(id: Int, path: String, bkColor: RGBA = API.mapGetBackgroundColorInt(id))

Main constructor

Параметры
  • id – d map identifier

  • path – h map file path

val id : Int

d map identifier

val path : String

h map file path

var scale : Double

Map scale read/write property.

var center : Point

Map center read/write property. The point coordinates should be geographic, not screen.

val layerCount : Int

Map layer count readonly property.

var extent : Envelope

Map extent read/write property.

fun close()

Close map. The map resources (layers, styles, etc.) will be freed.

fun reopen() : Boolean

Reopen map.

Результат

true if map reopened successfully.

fun setBackgroundColor(color: RGBA)

Set map background.

Параметры
  • color – background color

fun setSize(width: Int, height: Int)

Set map viewport size. MapView executes this function on resize.

Параметры
  • width – map width in pixels.

  • height – map height in pixels.

fun save() : Boolean

Save map.

Результат

true if map saved successfully.

fun addLayer(name: String, source: Object) : Layer?

Add layer to map.

Параметры
  • name – layer name.

  • source – layer datasource.

Результат

Layer class instance or null on error.

fun deleteLayer(layer: Layer) : Boolean

Remove layer from map.

Параметры
  • layer – Layer class instance.

Результат

True if delete succeeded.

fun deleteLayer(position: Int) : Boolean

Remove layer from map.

Параметры
  • position – Layer index.

Результат

True if delete succeeded.

fun getLayer(position: Int) : Layer?

Get map layer.

Параметры
  • position – Layer index.

Результат

Layer class instance.

fun setOptions(options: Map<String, String>) : Boolean = API.mapSetOptionsInt(id, options)

Set map options.

Параметры
  • options – key-value dictionary. The supported keys are:

  • ZOOM_INCREMENT - Add integer value to zoom level correspondent to scale. May be negative.

  • VIEWPORT_REDUCE_FACTOR - Reduce view size on provided value. Make sense to decrease memory usage.

Результат

True on success

fun setExtentLimits(minX: Double, minY: Double, maxX: Double, maxY: Double) : Boolean = API.mapSetExtentLimitsInt(id, minX, minY, maxX, maxY)

Set map extent limits. This limits prevent scroll out of this bounding box.

Параметры
  • minX – minimum x coordinate.

  • minY – minimum y coordinate.

  • maxX – maximum x coordinate.

  • maxY – maximum y coordinate.

Результат

True on success

fun reorder(before: Layer?, moved: Layer)

Reorder map layers.

Параметры
  • before – Before layer class instance will moved layer insert. If before = null, layyer will be moved to the end of layers tree.

  • moved – Layer class instance to move.

fun identify(x: Float, y: Float, limit: Int = 0) : Array<Feature>

Search features in buffer around click/tap position.

Параметры
  • x – position.

  • y – position.

  • limit – max count return features.

Результат

Array of Features.

fun select(features: List<Feature> = listOf())

Highlight feature in map layers. Change the feature style to selection style. The selection style mast be set in map.

Параметры
  • features – Features array. If array is empty the current highlighted features will get layer style and drawn not highlighted.

fun getLayerForFeature(feature: Feature) : Layer?

Get layer by feature belongs the datasource of correspondent layer.

Параметры
  • feature – Feature belongs the datasource of correspondent layer.

Результат

Layer class instance or null.

fun invalidate(extent: Envelope)

Invalidate part of the map.

Параметры
  • extent – Extent to invalidate

fun selectionStyle(type: SelectionStyleType) : JsonObject

Get selection style

Параметры
  • type – Style type

Результат

Json object with style

fun selectionStyleName(type: SelectionStyleType) : String

Get selection style name

Параметры
  • type – Style type

Результат

Style name string

fun setSelectionStyle(style: JsonObject, type: SelectionStyleType) : Boolean

Set selection style

Параметры
  • style – Json object with style. See Layer.style

  • type – Selection style type

Результат

True on success.

fun setSelectionStyleByName(name: String, type: SelectionStyleType) : Boolean

Set selection style name

Параметры
  • name – Style name. See Layer.styleName

  • type – Selection style type

Результат

True on success.

fun getOverlay(type: Overlay.Type) : Overlay?

Get map overlay

Параметры
  • type – Overlay type.

Результат

Overlay class instance or null.

fun addIconSet(name: String, path: String, move: Boolean) : Boolean

Add iconset to map. The iconset is square image 256 x 256 or 512 x 512 pixel with icons in it.

Параметры
  • name – Iconset name.

  • path – Path to image if file system.

  • move – If true the image will be deleted after successfully added to map document.

Результат

True on success.

fun removeIconSet(name: String) : Boolean

Remove iconset from map.

Параметры
  • name – Iconset name.

Результат

True on success.

fun isIconSetExists(name: String) : Boolean

Validate iconset exists in map.

Параметры
  • name – Iconset name.

Результат

True if exists.

enum class SelectionStyleType

@enum Map selection style types. In map can be configured styles for point, line and polygon (and multi…) layers. The styles are common for all layers.

  • UNKNOWN = 0

  • POINT = 1 : point

  • LINE = 2 : linestring

  • FILL = 3 : polygon

enum class DrawState

Map drawing state enum

  • NORMAL = 1 : Normal draw. Only new tiles will be filled with data to draw.

  • REDRAW = 2 : All cached data will be drop. Tiles deleted from memory. All tiles in screen will be filled with data to draw.

  • REFILL = 3 : All tiles will be mark need to fill with data to draw.

  • PRESERVED = 4 : Just update scree with cached data.

  • NOTHING = 5 : No draw operation.