A keyless maps app on Android (MapLibre + OpenStreetMap services)
androidmapsmaplibreopenstreetmapopenfreemapphotonnominatimosrmnavigationgeocoding
A useful Google Maps replacement can be built with no API keys, no accounts and no Play services: MapLibre Native draws vector tiles, and free OpenStreetMap-based services handle search, place details and routing. Justin's Map app (io.jhampton.map, Kotlin + Compose, first shipped 2026-10-24) is built this way. This article lists the stack, how each feature maps onto it, and what was learned.
The stack
| Job | Service | Notes |
|---|---|---|
| Map drawing | MapLibre Native Android 11.x | Open-source fork of Mapbox GL Native. Native libraries for 4 ABIs make the APK about 46 MB; ABI splits or arm64-only would cut it to about 15 MB. |
| Tiles and styles | OpenFreeMap (liberty, bright, positron, dark, fiord) | Free vector tiles in the OpenMapTiles schema, no key. |
| Satellite | Esri World Imagery raster tiles | Needs its attribution shown. |
| Search and reverse geocoding | Photon (photon.komoot.io) | Search-as-you-type over OSM data. |
| Place details | Nominatim /lookup?osm_ids=…&extratags=1 |
Opening hours, phone, website, amenities. |
| Routing | OSRM at routing.openstreetmap.de (routed-car, routed-bike, routed-foot) |
Returns geometry plus maneuvers. |
| Location | LocationManager, GPS + network providers |
No fused provider without Play services. |
Send a real User-Agent naming the app and a contact URL on every request; the OSM community services' usage policies require it, and these servers are shared and rate-limited.
Search that stays local
Photon's location bias (lat/lon) is far too weak for chain names: searching "Barnes and Noble" from Oklahoma City ranked Santa Fe first, and no Oklahoma City store was in the top 12. Fix:
- Run two queries in parallel: a worldwide one and one restricted to a bounding box of about 70 km around the map center (bbox=).
- Merge: nearby results whose name matches every query word (each word a prefix of a name word, "&" = "and") first, closest first; then looser nearby matches; then far results. Exception: far area results (city, state, country) still lead, so "Paris" finds Paris.
- Never auto-pick the first result on the keyboard's Search key; just close the keyboard and show the list.
Nearby categories from the tiles themselves
"Gas", "Coffee", "Pharmacies" chips do not need a POI server: the loaded vector tiles already carry OpenMapTiles poi features with class/subclass. Query them with VectorSource.querySourceFeatures(["poi"], filter) (an any(==class, ==subclass) expression), dedupe by name and position, sort by distance.
- POIs are complete only in zoom 14 tiles, so step the camera to about z14.5 first if zoomed out.
- Fall back to text search when the style has no vector source (a pure satellite style).
- Why not Overpass: all four public Overpass servers took 20 to 30 seconds or timed out (2026-10-24), and Photon's osm_tag filter returned almost nothing for categories.
- OpenMapTiles feature ids encode the OSM id: id = osm_id × 10 + type, where type 1 = node, 2 = way, 3 = relation. Decoding it gives an exact Nominatim lookup key (N123, W456) with no fuzzy name matching.
Opening hours
OSM opening_hours strings ("Mo-Fr 08:00-18:00; Sa 09:00-14:00; Su off", ranges past midnight, comma lists) can be parsed well enough for "Open · Closes 9 PM", "Closes soon", "Closed · Opens 10 AM tomorrow" and a week table. The parser should return no claim for shapes it does not understand rather than guessing. Nominatim's extratags also carry check_date, cuisine, drive-through, takeout, wheelchair access, charger counts and more.
Turn-by-turn navigation
- OSRM's step list is enough: track the next maneuver, speak a heads-up at a distance that depends on travel mode (here 800 m driving, 150 m walking), speak the instruction close to it (120 m / 30 m), and count a maneuver as passed within 30 m / 15 m. Jump ahead to the furthest maneuver already reached, which catches ones skipped on a fast road.
- Off-route = distance to the route line above 60 m driving (35 m walking) for 3 fixes in a row; then reroute automatically.
- Speak distances the way people say them ("in half a mile", "500 feet") with Android
TextToSpeech, and keep the mute toggle always visible: hardware volume keys cannot undo an app's own mute. - Keep the screen on, keep location running in
onPausewhile navigating. - Opening on the user: the first location fix can arrive before the map exists. Wait for both map-ready and the first fix before moving the camera.
Styles and labels
- Hybrid "satellite with labels": load the vector style, insert the imagery
RasterSourceabove the bottom layer, hide every fill, fill-extrusion, raster, hillshade and waterway layer, and draw road lines at reduced opacity. - Relabeling features without new tiles: on every style load, wrap each
SymbolLayer'stext-fieldin acaseexpression that checksname,name_en,name:en,name:latinandname_intagainst a list of old names and substitutes the new one. Used to show "Gulf of America" (the official U.S. name since 2025) where OSM tiles still carry "Golfo de México" / "Gulf of Mexico"; the reverse mapping goes into search queries because the geocoder only knows the OSM name. - Markers: a
SymbolLayerwith anaddImagebitmap never rendered on OpenFreeMap styles in this setup; stackedCircleLayers (white ring plus colored dot) work everywhere. - Status bar icons must switch to light over dark and satellite styles (
WindowCompatinsets controller).
Testing on the emulator
adb emu geo fix <lon> <lat>in a loop (about 1.6 s apart) simulates driving a route.- The SwiftShader emulator draws no map text at all, so label changes cannot be checked there. What worked instead: log the layer's
textFieldexpression from the app, and render the same style and expression with maplibre-gl JS in headless Chrome (Playwright,--use-angle=swiftshader --enable-unsafe-swiftshader; screenshots taken with--virtual-time-budgetcome out before the tiles load, so wait for the tiles before capturing). - A camera bearing (heading-up navigation) crashed MapLibre 11.8 in the emulator's GL encoder within two fixes, every time; tilt alone was fine. Navigation ships north-up with a 45° tilt until heading-up is tested on a real phone.
See also
- Driving the Android emulator headlessly for QA
- A self-hosted F-Droid repository and APK catalog
- In-app updates for sideloaded Android apps