Documentation for MapLib/Overlay.swift

class Overlay

Map overlay to draw different features (for example, current position, edit features, etc.)

var visible : Bool

Overlay visible read/write property.

var options : [String:String]

Overlay options key-value dictionary. The keys depend on overlay type.

class LocationOverlay : Overlay

Overlay showing current position

var style : JsonObject

Overlay style json object

func setStyle(name: String) Bool

Set ovelay style name.

Parameters
  • name – Overlay style name. The supported names depnds of overlay type.

Returns

True on success.

class EditOverlay : Overlay

Overlay showing edit features

var editLayer : Layer? = nil

Edit layer read/write property.

var pointStyle : JsonObject

Point json object style.

var lineStyle : JsonObject

Line json object style.

var fillStyle : JsonObject

Polygon json object style.

var crossStyle : JsonObject

The cross in screen center style read/write property.

var geometry : Geometry?

Edit geometry property.

var geometryType : Geometry.GeometryType

Edit geometry type property.

var walkingMode : Bool

Enable/disable edit by walk mode.

func setStyle(point name:String) Bool

Set edit overlay point feature style.

Parameters
  • name – Style name.

Returns

True on success.

func setStyle(line name:String) Bool

Set edit overlay line feature style.

Parameters
  • name – Style name.

Returns

True on success.

func setStyle(fill name:String) Bool

Set edit overlay polygon feature style.

Parameters
  • name – Style name.

Returns

True on success.

func setStyle(cross name:String) Bool

Set edit overlay cross style.

Parameters
  • name – Style name.

Returns

True on success.

func canUndo() Bool

Can undo edit operation.

Returns

True or false.

func canRedo() Bool

Can redo edit operation.

Returns

True or false.

func undo() Bool

Undo edit operation.

Returns

True on success.

func redo() Bool

Redo edit operation.

Returns

True on success.

func save() Feature?

Save edits and return result feature instance.

Returns

Feature class instance or nil.

func cancel() Bool

Cancel any edits.

Returns

True on success.

func createNewGeometry(in layer:Layer) Bool

Create new geometry and start editing. If the layer datasource is point - te pont at the center of screen will be created, if line - line with two points, if polygon - polygon with three points.

Parameters
  • layer – Layer in which to create new geometry. The feature will be created in layer datasource.

Returns

True on success.

func createNewEmptyGeometry(in layer:Layer) Bool

Create new geometry and start editing. The geometry will be empty. This is for edit by walk editing.

Parameters
  • layer – Layer in which to create new geometry. The feature will be created in layer datasource.

Returns

True on success.

func createNewGeometry(of type:Geometry.GeometryType) Bool

Create new geometry and start editing.

Parameters
  • type – Geometry type.

Returns

True on success.

func editGeometry(of feature:Feature) Bool

Start editing geometry from feature.

Parameters
  • feature – Feature to edit geometry.

Returns

True on success.

func deleteGeometry() Bool

Delete geometry in editing feature.

Returns

True on success.

func addGeometryPart() Bool

Add geomtry part.

Returns

True on success.

func addGeometryPoint() Bool

Add point to geometry. Make sense only for line or polygon ring.

Returns

True on success.

func addGeometryPoint(with coordinates:Point) Bool

Add point to geometry. Make sense only for line or polygon ring.

Parameters
  • coordinates – Point coordinates.

Returns

True on success.

func deleteGeometryPoint() DeleteResultType

Delete point from geometry.

Returns

True on success.

func deleteGeometryPart() DeleteResultType

Delete geometry part

Returns

The value of type enum DeleteResultType

func addGeometryHole() Bool

Add hole topolygon geometry.

Returns

True on success.

func deleteGeometryHole() DeleteResultType

Delete geometry hole.

Returns

delete result type indicating is this last hole or any already exists.

func touch(down x:Double, y: Double) (pointId: Int32, isHole: Bool)

Touch down event in edit overlay.

Parameters
  • x – x screen coordinate.

  • y – y screen coordinate.

Returns

Tuple with selected point identificator and is this point belongs to hole.

func touch(up x:Double, y: Double) (pointId: Int32, isHole: Bool)

Touch up event in edit overlay.

Parameters
  • x – x screen coordinate.

  • y – y screen coordinate.

Returns

Tuple with selected point identificator and is this point belongs to hole.

func touch(move x:Double, y: Double) (pointId: Int32, isHole: Bool)

Touch move event in edit overlay.

Parameters
  • x – x screen coordinate.

  • y – y screen coordinate.

Returns

Tuple with selected point identificator and is this point belongs to hole.

func touch(single x:Double, y: Double) (pointId: Int32, isHole: Bool)

Touch single event in edit overlay. Fotr example down and up.

Parameters
  • x – x screen coordinate.

  • y – y screen coordinate.

Returns

Tuple with selected point identificator and is this point belongs to hole.

enum DeleteResultType : UInt32

Edit operation result type.

  • NON_LAST: deleted point/part was not last in geometry.

  • LINE: delete line.

  • HOLE: the hole in polygon was deleted.

  • GEOMETRY_PART: part of the geometry was deleted.

  • GEOMETRY: the whole geometry was deleted.