Documentation for MapLib/Map.swift

struct Point

Point class. Store x and y coordinates.

class Map

Map class. The oredered array of layers.

var scale : Double

Map scale read/write property.

var center : Point

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

var layerCount : Int32

Map layer count readonly property.

var extent : Envelope

Map extent read/write property.

func close()

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

func setBackgroundColor(R: UInt8, G: UInt8, B: UInt8, A: UInt8)

Set map background.

Parameters
  • R – red color.

  • G – green color.

  • B – blue color.

  • A – alpha color.

func setSize(width: CGFloat, height: CGFloat)

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

Parameters
  • width – map width in pixels.

  • height – map height in pixels.

func save() Bool

Save map.

Returns

true if mape saved successfuly.

func addLayer(name: String, source: Object!) Layer?

Add layer to map.

Parameters
  • name – layer mame.

  • source – layer datasource.

Returns

Layer class instance or nil on error.

func deleteLayer(layer: Layer) Bool

Remove layer from map.

Parameters
  • layer – Layer class instance.

Returns

True if delete succeeded.

func deleteLayer(position: Int32) Bool

Remove layer from map.

Parameters
  • position – Layer index.

Returns

True if delete succeeded.

func getLayer(by position:Int32) Layer?

Get map layer.

Parameters
  • position – Layer index.

Returns

Layer class instance.

func setOptions(options: [String:String])

Set map options.

Parameters
  • options – key-value dictionary. The supported keys are: - ZOOM_INCREMENT - Add integer value to zomm level correspondent to scale. May be negative. - VIEWPORT_REDUCE_FACTOR - Reduce view size on provided value. Make sense to decrease memory usage.

func setExtentLimits(minX: Double, minY: Double, maxX: Double, maxY: Double)

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

Parameters
  • minX – minimum x coordinate.

  • minY – minimum y coordinate.

  • maxX – maximum x coordinate.

  • maxY – maximum y coordinate.

func reorder(before: Layer?, moved: Layer!)

Reorder map layers.

Parameters
  • before – Before layer class instance will moved layer insert.

  • moved – Layer class instance to move.

func identify(x: Float, y: Float, limit: Int = 0) [Feature]

Search features in buffer around click/tap postition.

Parameters
  • x – x position.

  • y – y position.

  • limit – max count return features.

Returns

array of Feature.

func select(features: [Feature])

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

Parameters
  • features – Features array. If array is empty the current hightlighted features will get layer style and drawn not hightlited.

func invalidate(extent: Envelope)

Invalidate part of the map.

Parameters
  • extent – Extente to invalidate

func selectionStyle(for type:SelectionStyleType) JsonObject

Get selection style

Parameters
  • type – Style type

Returns

Json object with style

func selectionStyleName(for type:SelectionStyleType) String

Get selection style name

Parameters
  • type – Style type

Returns

Style name string

func setSelectionStyle()

Set selection style

Parameters
  • style – Json object with style. See Layer.style

  • type – Selection style type

Returns

True on success.

func setSelectionStyle()

Set selection style name

Parameters
  • name – Style name. See Layer.styleName

  • type – Selection style type

Returns

True on success.

func getOverlay(type: OverlayType) Overlay?

Get map overlay

Parameters
  • type – Overlay type.

Returns

Overlay class instance or nil.

func addIconSet(name: String, path: String, move: Bool) Bool

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

Parameters
  • name – Iconset name.

  • path – Path to image if file system.

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

Returns

True on success.

func removeIconSet(name: String) Bool

Remove iconset from map.

Parameters
  • name – Iconset name.

Returns

True on success.

func isIconSetExists(name: String) Bool

Validate iconset exists in map.

Parameters
  • name – Iconset name.

Returns

True if exists.

enum OverlayType : UInt32

Map overlay types.

  • UNKNOWN: unknown overlay type.

  • LOCATION: overlay with current location mark.

  • TRACK: overlay for current tracks.

  • EDIT: overlay for vector geometry editig.

  • FIGURES: overlay to show geometry primitives.

  • ALL: All overlays.

enum SelectionStyleType : UInt32

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.

  • POINT: point.

  • LINE: linestring.

  • FILL: polygon.

enum DrawState : UInt32

Map drawing state enum

  • NORMAL: normal draw. Only new tiles will be filled with data to draw.

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

  • REFILL: all tiles will be mark need to fill with data to draw.

  • PRESERVED: just update scree with cached data.

  • NOTHING: no draw operation.