platform-osx now vends a real NSView subclass, MGLMapView, that is readily embedded inside a Cocoa application for OS X. MGLMapView is backed by an NSOpenGLLayer for optimal performance and integration with other layer-backed views. It supports keyboard shortcuts and several gestures and hosts attribution, zooming, and rotation controls as subviews. osxapp is now a bona fide Cocoa application that embeds MGLMapView inside a XIB. osxapp has preferences and a share button for tight integration with custom styles. Enabling asynchronous rendering would be more consistent with iOS but increases CPU usage so much, even when idle, that it isn’t worth any performance gain. The bigger issue is that VAOs aren’t being used. make xpackage creates a static library similar to the one created by make ipackage. make clean cleans additional places where build output ends up. The OS X minimum deployment target has been increased from 10.9 to 10.10. osxapp’s window has a full size content view, which requires 10.10. Lightweight generics require iOS 9+ and OS X 10.11 regardless, because it was only in that release that Foundation collection classes started adopting lightweight generics. Shuffled files around and refactored annotations so that iOS and OS X share a good chunk of the annotations code, which now takes advantage of polymorphism. MGLMapView can now display annotations but cannot yet select them. In osxapp, a long press drops a pin, and so does the map view’s context menu. Annotations have NSPopovers as callouts, and their view controllers can be customized. Annotation image alignment rects are respected for hit testing purposes and for positioning the callout anchor. Callouts in osxapp demonstrate the use of bindings to keep callouts in sync with underlying model objects.
38 lines
2.6 KiB
Objective-C
38 lines
2.6 KiB
Objective-C
#import <Foundation/Foundation.h>
|
||
#import <CoreLocation/CoreLocation.h>
|
||
|
||
#import "MGLAnnotation.h"
|
||
#import "MGLGeometry.h"
|
||
|
||
#import "MGLTypes.h"
|
||
|
||
NS_ASSUME_NONNULL_BEGIN
|
||
|
||
/** The `MGLOverlay` protocol defines a specific type of annotation that represents both a point and an area on a map. Overlay objects are essentially data objects that contain the geographic data needed to represent the map area. For example, overlays can take the form of common shapes such as rectangles and circles. They can also describe polygons and other complex shapes.
|
||
*
|
||
* You use overlays to layer more sophisticated content on top of a map view. For example, you could use an overlay to show the boundaries of a national park or trace a bus route along city streets. The Mapbox iOS SDK defines several concrete classes that conform to this protocol and define standard shapes.
|
||
*
|
||
* Because overlays are also annotations, they have similar usage pattern to annotations. When added to a map view using the `addOverlay:` method, that view detects whenever the overlay’s defined region intersects the visible portion of the map. At that point, the map view asks its delegate to provide a special overlay view to draw the visual representation of the overlay. If you add an overlay to a map view as an annotation instead, it is treated as an annotation with a single point. */
|
||
@protocol MGLOverlay <MGLAnnotation>
|
||
|
||
/* The approximate center point of the overlay area. (required) (read-only)
|
||
*
|
||
* This point is typically set to the center point of the map’s bounding rectangle. It is used as the anchor point for any callouts displayed for the annotation. */
|
||
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
|
||
|
||
/** The cooordinate rectangle that encompasses the overlay. (required) (read-only)
|
||
*
|
||
* This property contains the smallest rectangle that completely encompasses the overlay. Implementers of this protocol must set this area when implementing their overlay class, and after setting it, you must not change it. */
|
||
@property (nonatomic, readonly) MGLCoordinateBounds overlayBounds;
|
||
|
||
/** Returns a Boolean indicating whether the specified rectangle intersects the receiver’s shape.
|
||
*
|
||
* You can implement this method to provide more specific bounds checking for an overlay. If you do not implement it, the bounding rectangle is used to detect intersections.
|
||
* @param overlayBounds The rectangle to intersect with the receiver’s area.
|
||
* @return `YES` if any part of the map rectangle intersects the receiver’s shape or `NO` if it does not. */
|
||
- (BOOL)intersectsOverlayBounds:(MGLCoordinateBounds)overlayBounds;
|
||
|
||
@end
|
||
|
||
NS_ASSUME_NONNULL_END
|