Skip to Content
ReferenceMap Controller

MapsGL Android - Map Controller

A map controller acts as an adapter to a third-party mapping library and provides a consistent interface between the functionality of MapsGL and the underlying map. All MapsGL-related data — sources, weather layers, custom layers, and the animation timeline — is managed by the map controller.

Supported Mapping Libraries

MapsGL SDK for Android currently supports integration with the following third-party mapping libraries:

Library + VersionController
Mapbox GL , version v11.x.xMapboxMapController

Read more about setting up a map controller with Mapbox.

Example

The following example creates a Mapbox map instance and initializes a MapsGL MapboxMapController with the map:

val xweatherAccount = XweatherAccount( getString(R.string.xweather_client_id), getString(R.string.xweather_client_secret) ) val mapLoadedCallback = MapLoadedCallback { mapController.addWeatherLayer(LayerCode.TEMPERATURES) } binding.mapView.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { override fun onGlobalLayout() { binding.mapView.viewTreeObserver.removeOnGlobalLayoutListener(this) mapController = MapboxMapController(mapView, xweatherAccount) with(mapController) { mapboxMap?.setProjection(projection(ProjectionName.MERCATOR)) mapboxMap?.subscribeMapLoaded(mapLoadedCallback) } } })

Refer to the MapController API reference for available properties and methods.

Registering Custom Images

To use your own icon image on a symbol layer, register it on the Mapbox style and reference its id from IconPaint.image:

val image = BitmapFactory.decodeResource(resources, R.drawable.my_icon) mapController.mapboxMap?.getStyle { style -> style.addImage("my-icon", image, false) }

Pass true as the third argument when the bitmap is an SDF (signed-distance field) icon, so it can be tinted with fill.color.

Registered images are drawn by Mapbox, so set useGlRendering = false on the SymbolLayerDescriptor that uses them. MapsGL’s own renderer draws only the built-in mapsgl: sprite icons, which load automatically. See Custom Icons for sprite sheets, data-driven icons, and SDF icons.

© 2026 Xweather (opens in a new tab)Terms of Service (opens in a new tab)Privacy Policy (opens in a new tab)