Platforms to show: All Mac Windows Linux Cross-Platform

Back to MKCustomOverlayRendererMBS class.

MKCustomOverlayRendererMBS.canDrawMapRect(mapRect as MKMapRectMBS, zoomScale as Double) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event MapKit MBS MacFrameworks Plugin 19.2 ✅ Yes ❌ No ❌ No ❌ No
Event to return a Boolean value indicating whether the overlay view is ready to draw its content.
Example
Function canDrawMapRect(mapRect as MKMapRectMBS, zoomScale as Double) Handles canDrawMapRect as Boolean
Return True
End Function

mapRect: The map rectangle that needs to be updated.
zoomScale: The current scale factor applied to the map.

Return yes if this overlay renderer is ready to draw its contents on the map or false if it is not.

Overlay renderers can override this method in situations where they may depend on the availability of other information to draw their contents. For example, a renderer showing traffic information might want to delay drawing until it has all of the traffic data it needs. In such a case, it can return NO from this method to indicate that it is not ready. An overlay renderer might also return false if it does not draw content in the specified rectangle.

If you return false from this method, your application is responsible for calling the setNeedsDisplayInMapRect method when the overlay renderer subsequently becomes ready to draw its contents.

The default implementation of this method returns YES.

As callback may come on a thread, MBS Xojo Plugin invokes event on the main thread. For best performance, please make sure your code does not take long time to execute.

MKCustomOverlayRendererMBS.DrawMapRect(mapRect as MKMapRectMBS, zoomScale as Double, context as CGContextMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event MapKit MBS MacFrameworks Plugin 19.2 ✅ Yes ❌ No ❌ No ❌ No
The event to draw the overlay’s contents at the specified location on the map.
Example
Sub DrawMapRect(mapRect as MKMapRectMBS, zoomScale as Double, context as CGContextMBS) Handles DrawMapRect
// change coordinate system to show just our area
Dim rect As CGRectMBS = Self.RectForMapRect(overlay.boundingMapRect)
context.ScaleCTM(1.0, -1.0)
context.TranslateCTM(0.0, -rect.size.height)

// and fill it all in red
context.SetRGBFillColor 1,0,0,0.3
context.FillRect rect

context.Flush
End Sub

mapRect: The map rectangle that needs to be updated. Your drawing code should avoid drawing outside of this rectangle.
zoomScale: 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.
context: The graphics context to use for drawing the overlay’s contents.

The default implementation of this method does nothing. Subclasses are expected to implement this event 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 CGPoint and 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.

To improve drawing performance, the map view may divide your overlay into multiple tiles and render each one on a separate thread.

As callback may come on a thread, MBS Xojo Plugin invokes event on the main thread. For best performance, please make sure your code does not take long time to execute.

The items on this page are in the following plugins: MBS MacFrameworks Plugin.


The biggest plugin in space...