ApiKeyManager

Manages API keys for third-party tile providers.

Some map types (CYCLEMAP, TRANSPORT, TRANSPORT_DARK, TRACESTRACK_TOPO) require API keys from tile providers. Keys can be configured in two ways:

1. AndroidManifest.xml (Recommended):

<application>
<meta-data
android:name="de.afarber.openmapview.THUNDERFOREST_API_KEY"
android:value="your_thunderforest_key_here"/>
<meta-data
android:name="de.afarber.openmapview.TRACESTRACK_API_KEY"
android:value="your_tracestrack_key_here"/>
</application>

2. Programmatically (Runtime):

ApiKeyManager.setApiKey("thunderforest", "your_key_here")
ApiKeyManager.setApiKey("tracestrack", "your_key_here")

API keys set programmatically override keys from the manifest.

Provider Names

  • "thunderforest" - For CYCLEMAP, TRANSPORT, and TRANSPORT_DARK map types

  • "tracestrack" - For TRACESTRACK_TOPO map type

Obtaining API Keys

  • Thunderforest: https://www.thunderforest.com/pricing/ (Free: 150k tiles/month)

  • Tracestrack: https://www.tracestrack.com/en/signup (Free tier available)

See also

Functions

Link copied to clipboard

Clears all programmatically-set API keys. Keys from AndroidManifest.xml are not affected.

Link copied to clipboard

Retrieves the API key for the given provider.

Link copied to clipboard
fun hasApiKey(provider: String): Boolean

Checks if an API key is configured for the given provider.

Link copied to clipboard
fun setApiKey(provider: String, key: String)

Sets an API key programmatically for the given provider.