UNL Android Sdk
Current version: v1.1.1
-
Custom map styles
-
Fast vector maps
UNL Maps SDK for Android is a library for embedding UNL Maps within Android applications. The Map SDKs are packaged with additional controls to integrate interactive Map controls with an application including but not restricted to zoom, pan, layer overlays, tile selection, and UNL grid controls etc.
Requirements
The UNL Maps SDK for Android is compatible with applications that:
Are built using the Android SDK 21 or higher.
Use Java 11 for sourceCompatibility and targetCompatibility
Java compatibility
The UNL Maps SDK for Android is built with Kotlin, the official language recommended by Google for Android development. Kotlin is 100% interoperable with Java.
Contribution
UNL Android Sdk is an advance Map SDK library, builld using the core open-source library of MapLibre GL JS. UNL conforms to MapLibre GL licensing terms listed under 3-Clause BSD License.
Installation
Add the following dependency to your
build.gradle
file:
implementation 'com.github.u-n-l:unl-maps-sdk-android:Tag'
Add Maven URLs
allprojects {
repositories {
....
maven { url 'https://jitpack.io' }
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/u-n-l/core-java")
credentials {
username = <YOUR_USERNAME>
password = <YOUR_PASSWORD>
}
}
.....
}
}
Enable AndroidX by adding following in
gradle.properties
.
android.useAndroidX=true
android.enableJetifier=true
Permissons
Add the following permissions to your
AndroidManifest.xml
file:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
Initializing the SDK
Example usage
Your activity.xml
<com.unl.map.sdk.views.UnlMapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Your Activity
above
setContentView(R.layout.activity)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Initializing the UNL SDK
UnlMap(applicationContext,getString(R.string.api_key),
getString(R.string.vpm_id),EnvironmentType.SANDBOX)
setContentView(R.layout.activity)
//Getting Instance of `UnlMapView` from `activity.xml`
val unlMap=findViewById<UnlMapView>(R.id.mapView)
//This `getMapAsync` method is used for map loaded to view.
unlMap.getMapAsync {
// Need supportFragmentManager and Activity for showing some controls
unlMap.fm=supportFragmentManager
unlMap.activity=this
unlMap.lifeCycleOwner=this
//for enable Indoor map functionality
unlMap.enableIndoorMap=true
unlMap.viewLifecycle=this
//enableTileSelector method is used to show TileSelector on UnlMapView or not.
unlMap.enableTileSelector(true)
// setGridControls method is used to show GridControls on UnlMapView or not.
unlMap.setGridControls(this,true)
// setGridControls method is used to set position for TileSelector.
unlMap.setTileSelectorGravity(Gravity.RIGHT)
}
}
See
SDK Authentication Docs
for instructions on how to generate an
apiKey
and vpmId
to get
started with the UnlSdk.