Skip to content

A modern, Kotlin-first, MIT-licensed MapView replacement for Android — powered by OpenStreetMap. Drop-in compatible with Google MapView. Built for performance, offline support, and full control.

License

Notifications You must be signed in to change notification settings

afarber/OpenMapView

Repository files navigation

CI Daily Tests Release codecov API Documentation

OpenMapView

A modern, Kotlin-first MapView replacement for Android — powered by OpenStreetMap.

Installation

Add to your build.gradle.kts:

dependencies {
    implementation("de.afarber:openmapview:0.13.0")
}

The library is available on Maven Central. Alternative distribution via JitPack is also supported.

License Compliance

OpenMapView is licensed under the MIT License - use freely in commercial apps.

Dependency Licenses:

  • All runtime dependencies use Apache 2.0 or MIT licenses (business-friendly)
  • View complete Dependency License Report
  • No GPL or restrictive copyleft licenses

Dependencies (5 total):

  • androidx.core:core-ktx (Apache 2.0)
  • androidx.lifecycle:lifecycle-runtime-ktx (Apache 2.0)
  • androidx.compose.ui:ui-graphics (Apache 2.0)
  • io.ktor:ktor-client-android (Apache 2.0)
  • com.jakewharton:disklrucache (Apache 2.0)

Features

  • Drop-in compatible with Google MapView (non-deprecated methods only)
  • Lightweight, pure Kotlin implementation with zero Google dependencies
  • OSM tiles via standard APIs (free, no API keys required)
  • Smooth camera animations with customizable durations and callbacks
  • Multiple overlay types: Markers, Polylines, Polygons, Circles, Ground Overlays, Tile Overlays, Info Windows
  • Multiple map types (see Map Types Guide)
  • Built-in zoom controls (+/- buttons) via UiSettings
  • External app integration (open in Google Maps, OsmAnd, etc. via geo: URI)
  • GeoJSON import support
  • Extensible marker, overlay, and gesture handling
  • MIT licensed (use freely in commercial apps)

API Documentation

Full API reference documentation is available at afarber.github.io/OpenMapView.

The documentation is automatically generated from KDoc comments and updated with every commit to main.

Examples

Explore the example applications to see OpenMapView in action:

Example01Pan Demo

Documentation

Getting Started

With Jetpack Compose

@Composable
fun MapViewScreen() {
    val lifecycleOwner = androidx.lifecycle.compose.LocalLifecycleOwner.current

    AndroidView(
        factory = { context ->
            OpenMapView(context).apply {
                // Register lifecycle observer for proper cleanup
                lifecycleOwner.lifecycle.addObserver(this)

                setCenter(LatLng(51.4661, 7.2491))
                setZoom(14.0)

                // Add markers - Kotlin style (direct instantiation)
                addMarker(Marker(
                    position = LatLng(51.4661, 7.2491),
                    title = "Bochum City Center"
                ))

                // Or Google Maps API style (builder pattern)
                addMarker(
                    MarkerOptions()
                        .position(LatLng(51.4700, 7.2550))
                        .title("North Location")
                        .draggable(true)
                )
            }
        },
        modifier = Modifier.fillMaxSize()
    )
}

With XML Layouts

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val mapView = findViewById<OpenMapView>(R.id.mapView)
        mapView.setZoom(14.0)
        mapView.setCenter(LatLng(51.4661, 7.2491))
    }
}

About

A modern, Kotlin-first, MIT-licensed MapView replacement for Android — powered by OpenStreetMap. Drop-in compatible with Google MapView. Built for performance, offline support, and full control.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published