MapController

class MapController(context: Context)(source)

Core controller managing map state, rendering, and interactions.

Handles map positioning (zoom, center), tile management, marker rendering, shape drawing, camera animations, and touch event processing.

This class is used internally by OpenMapView and is not part of the public API.

Constructors

Link copied to clipboard
constructor(context: Context)

Types

Link copied to clipboard
object Companion

Properties

Functions

Link copied to clipboard
fun addGeoJson(geoJsonString: String): GeoJsonResult

Parses GeoJSON and adds all features to the map.

Link copied to clipboard
fun addMarker(marker: Marker): Marker

Adds a marker to the map.

Link copied to clipboard
fun addPolygon(polygon: Polygon): Polygon

Adds a polygon to the map.

Link copied to clipboard
fun addPolyline(polyline: Polyline): Polyline

Adds a polyline to the map.

Link copied to clipboard
fun animateCamera(cameraUpdate: CameraUpdate, durationMs: Int = 250, listener: OnCameraAnimationListener? = null)

Animates the camera to a new position.

Link copied to clipboard

Removes all markers from the map.

Link copied to clipboard

Removes all polygons from the map.

Link copied to clipboard

Removes all polylines from the map.

Link copied to clipboard
fun commitPan()

Commits accumulated pan offsets to the map center.

Link copied to clipboard

Creates a Projection instance for coordinate conversions.

Link copied to clipboard
fun draw(canvas: Canvas)

Renders the map to the provided canvas.

Link copied to clipboard

Returns the current camera position.

Link copied to clipboard

Returns the current map center.

Link copied to clipboard

Returns a copy of all markers on the map.

Link copied to clipboard

Returns the current maximum zoom level preference.

Link copied to clipboard

Returns the current minimum zoom level preference.

Link copied to clipboard

Returns a copy of all polygons on the map.

Link copied to clipboard

Returns a copy of all polylines on the map.

Link copied to clipboard

Returns the current zoom level.

Link copied to clipboard

Finds the info window at the specified screen coordinates.

Link copied to clipboard

Finds the topmost marker at the specified screen coordinates.

Link copied to clipboard

Checks if a touch at screen coordinates hits a clickable polygon.

Link copied to clipboard

Checks if a touch at screen coordinates hits a clickable polyline.

Link copied to clipboard
fun moveCamera(cameraUpdate: CameraUpdate)

Moves the camera instantly to a new position.

Link copied to clipboard
fun onDestroy()

Cleans up resources to prevent memory leaks.

Link copied to clipboard
fun onPause()

Called when the app goes to the background.

Link copied to clipboard
fun onResume()

Called when the app comes to the foreground.

Link copied to clipboard

Removes a marker from the map.

Link copied to clipboard

Removes a polygon from the map.

Link copied to clipboard

Removes a polyline from the map.

Link copied to clipboard

Resets the min/max zoom preferences to their defaults (2.0 - 19.0).

Link copied to clipboard
fun screenToLatLng(screenX: Float, screenY: Float): LatLng

Converts screen coordinates to geographic coordinates.

Link copied to clipboard
fun setCenter(latLng: LatLng)

Sets the map center to the specified location.

Link copied to clipboard

Sets the maximum zoom level preference.

Link copied to clipboard

Sets the minimum zoom level preference.

Link copied to clipboard
fun setOnTileLoadedCallback(callback: () -> Unit)

Sets a callback to be invoked when tiles finish loading.

Link copied to clipboard
fun setViewSize(width: Int, height: Int)

Sets the view dimensions for rendering calculations.

Link copied to clipboard
fun setZoom(z: Double)

Sets the zoom level, clamping to valid range.

Link copied to clipboard

Stops any ongoing camera animation.

Link copied to clipboard

Updates the temporary pan offset during a drag gesture.

Link copied to clipboard
fun zoom(scaleFactor: Float, focusX: Float, focusY: Float)

Applies a zoom gesture centered on a specific screen point.