# Draw journey on map load

**URL:** <https://community.mappedin.com/t/draw-journey-on-map-load/58>\
**Category:** Mappedin SDK for Android\
**Created:** [June 10, 2024, 7:35pm UTC](https://community.mappedin.com/t/draw-journey-on-map-load/58 "2024-06-10T19:35:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zanz](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.mappedin.com/zanz/32/63_2.png) [@zanz](https://community.mappedin.com/u/zanz)\
**Post date:** [June 10, 2024, 7:35pm UTC](https://community.mappedin.com/t/draw-journey-on-map-load/58/1 "2024-06-10T19:35:09Z")

</div>

I’m trying to display directions when the map loads, but am running into problems. I took some of the sample code, but it’s not working for me. ☹

```auto
override fun onDataLoaded(data: MPIData) {
    val departure = mapView.venueData?.locations?.first { it.name == "My first location" }!!
    val destination = mapView.venueData?.locations?.first { it.name == "My second location" }!!

    mapView.getDirections(to = destination, from = departure) {
        if (it != null) {
            mapView.journeyManager.draw(directions = it)
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![msohm](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.mappedin.com/msohm/32/6_2.png) [@msohm](https://community.mappedin.com/u/msohm)\
**Post date:** [June 10, 2024, 8:19pm UTC](https://community.mappedin.com/t/draw-journey-on-map-load/58/2 "2024-06-10T20:19:08Z")

</div>

Can you elaborate on what isn’t working? What error or behaviour are you getting? I notice that you are attempting to do this in the onDataLoaded method. At this point the MapView has downloaded the data it needs, but has not started rendering the map yet. Drawing on the map requires the app to wait for the map to be ready. Use the code you have above in the ​​onFirstMapLoaded() method instead of onDataLoaded. If you still have issues, provide further details.

---

<div class="post-metadata">

**Author:** ![zanz](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.mappedin.com/zanz/32/63_2.png) [@zanz](https://community.mappedin.com/u/zanz)\
**Post date:** [June 11, 2024, 8:03pm UTC](https://community.mappedin.com/t/draw-journey-on-map-load/58/3 "2024-06-11T20:03:13Z")

</div>

Oh - that makes a lot of sense. I tried the `onFirstMapLoaded()` method as you mentioned and that seemed to do the trick!

Thanks @msohm
