Draws the overlay’s contents at the specified location on the map.
- iOS 7.0+
- macOS 10.9+
- Mac Catalyst 13.0+
- tvOS 9.2+
The map rectangle that needs to be updated. Your drawing code should avoid drawing outside of this rectangle.
The current zoom factor applied to the map content. You can use this value for configuring the stroke width of lines or other attributes that might be affected by the scale of the map’s contents.
The graphics context to use for drawing the overlay’s contents.
The default implementation of this method does nothing. Subclasses are expected to override this method and use it to draw the overlay’s contents.
When determining where to draw content, make your initial calculations relative to the map itself. In other words, compute the position and size of any overlay content using map points and map rectangles, convert those values to regular
CGRect types using the methods of this class, and then pass the converted points to any drawing primitives.
It is recommended that you use Core Graphics to draw any content for your overlays. If you choose to draw using UIKit classes and methods instead, you must push the specified graphics context onto the context stack (using the
UIGraphics function) before making any drawing calls. When you are done drawing, you must similarly pop the graphics context off the stack using the
UIGraphics. Overlay drawing typically occurs on background threads to improve performance, so do not manipulate UIKit views or other objects that can only be manipulated on the app’s main thread.
To improve drawing performance, the map view may divide your overlay into multiple tiles and render each one on a separate thread. Your implementation of this method must therefore be capable of safely running from multiple threads simultaneously. In addition, you should avoid drawing the entire contents of the overlay each time this method is called. Instead, always take the
map parameter into consideration and avoid drawing content outside that rectangle.