Chapter 14. Making a maps client

 

In this chapter

  • Exploring a real-life example of a reactive app
  • Handling dragging state in Rx event streams
  • Expanding Rx chains as the app grows

Maps example

Maps have become more and more prominent in modern applications. Although it’s uncommon to have to write your own, you’ll go through building a simple maps client as an exercise. After completing the chapter, you’ll understand more of the internal workings of any maps application—or have a basis to fulfill you own custom maps use case.

If you aren’t familiar with the way maps work, don’t worry; on the way you’ll learn everything necessary. A bit of mathematics is involved, but as before, the more complex functions will be given to you as utility tools. If you’re interested in the more involved parts you can find additional information about map calculations online.

Why maps?

Maps might seem like an unusual thing to build, but you’ll see that many parts in a map can be made with Rx. You’ll take an approach that uses as much Rx as possible in this example, yielding perhaps slightly surprising results. The maps will still work as normal maps would, but in the process you’ll see how to truly separate the data and how much you can stretch the line between the data and the rendering—on the spectrum toward the left.

Basics of map rendering

Getting started with map tiles

Making an initial view model

Calculating tiles based on zoom level

Using the offset to move tiles

Dragging the map

The code so far

Viewport and hiding tiles

Loading map tiles

Adding zoom-level controls

Adding support for map coordinates

Summary