Java
Install
Section titled “Install”Java uses the Kotlin library’s JVM and Android packages from Maven Central.
On the JVM, add the binding’s JVM package, and a runtime for each platform that your application runs on, as the Kotlin page’s JVM section describes:
dependencies { implementation("org.maplibre.nativeffi:maplibre-native-ffi-jvm:0.202611.0") runtimeOnly("org.maplibre.nativeffi:maplibre-native-ffi-runtime-vulkan-jvm:0.202611.0:natives-linux-x64")}Start Java with --enable-native-access=ALL-UNNAMED.
On Android, add maplibre-native-ffi and a runtime, as the Kotlin page’s
Android section shows. Call MaplibreNative.initAndroid(context) once before
you create a runtime.
From Java
Section titled “From Java”The binding’s API reference is the Kotlin one. Java sees the same classes, with these differences:
- An asynchronous call returns a
Completion, which is aCompletableFuture. Wait for it withjoin(), or chain a stage such asthenRun(). Inside a callback from the library,join()andget()throw anIllegalStateExceptionuntil the result arrives, so chain a stage there instead. - A record with a member that has a default also has a factory,
of(...), which takes the members that have none. EachwithX(...)returns a copy that sets one more member, as inCameraOptions.of().withZoom(3.0). - An unsigned value is an
intor alongwith the same bits, as inmap.cancelCameraTransitionsWithId(long). A record with an unsigned member, such asLogicalExtent, is created withof(...). - An enum’s constants are static fields, such as
CameraUpdateMode.FLY.X.of(int)gives the value for a raw number, and eachX_VALUEconstant is a raw number toswitchon. - Functions, extensions, and constants outside a class are statics of
MaplibreNative, as inMaplibreNative.setLogCallback(handler). An extension takes its receiver first, as inMaplibreNative.getHardwareBuffer(frame)on Android. - To release a handle, call
release()in afinallyblock. A runtime, map, or render session returns aCompletionthere, whichjoin()waits for.