Introducing the new iOS Annotation Extension
By: Nadia Barbosa
Today, we’re launching an extension to the Maps SDK for iOS that simplifies adding annotations to the map. Annotations include icons, text, points, lines, and polygons. With the iOS Annotation Extension, developers can quickly add annotations in a familiar object-oriented manner, without using runtime styling.
Android developers can also find this functionality through the Android Annotation Plugin.
Why we built this
Our Maps SDKs for Android and iOS are highly flexible, offering fine-grain control of map appearance and experiences. There are a lot of classes to chose from for completing certain tasks. We wanted to simplify the workflow for developers looking to hit the ground running with the most common use case for our SDKs: adding icons and basic shapes to a map. With the developer experience in mind, we set out to abstract away the most complex parts of adding annotations on a map.
How it works
The application below displays one POI with a custom icon and label.
Without the Annotation Extension, adding this icon to the map using runtime styling in Swift would require roughly ten lines of code:
With the Annotations Extension, we’ve removed the concept of sources and style layers and removed the requirement to wrap all property values in NSExpression objects. This creates a cleaner, streamlined code that’s nearly half the size.
We’ve also added built-in support for selection and dragging, which means developers no longer have to implement their own gesture recognizers when building interactivity.
Try it out
Check out the docs for the iOS extension and Android plugin to learn more about the setup process, and give us a shout in our GitHub repository if you have questions or feedback about the features you want to see next.
Nadia Barbosa - Maps SDK Engineer, iOS - Mapbox | LinkedIn
Quickly add annotations to mobile maps was originally published in Points of interest on Medium, where people are continuing the conversation by highlighting and responding to this story.