Documentation for maplib/MapView.kt

interface GestureDelegate

Gesture delegate protocol. Correspondent functions will be executed on gesture events.

interface LocationDelegate

Location delegate protocol. Correspondent functions will be executed on location events.

interface MapViewDelegate

Map drawing delegate protocol. Correspondent functions will be executed on map draw events.

class MapView : GLSurfaceView

Map view with GL rendering.

MapView holds MapDocument and renders it.

var currentLocation : Location? = null

Last known location or null.

var showLocation : Boolean = false

Show/hide current position on map. The location overlay must be set.

var freeze : Boolean = true

Freeze map drawing read/write property.

var mapScale : Double

Map scale read/write property.

var mapCenter : Point

Map center in spatial reference coordinates read/write property.

var mapExtent : Envelope

Map current extent read/write property.

fun setMap(map: MapDocument)

Set map class to view.

Parameters
  • map – Map class instance.

fun cancelDraw() : Boolean

Cancel drawing process. Default return value is false. Using override function can cancel drawing on some cases.

Returns

True to cancel drawing.

fun refresh(normal: Boolean = true)

Refresh map.

Parameters
  • normal – If true just refresh view, otherwise refill all map tiles.

fun zoomIn(multiply: Double = 2.0)

Zoom in.

Parameters
  • multiply – Multiply factor. Default is 2.

fun zoomOut(multiply: Double = 2.0)

Zoom out.

Parameters
  • multiply – Multiply factor. Default is 2.

fun centerMap(coordinate: Point)

Center map at spatial reference coordinates and redraw it.

Parameters
  • coordinate – New center coordinates.

fun centerInCurrentLocation()

Center map in current location. If current location is null, nothing happened.

fun invalidate(envelope: Envelope)

Invalidate part of the map. The refresh function invalidates all visible screen.

Parameters
  • envelope – Envelope to invalidate.

fun pan(w: Double, h: Double)

Pan map to specific screen shift.

Parameters
  • w – horizontal pixel shift

  • h – vertical pixel shift.

fun scheduleDraw(drawState: MapDocument.DrawState, timeInterval: Long = Constants.refreshTime)

Schedule map redraw.

Parameters
  • drawState – Draw state value. See Map.DrawState values.

  • timeInterval – Time interval in seconds.

fun registerGestureRecognizers(delegate: GestureDelegate)

Register gesture delegate function.

Parameters
  • delegate – delegate function.

fun registerLocation(delegate: LocationDelegate)

Register location delegate function.

Parameters
  • delegate – location delegate function.

fun registerView(delegate: MapViewDelegate)

Register map drawing delegate function.

Parameters
  • delegate – map drawing delegate function.

fun getExtent(srs: Int) : Envelope

Get current extent in specified spatial reference system by EPSG code.

Parameters
  • srs – EPSG code.

Returns

Envelope in specified spatial reference system.