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 addCircle(circle: Circle): Circle

Adds a circle to the map.

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

Parses GeoJSON and adds all features to the map.

Link copied to clipboard

Adds a ground overlay 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

Adds a tile overlay to the map.

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

Animates the camera to a new position.

fun animateCamera(cameraUpdate: CameraUpdate, durationMs: Int, interpolator: TimeInterpolator, listener: CancelableCallback? = null)

Animates the camera to a new position with the given timing, e.g. a android.view.animation.LinearInterpolator for constant speed.

Link copied to clipboard

Drops a camera update kept by deferBoundsUpdate, e.g. when the camera is set directly, calling onCancel() of its listener.

Link copied to clipboard

Removes all circles from the map.

Link copied to clipboard

Removes all ground overlays from the map.

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

Drops the downloaded tiles of a tile overlay, so they are requested again.

Link copied to clipboard

Removes all tile overlays 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
fun drawEdgeEffects(canvas: Canvas, width: Int, height: Int)

Draws the custom edge glow effects on the canvas.

Link copied to clipboard

Returns the bearing in degrees clockwise from north, 0 to 360.

Link copied to clipboard

Returns the current camera position.

Link copied to clipboard

Returns the camera target: the location shown at the center of the area inside the map padding, or at the view center without padding.

Link copied to clipboard

Returns a copy of all circles on the map.

Link copied to clipboard

Returns a copy of all ground overlays on the map.

Link copied to clipboard

Returns the current camera target bounds constraint.

Link copied to clipboard

Returns the color scheme of the map, see setMapColorScheme.

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 color filter of the base map tiles, see setTileColorFilter.

Link copied to clipboard

Returns a copy of all tile overlays on the map.

Link copied to clipboard

Returns how many screen pixels a pixel of a 256 px tile covers, see setTileScale.

Link copied to clipboard

Gets the current tile source.

Link copied to clipboard
fun getZoom(): Float

Returns the current zoom level.

Link copied to clipboard
fun handleCircleTouch(screenX: Float, screenY: Float): Circle?

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

Link copied to clipboard
Link copied to clipboard

Finds the info window at the specified screen coordinates.

Link copied to clipboard
fun handleMarkerTouch(screenX: Float, screenY: Float): Marker?

Finds the topmost marker at the specified screen coordinates.

Link copied to clipboard
fun handlePolygonTouch(screenX: Float, screenY: Float): Polygon?

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

Link copied to clipboard
fun handlePolylineTouch(screenX: Float, screenY: Float): Polyline?

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

Link copied to clipboard

Checks if any edge glow is currently active.

Link copied to clipboard
fun moveCamera(cameraUpdate: CameraUpdate)

Moves the camera instantly to a new position.

Link copied to clipboard
fun onDestroy()

Releases 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

Releases all edge glows, allowing them to decay naturally.

Link copied to clipboard

Removes a circle from the map.

Link copied to clipboard

Removes a ground overlay from the map.

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

Removes a tile overlay 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 rotateBy(degrees: Float, focusX: Float, focusY: Float)

Turns the map by degrees around a screen point, e.g. the fingers of a rotate gesture, so the location at that point stays there. Positive degrees turn the map clockwise on the screen, which lowers the bearing.

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

Converts screen coordinates to geographic coordinates.

Link copied to clipboard
fun setBearing(bearing: Float)

Sets the bearing: the direction at the top of the screen, in degrees clockwise from north, e.g. 90 for east up. The map turns around the camera target, which stays in place.

Link copied to clipboard
fun setCenter(latLng: LatLng)

Sets the camera target: the location shown at the center of the area inside the map padding, or at the view center without padding.

Link copied to clipboard

Sets a LatLngBounds to constrain the camera target.

Link copied to clipboard
fun setMapColorScheme(scheme: Int)

Sets the color scheme of the map, one of the MapColorScheme constants.

Link copied to clipboard
fun setMapPadding(left: Int, top: Int, right: Int, bottom: Int)

Sets map padding that affects the logical viewport.

Link copied to clipboard
fun setMapType(mapType: Int)

Sets the map type with API key handling.

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 setNightMode(night: Boolean)

Sets whether the device is in night mode, for MapColorScheme.FOLLOW_SYSTEM.

Link copied to clipboard

Sets a callback that is invoked once, after a draw in which all visible base map tiles were shown and the camera was not moving. If the map is already fully drawn, the callback is invoked after the next frame. Tile overlays are not waited for, because sparse overlays have no tiles for many areas.

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

Sets a callback to be invoked when tiles finish loading.

Link copied to clipboard

Sets a color filter for the base map tiles and their placeholders, e.g. TileColorFilters.invertedDark for a dark map. Markers, shapes, ground and tile overlays and info windows keep their colors.

Link copied to clipboard
fun setTileScale(scale: Float)

Sets how many screen pixels a pixel of a 256 px tile covers.

Link copied to clipboard
fun setUiSettings(settings: UiSettings)

Sets the UiSettings instance for controlling UI behavior.

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

Sets the view dimensions for rendering calculations.

Link copied to clipboard
fun setZoom(z: Float)

Sets the zoom level, clamping to valid range.

Link copied to clipboard

Stops any ongoing camera animation.

Link copied to clipboard
fun triggerEdgeEffect(edges: Set<Edge>, intensity: Float = 0.8f)

Triggers the edge glow effect on specified edges.

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.