Wesley de Groot's Blog
Surprise Route

Back

In this post, I'll take you tough the process of creating my Surprise Route app in Swift(UI).
This app is designed to generate random routes for walking or biking, making your daily exercise routine more exciting and adventurous.

Introduction

What is Surprise Route?

Surprise Route is an app that generates a random route for you to explore, making your daily walks or runs more exciting. It takes your current location and creates a unique path that you can follow, ensuring you discover new areas and enjoy the journey.

Why Surprise Route?

Since a couple of weeks I'll try to walk or bike every day. I noticed that I often take the same routes, which can become monotonous. I wanted to create an app that would help me break out of this routine and explore new places in my neighborhood. That's how the idea for Surprise Route was born.

How does it work?

The app uses the current location and generates a random route by selecting random points within a certain radius. Then it asks to MapKit to create a path that connects these points, ensuring that the route is walkable or bikeable. The app also allows you to customize the distance and difficulty level of the route, making it suitable for different users.

Design

┌────────────────────────────────────────┐
| ╭────────────────────────────────────╮ |
| |          (Surprise Route)      (i) | |
| |                                    | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| |              MAP VIEW              | |
| ╰────────────────────────────────────╯ |
├────────────────────────────────────────┤
| Generate a [walk]↕ route for [1 hour]↕ |
| ┌────────────────────────────────────┐ |
| | Distance    Duration    Waypoints  | |
| | 5 km        1 hour      9          | |
| └────────────────────────────────────┘ |
| ╭────────────────────────────────────╮ |
| |         ↗ Generate Route           | |
| ╰────────────────────────────────────╯ |
└────────────────────────────────────────┘
Final design of the app Surprise Route Walk

Encountered challenges

Sometimes routes generate a "spike" to one street to enter that street and then return to the original path. This can happen due to the way the random points are selected or how the path is generated. I'm currently working on improving the algorithm to minimize these spikes and create smoother routes.
(see the screenshot in the details section above "Final design of the app")

Fun facts

  • The map is displayed using the UIKit version of MapKit, which allows to add overlays and annotations to the map. This makes it easy to visualize the route and see the points of interest along the way.

  • You can see where the waypoints are located on the map, go to ⓘ scroll to the bottom of the screen and enable "Show Waypoints". This helps you understand how the route is constructed.

Wrap up

In this post, we explored the process of creating the Surprise Route app in Swift(UI). We discussed its purpose, functionality, and the challenges faced during development. By leveraging the power of Swift and MapKit, we were able to create an app that encourages exploration and makes daily walks or runs more exciting.

Read more

Share


Share Bluesky Mastodon Twitter LinkedIn Facebook
x-twitter mastodon github linkedin discord threads instagram whatsapp bluesky square-rss sitemap