Skip to main content

Display overlays

|

Overlays are used to provide enhanced, layered information that adds contextual value to a base map, offering users dynamic, interactive, and customized data that can be visualized on top of other map elements.

Disabling overlays

Overlays can be disabled either by applying a predefined, custom map style created in Magic Lane Map Studio-where certain overlays are already disabled - or by using the disableOverlay method, as shown below:

val overlayService = OverlayService()
val error = overlayService.disableOverlay(ECommonOverlayId.PublicTransport.value, categoryId = -1)

Passing -1 (default value) as the optional categoryId parameter indicates that we want to disable the entire public transport overlay, rather than targeting a specific category.

The error returned will be success if the overlay was disabled or notFound if no overlay (or overlay category) with the specified ID was found in the applied style.

To disable specific overlays within a category, you'll need to retrieve their unique identifiers (uid) as shown below:

val overlayService = OverlayService()

// Get available overlays with callback
val overlayCollection = overlayService.getAvailableOverlays { error, _ ->
if (error == GemError.NoError) {
// Access overlays through MapView preferences (if available)
}
}
overlayCollection?.first?.let { collection ->
if (collection.size > 0) {
val overlayInfo = collection[0]
val uid = overlayInfo.uid
val disableError = overlayService.disableOverlay(uid, -1)
// Handle the error result
Log.d("Overlay", "Disable result: $disableError")
}
}

Enabling overlays

In a similar way, the overlay can be enabled using the enableOverlay method by providing the overlay id. It also has an optional categoryId parameter, which when left as default, it activates whole overlay rather than a specific category.

val overlayService = OverlayService()
val error = overlayService.enableOverlay(ECommonOverlayId.PublicTransport.value, categoryId = -1)