MapMe — the Android maps adapter

An Android library for working with maps

Josh Burton
Trade Me Blog
2 min readSep 10, 2017

--

Maps are easy right? Set up a MapView, add a few markers. Done!

Now try with dozens of markers, markers of different types, and with selected and focused states. It gets complicated fast!

Here at Trade Me Property we do a lot of work with maps. When we set out to build our new map-based search feature called Insights, we knew we needed a new tool for the job, and we’re super happy with the result.

See for yourself!

Introducing MapMe

MapMe is an Android library written in Kotlin (🎉), bringing the adapter pattern to maps.

Know how to use a RecyclerView Adapter? Then you know how to use MapMe!

Adapters are a common pattern in Android development. They separate the management of data from the creation of views, and handle the processing and dispatching of view updates.

We thought this (along with DiffUtil) would be a perfect way to work with maps and markers.

How does it work?

MapMe works just like a RecyclerView Adapter, and provides adapters for both Google Maps and Mapbox.

A simple adapter looks something like:

In an Activity, Fragment or custom view, attach the MapMeAdapter to the map:

Finally, fetch your data and give it to the MapMeAdapter:

MapMe will create markers for your data and add them to the map. 🎉

There’s more

MapMe also handles marker clicks, info window clicks, and even makes it easier to animate markers. It’s all in the readme.

Give it a shot!

The concept of MapMe is simple, but the result allowed us to focus on what’s important — fetching, manipulating and managing the data, rather than the markers or the map.

I hope you love it as much as we do — can’t wait to hear your feedback!

Check MapMe out on Github.

If you liked this article make sure to 👏 it below, and follow me on twitter!

--

--

Josh Burton
Trade Me Blog

Freelance Android Developer. Fueled by coffee. @athornz on Twitter.