(Android/Kotlin) OpenStreetMap - Public Transport OSMdroid

176 views Asked by At

I need to make an app in Android Studio using Kotlin that can, among other things, display a map with public transport information.

To get a map i use OSMdroid.

As far as i understood you have to display a map using Mapnik and overlay that map with public transport tiles.

I am able to fully display a normal map but as soon as i try to overlay that map with the public transport information i only get a blank map:

//Code to Display a basic Map
        val mapView = binding.mapView
        val ctx = applicationContext
        Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx))
        mapView.setTileSource(TileSourceFactory.MAPNIK)
        centerMapOnPosition(51.57412537712895, 7.0285164257552974, 18.5, mapView) // WHS als Beispiel

//Code to overlay public Transport information
        val provider = MapTileProviderBasic(applicationContext)
        provider.tileSource = TileSourceFactory.PUBLIC_TRANSPORT
        val tilesOverlay = TilesOverlay(provider, this.baseContext)
        mapView.overlays.add(tilesOverlay)

Using my code i was able to show open sea information using TileSourceFactory.OPEN_SEAMAP in my mind it should work the thame with TileSourceFactory.PUBLIC_TRANSPORT but apparently i do something wrong :c

If i comment the public transport part i get a map that looks like this and is fully functionaly inside my app:

basic map

If i use the public transport part my map is blank:

blank map

Im not sure how exactly the public transport part should look but looking at OpenStreetMap i would expect something like that:

expected map

0

There are 0 answers