diff options
Diffstat (limited to 'include')
39 files changed, 617 insertions, 3136 deletions
diff --git a/include/mbgl/darwin/MGLAnnotation.h b/include/mbgl/darwin/MGLAnnotation.h deleted file mode 100644 index e4726f9503..0000000000 --- a/include/mbgl/darwin/MGLAnnotation.h +++ /dev/null @@ -1,48 +0,0 @@ -#import <Foundation/Foundation.h> -#import <CoreLocation/CoreLocation.h> -#import <TargetConditionals.h> - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - The `MGLAnnotation` protocol is used to provide annotation-related information to a map view. To use this protocol, you adopt it in any custom objects that store or represent annotation data. Each object then serves as the source of information about a single map annotation and provides critical information, such as the annotation’s location on the map. Annotation objects do not provide the visual representation of the annotation but typically coordinate (in conjunction with the map view’s delegate) the creation of an appropriate objects to handle the display. - - An object that adopts this protocol must implement the `coordinate` property. The other methods of this protocol are optional. - */ -@protocol MGLAnnotation <NSObject> - -#pragma mark Position Attributes - -/** The center point (specified as a map coordinate) of the annotation. (required) (read-only) */ -@property (nonatomic, readonly) CLLocationCoordinate2D coordinate; - -@optional - -#pragma mark Title Attributes - -/** - The string containing the annotation’s title. - - Although this property is optional, if you support the selection of annotations in your map view, you are expected to provide this property. This string is displayed in the callout for the associated annotation. - */ -@property (nonatomic, readonly, copy, nullable) NSString *title; - -/** - The string containing the annotation’s subtitle. - - This string is displayed in the callout for the associated annotation. - */ -@property (nonatomic, readonly, copy, nullable) NSString *subtitle; - -#if !TARGET_OS_IPHONE - -/** The string containing the annotation’s tooltip. */ -@property (nonatomic, readonly, copy, nullable) NSString *toolTip; - -#endif - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/darwin/MGLGeometry.h b/include/mbgl/darwin/MGLGeometry.h deleted file mode 100644 index 8d185805db..0000000000 --- a/include/mbgl/darwin/MGLGeometry.h +++ /dev/null @@ -1,99 +0,0 @@ -#import <Foundation/Foundation.h> -#import <CoreLocation/CoreLocation.h> -#import <CoreGraphics/CGBase.h> - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** Defines the area spanned by an `MGLCoordinateBounds`. */ -typedef struct MGLCoordinateSpan { - /** Latitudes spanned by an `MGLCoordinateBounds`. */ - CLLocationDegrees latitudeDelta; - /** Longitudes spanned by an `MGLCoordinateBounds`. */ - CLLocationDegrees longitudeDelta; -} MGLCoordinateSpan; - -/** Creates a new `MGLCoordinateSpan` from the given latitudinal and longitudinal deltas. */ -NS_INLINE MGLCoordinateSpan MGLCoordinateSpanMake(CLLocationDegrees latitudeDelta, CLLocationDegrees longitudeDelta) { - MGLCoordinateSpan span; - span.latitudeDelta = latitudeDelta; - span.longitudeDelta = longitudeDelta; - return span; -} - -/** Returns `YES` if the two coordinate spans represent the same latitudinal change and the same longitudinal change. */ -NS_INLINE BOOL MGLCoordinateSpanEqualToCoordinateSpan(MGLCoordinateSpan span1, MGLCoordinateSpan span2) { - return (span1.latitudeDelta == span2.latitudeDelta && - span1.longitudeDelta == span2.longitudeDelta); -} - -/** An area of zero width and zero height. */ -extern const MGLCoordinateSpan MGLCoordinateSpanZero; - -/** A rectangular area as measured on a two-dimensional map projection. */ -typedef struct MGLCoordinateBounds { - /** Coordinate at the southwest corner. */ - CLLocationCoordinate2D sw; - /** Coordinate at the northeast corner. */ - CLLocationCoordinate2D ne; -} MGLCoordinateBounds; - -/** Creates a new `MGLCoordinateBounds` structure from the given southwest and northeast coordinates. */ -NS_INLINE MGLCoordinateBounds MGLCoordinateBoundsMake(CLLocationCoordinate2D sw, CLLocationCoordinate2D ne) { - MGLCoordinateBounds bounds; - bounds.sw = sw; - bounds.ne = ne; - return bounds; -} - -/** Returns `YES` if the two coordinate bounds are equal to each other. */ -NS_INLINE BOOL MGLCoordinateBoundsEqualToCoordinateBounds(MGLCoordinateBounds bounds1, MGLCoordinateBounds bounds2) { - return (bounds1.sw.latitude == bounds2.sw.latitude && - bounds1.sw.longitude == bounds2.sw.longitude && - bounds1.ne.latitude == bounds2.ne.latitude && - bounds1.ne.longitude == bounds2.ne.longitude); -} - -/** Returns the area spanned by the coordinate bounds. */ -NS_INLINE MGLCoordinateSpan MGLCoordinateBoundsGetCoordinateSpan(MGLCoordinateBounds bounds) { - return MGLCoordinateSpanMake(bounds.ne.latitude - bounds.sw.latitude, - bounds.ne.longitude - bounds.sw.longitude); -} - -/** Returns a coordinate bounds with southwest and northeast coordinates that are offset from those of the source bounds. */ -NS_INLINE MGLCoordinateBounds MGLCoordinateBoundsOffset(MGLCoordinateBounds bounds, MGLCoordinateSpan offset) { - MGLCoordinateBounds offsetBounds = bounds; - offsetBounds.sw.latitude += offset.latitudeDelta; - offsetBounds.sw.longitude += offset.longitudeDelta; - offsetBounds.ne.latitude += offset.latitudeDelta; - offsetBounds.ne.longitude += offset.longitudeDelta; - return offsetBounds; -} - -/** Returns `YES` if the coordinate bounds covers no area. - - Note that a bounds may be empty but have a non-zero coordinate span (e.g., when its northeast point lies due north of its southwest point). */ -NS_INLINE BOOL MGLCoordinateBoundsIsEmpty(MGLCoordinateBounds bounds) { - MGLCoordinateSpan span = MGLCoordinateBoundsGetCoordinateSpan(bounds); - return span.latitudeDelta == 0 || span.longitudeDelta == 0; -} - -/** Returns a formatted string for the given coordinate bounds. */ -NS_INLINE NSString *MGLStringFromCoordinateBounds(MGLCoordinateBounds bounds) { - return [NSString stringWithFormat:@"{{%.1f, %.1f}, {%.1f, %.1f}}", - bounds.sw.latitude, bounds.sw.longitude, - bounds.ne.latitude, bounds.ne.longitude]; -} - -/** Returns radians, converted from degrees. */ -NS_INLINE CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees) { - return (CGFloat)(degrees * M_PI) / 180; -} - -/** Returns degrees, converted from radians. */ -NS_INLINE CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) { - return radians * 180 / M_PI; -} - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/darwin/MGLMapCamera.h b/include/mbgl/darwin/MGLMapCamera.h deleted file mode 100644 index 3cb902ba52..0000000000 --- a/include/mbgl/darwin/MGLMapCamera.h +++ /dev/null @@ -1,53 +0,0 @@ -#import <Foundation/Foundation.h> -#import <CoreGraphics/CoreGraphics.h> -#import <CoreLocation/CoreLocation.h> - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** An `MGLMapCamera` object represents a viewpoint from which the user observes some point on an `MGLMapView`. */ -@interface MGLMapCamera : NSObject <NSSecureCoding, NSCopying> - -/** Coordinate at the center of the map view. */ -@property (nonatomic) CLLocationCoordinate2D centerCoordinate; - -/** Heading measured in degrees clockwise from true north. */ -@property (nonatomic) CLLocationDirection heading; - -/** Pitch toward the horizon measured in degrees, with 0 degrees resulting in a two-dimensional map. */ -@property (nonatomic) CGFloat pitch; - -/** Meters above ground level. */ -@property (nonatomic) CLLocationDistance altitude; - -/** Returns a new camera with all properties set to 0. */ -+ (instancetype)camera; - -/** - Returns a new camera using based on information about the camera’s viewpoint and focus point. - - @param centerCoordinate The geographic coordinate on which the map should be centered. - @param eyeCoordinate The geometric coordinate at which the camera should be situated. - @param eyeAltitude The altitude (measured in meters) above the map at which the camera should be situated. The altitude may be less than the distance from the camera’s viewpoint to the camera’s focus point. - */ -+ (instancetype)cameraLookingAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate - fromEyeCoordinate:(CLLocationCoordinate2D)eyeCoordinate - eyeAltitude:(CLLocationDistance)eyeAltitude; - -/** - Returns a new camera with the given distance, pitch, and heading. - - @param centerCoordinate The geographic coordinate on which the map should be centered. - @param distance The straight-line distance from the viewpoint to the `centerCoordinate`. - @param pitch The viewing angle of the camera, measured in degrees. A value of `0` results in a camera pointed straight down at the map. Angles greater than `0` result in a camera angled toward the horizon. - @param heading The camera’s heading, measured in degrees clockwise from true north. A value of `0` means that the top edge of the map view corresponds to true north. The value `90` means the top of the map is pointing due east. The value `180` means the top of the map points due south, and so on. - */ -+ (instancetype)cameraLookingAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate - fromDistance:(CLLocationDistance)distance - pitch:(CGFloat)pitch - heading:(CLLocationDirection)heading; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/darwin/MGLMultiPoint.h b/include/mbgl/darwin/MGLMultiPoint.h deleted file mode 100644 index ad9db1e681..0000000000 --- a/include/mbgl/darwin/MGLMultiPoint.h +++ /dev/null @@ -1,26 +0,0 @@ -#import <Foundation/Foundation.h> -#import <CoreLocation/CoreLocation.h> - -#import "MGLShape.h" - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** The `MGLMultiPoint` class is an abstract superclass used to define shapes composed of multiple points. You should not create instances of this class directly. Instead, you should create instances of the `MGLPolyline` or `MGLPolygon` classes. However, you can use the method and properties of this class to access information about the specific points associated with the line or polygon. */ -@interface MGLMultiPoint : MGLShape - -/** The number of points associated with the shape. (read-only) */ -@property (nonatomic, readonly) NSUInteger pointCount; - -/** - Retrieves one or more coordinates associated with the shape. - - @param coords On input, you must provide a C array of structures large enough to hold the desired number of coordinates. On output, this structure contains the requested coordinate data. - @param range The range of points you want. The `location` field indicates the first point you are requesting, with `0` being the first point, `1` being the second point, and so on. The `length` field indicates the number of points you want. The array in _`coords`_ must be large enough to accommodate the number of requested coordinates. - */ -- (void)getCoordinates:(CLLocationCoordinate2D *)coords range:(NSRange)range; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/darwin/MGLOverlay.h b/include/mbgl/darwin/MGLOverlay.h deleted file mode 100644 index aa80fe3900..0000000000 --- a/include/mbgl/darwin/MGLOverlay.h +++ /dev/null @@ -1,46 +0,0 @@ -#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 diff --git a/include/mbgl/darwin/MGLPointAnnotation.h b/include/mbgl/darwin/MGLPointAnnotation.h deleted file mode 100644 index d186cbff18..0000000000 --- a/include/mbgl/darwin/MGLPointAnnotation.h +++ /dev/null @@ -1,18 +0,0 @@ -#import <Foundation/Foundation.h> -#import <CoreLocation/CoreLocation.h> - -#import "MGLShape.h" - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** The `MGLPointAnnotation` class defines a concrete annotation object located at a specified point. You can use this class, rather than define your own, in situations where all you want to do is associate a point on the map with a title. */ -@interface MGLPointAnnotation : MGLShape - -/** The coordinate point of the annotation, specified as a latitude and longitude. */ -@property (nonatomic, assign) CLLocationCoordinate2D coordinate; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/darwin/MGLPolygon.h b/include/mbgl/darwin/MGLPolygon.h deleted file mode 100644 index c5480264fb..0000000000 --- a/include/mbgl/darwin/MGLPolygon.h +++ /dev/null @@ -1,26 +0,0 @@ -#import <Foundation/Foundation.h> -#import <CoreLocation/CoreLocation.h> - -#import "MGLMultiPoint.h" -#import "MGLOverlay.h" - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** The `MGLPolygon` class represents a shape consisting of one or more points that define a closed polygon. The points are connected end-to-end in the order they are provided. The first and last points are connected to each other to create the closed shape. */ -@interface MGLPolygon : MGLMultiPoint <MGLOverlay> - -/** - Creates and returns an `MGLPolygon` object from the specified set of coordinates. - - @param coords The array of coordinates defining the shape. The data in this array is copied to the new object. - @param count The number of items in the `coords` array. - @return A new polygon object. - */ -+ (instancetype)polygonWithCoordinates:(CLLocationCoordinate2D *)coords - count:(NSUInteger)count; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/darwin/MGLPolyline.h b/include/mbgl/darwin/MGLPolyline.h deleted file mode 100644 index c28299c7e0..0000000000 --- a/include/mbgl/darwin/MGLPolyline.h +++ /dev/null @@ -1,26 +0,0 @@ -#import <Foundation/Foundation.h> -#import <CoreLocation/CoreLocation.h> - -#import "MGLMultiPoint.h" -#import "MGLOverlay.h" - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** The `MGLPolyline` class represents a shape consisting of one or more points that define connecting line segments. The points are connected end-to-end in the order they are provided. The first and last points are not connected to each other. */ -@interface MGLPolyline : MGLMultiPoint <MGLOverlay> - -/** - Creates and returns an `MGLPolyline` object from the specified set of coordinates. - - @param coords The array of coordinates defining the shape. The data in this array is copied to the new object. - @param count The number of items in the `coords` array. - @return A new polyline object. - */ -+ (instancetype)polylineWithCoordinates:(CLLocationCoordinate2D *)coords - count:(NSUInteger)count; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/darwin/MGLShape.h b/include/mbgl/darwin/MGLShape.h deleted file mode 100644 index c1b84816f2..0000000000 --- a/include/mbgl/darwin/MGLShape.h +++ /dev/null @@ -1,27 +0,0 @@ -#import <Foundation/Foundation.h> - -#import "MGLAnnotation.h" - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** The `MGLShape` class is an abstract class that defines the basic properties for all shape-based annotation objects. This class must be subclassed and cannot be used as is. Subclasses are responsible for defining the geometry of the shape and providing an appropriate value for the coordinate property inherited from the `MGLAnnotation` protocol. */ -@interface MGLShape : NSObject <MGLAnnotation> - -/** The title of the shape annotation. The default value of this property is `nil`. */ -@property (nonatomic, copy, nullable) NSString *title; - -/** The subtitle of the shape annotation. The default value of this property is `nil`. */ -@property (nonatomic, copy, nullable) NSString *subtitle; - -#if !TARGET_OS_IPHONE - -/** The tooltip of the shape annotation. The default value of this property is `nil`. */ -@property (nonatomic, copy, nullable) NSString *toolTip; - -#endif - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/darwin/MGLStyle.h b/include/mbgl/darwin/MGLStyle.h deleted file mode 100644 index e5b2de877c..0000000000 --- a/include/mbgl/darwin/MGLStyle.h +++ /dev/null @@ -1,56 +0,0 @@ -#import <Foundation/Foundation.h> - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** A collection of convenience methods for creating style URLs of default styles provided by Mapbox. These instances of NSURL are cached. */ -@interface MGLStyle : NSObject - -/** - Returns the Streets style URL. - - Mapbox Streets is a complete base map, perfect for incorporating your own data. - */ -+ (NSURL *)streetsStyleURL; - -/** - Returns the Emerald style URL. - - Emerald is a versatile style with emphasis on road networks and public transportation. - */ -+ (NSURL *)emeraldStyleURL; - -/** - Returns the Light style URL. - - Light is a subtle, light-colored backdrop for data visualizations. - */ -+ (NSURL *)lightStyleURL; - -/** - Returns the Dark style URL. - - Dark is a subtle, dark-colored backdrop for data visualizations. - */ -+ (NSURL *)darkStyleURL; - -/** - Returns the Satellite style URL. - - Mapbox Satellite is a beautiful global satellite and aerial imagery layer. - */ -+ (NSURL *)satelliteStyleURL; - -/** - Returns the Hybrid style URL. - - Hybrid combines the global satellite and aerial imagery of Mapbox Satellite with unobtrusive labels. - */ -+ (NSURL *)hybridStyleURL; - -- (instancetype)init NS_UNAVAILABLE; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/darwin/MGLTypes.h b/include/mbgl/darwin/MGLTypes.h deleted file mode 100644 index c107055dbb..0000000000 --- a/include/mbgl/darwin/MGLTypes.h +++ /dev/null @@ -1,53 +0,0 @@ -#import <Foundation/Foundation.h> - -#pragma once - -#if !__has_feature(nullability) - #define NS_ASSUME_NONNULL_BEGIN - #define NS_ASSUME_NONNULL_END - #define nullable - #define nonnull - #define null_resettable -#endif - -NS_ASSUME_NONNULL_BEGIN - -/** Indicates an error occurred in the Mapbox SDK. */ -extern NSString * const MGLErrorDomain; - -/** The mode used to track the user location on the map. */ -typedef NS_ENUM(NSUInteger, MGLUserTrackingMode) { - /** The map does not follow the user location. */ - MGLUserTrackingModeNone = 0, - /** The map follows the user location. */ - MGLUserTrackingModeFollow, - /** The map follows the user location and rotates when the heading changes. */ - MGLUserTrackingModeFollowWithHeading, - /** The map follows the user location and rotates when the course changes. */ - MGLUserTrackingModeFollowWithCourse, -}; - -NS_ASSUME_NONNULL_END - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wvariadic-macros" - #ifndef NS_ARRAY_OF - // Foundation collection classes adopted lightweight generics in iOS 9.0 and OS X 10.11 SDKs. - #if __has_feature(objc_generics) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 90000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101100) - /** Inserts a type specifier for a pointer to a lightweight generic with the given collection and object classes. Use a `*` for any non-`id` object classes but no `*` for the collection class. */ - #define NS_ARRAY_OF(ObjectClass...) NSArray <ObjectClass> - #define NS_MUTABLE_ARRAY_OF(ObjectClass...) NSMutableArray <ObjectClass> - #define NS_SET_OF(ObjectClass...) NSSet <ObjectClass> - #define NS_MUTABLE_SET_OF(ObjectClass...) NSMutableSet <ObjectClass> - #define NS_DICTIONARY_OF(ObjectClass...) NSDictionary <ObjectClass> - #define NS_MUTABLE_DICTIONARY_OF(ObjectClass...) NSMutableDictionary <ObjectClass> - #else - #define NS_ARRAY_OF(ObjectClass...) NSArray - #define NS_MUTABLE_ARRAY_OF(ObjectClass...) NSMutableArray - #define NS_SET_OF(ObjectClass...) NSSet - #define NS_MUTABLE_SET_OF(ObjectClass...) NSMutableSet - #define NS_DICTIONARY_OF(ObjectClass...) NSDictionary - #define NS_MUTABLE_DICTIONARY_OF(ObjectClass...) NSMutableDictionary - #endif - #endif -#pragma clang diagnostic pop diff --git a/include/mbgl/platform/gl.hpp b/include/mbgl/gl/gl.hpp index 1e98ea7f3b..2d9b3f7a71 100644 --- a/include/mbgl/platform/gl.hpp +++ b/include/mbgl/gl/gl.hpp @@ -1,5 +1,5 @@ -#ifndef MBGL_RENDERER_GL -#define MBGL_RENDERER_GL +#ifndef MBGL_GL_GL +#define MBGL_GL_GL //#define GL_TRACK @@ -110,6 +110,32 @@ public: using glProc = void (*)(); void InitializeExtensions(glProc (*getProcAddress)(const char *)); +static gl::ExtensionFunction< + void (GLuint array)> + BindVertexArray({ + {"GL_ARB_vertex_array_object", "glBindVertexArray"}, + {"GL_OES_vertex_array_object", "glBindVertexArrayOES"}, + {"GL_APPLE_vertex_array_object", "glBindVertexArrayAPPLE"} + }); + +static gl::ExtensionFunction< + void (GLsizei n, + const GLuint* arrays)> + DeleteVertexArrays({ + {"GL_ARB_vertex_array_object", "glDeleteVertexArrays"}, + {"GL_OES_vertex_array_object", "glDeleteVertexArraysOES"}, + {"GL_APPLE_vertex_array_object", "glDeleteVertexArraysAPPLE"} + }); + +static gl::ExtensionFunction< + void (GLsizei n, + GLuint* arrays)> + GenVertexArrays({ + {"GL_ARB_vertex_array_object", "glGenVertexArrays"}, + {"GL_OES_vertex_array_object", "glGenVertexArraysOES"}, + {"GL_APPLE_vertex_array_object", "glGenVertexArraysAPPLE"} + }); + } // namespace gl } // namespace mbgl diff --git a/include/mbgl/gl/gl_helper.hpp b/include/mbgl/gl/gl_helper.hpp new file mode 100644 index 0000000000..4f3990a434 --- /dev/null +++ b/include/mbgl/gl/gl_helper.hpp @@ -0,0 +1,23 @@ +#ifndef MBGL_GL_GL_HELPER +#define MBGL_GL_GL_HELPER + +namespace mbgl { +namespace gl { + +template <typename T> +class Preserve { +public: + inline Preserve() : data(T::Get()) { + } + inline ~Preserve() { + T::Set(data); + } + +private: + const typename T::Type data; +}; + +} // namespace gl +} // namespace mbgl + +#endif diff --git a/include/mbgl/gl/gl_values.hpp b/include/mbgl/gl/gl_values.hpp new file mode 100644 index 0000000000..a5d413f5af --- /dev/null +++ b/include/mbgl/gl/gl_values.hpp @@ -0,0 +1,277 @@ +#ifndef MBGL_GL_GL_VALUES +#define MBGL_GL_GL_VALUES + +#include <cstdint> +#include <tuple> +#include <array> + +#include <mbgl/gl/gl.hpp> + +namespace mbgl { +namespace gl { + +struct ClearDepth { + using Type = GLfloat; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glClearDepth(value)); + } + inline static Type Get() { + Type clearDepth; + MBGL_CHECK_ERROR(glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth)); + return clearDepth; + } +}; + +struct ClearColor { + struct Type { GLfloat r, g, b, a; }; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glClearColor(value.r, value.g, value.b, value.a)); + } + inline static Type Get() { + GLfloat floats[4]; + MBGL_CHECK_ERROR(glGetFloatv(GL_COLOR_CLEAR_VALUE, floats)); + return { floats[0], floats[1], floats[2], floats[3] }; + } +}; + +inline bool operator!=(const ClearColor::Type& a, const ClearColor::Type& b) { + return a.r != b.r || a.g != b.g || a.b != b.b || a.a != b.a; +} + +struct ClearStencil { + using Type = GLint; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glClearStencil(value)); + } + inline static Type Get() { + Type clearStencil; + MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil)); + return clearStencil; + } +}; + +struct StencilMask { + using Type = GLuint; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glStencilMask(value)); + } + inline static Type Get() { + GLint stencilMask; + MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_WRITEMASK, &stencilMask)); + return stencilMask; + } +}; + +struct DepthMask { + using Type = GLboolean; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glDepthMask(value)); + } + inline static Type Get() { + Type depthMask; + MBGL_CHECK_ERROR(glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask)); + return depthMask; + } +}; + +struct ColorMask { + struct Type { bool r, g, b, a; }; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glColorMask(value.r, value.g, value.b, value.a)); + } + inline static Type Get() { + GLboolean bools[4]; + MBGL_CHECK_ERROR(glGetBooleanv(GL_COLOR_WRITEMASK, bools)); + return { static_cast<bool>(bools[0]), static_cast<bool>(bools[1]), + static_cast<bool>(bools[2]), static_cast<bool>(bools[3]) }; + } +}; + +inline bool operator!=(const ColorMask::Type& a, const ColorMask::Type& b) { + return a.r != b.r || a.g != b.g || a.b != b.b || a.a != b.a; +} + +struct StencilFunc { + struct Type { GLenum func; GLint ref; GLuint mask; }; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glStencilFunc(value.func, value.ref, value.mask)); + } + inline static Type Get() { + GLint func, ref, mask; + MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_FUNC, &func)); + MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_REF, &ref)); + MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_VALUE_MASK, &mask)); + return { static_cast<GLenum>(func), ref, static_cast<GLuint>(mask) }; + } +}; + +inline bool operator!=(const StencilFunc::Type& a, const StencilFunc::Type& b) { + return a.func != b.func || a.ref != b.ref || a.mask != b.mask; +} + +struct StencilTest { + using Type = bool; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(value ? glEnable(GL_STENCIL_TEST) : glDisable(GL_STENCIL_TEST)); + } + inline static Type Get() { + Type stencilTest; + MBGL_CHECK_ERROR(stencilTest = glIsEnabled(GL_STENCIL_TEST)); + return stencilTest; + } +}; + +struct StencilOp { + struct Type { GLenum sfail, dpfail, dppass; }; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glStencilOp(value.sfail, value.dpfail, value.dppass)); + } + inline static Type Get() { + GLint sfail, dpfail, dppass; + MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_FAIL, &sfail)); + MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &dpfail)); + MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &dppass)); + return { static_cast<GLenum>(sfail), static_cast<GLenum>(dpfail), static_cast<GLuint>(dppass) }; + } +}; + +struct DepthRange { + struct Type { GLfloat near, far; }; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glDepthRange(value.near, value.far)); + } + inline static Type Get() { + GLfloat floats[2]; + MBGL_CHECK_ERROR(glGetFloatv(GL_DEPTH_RANGE, floats)); + return { floats[0], floats[1] }; + } +}; + +inline bool operator!=(const DepthRange::Type& a, const DepthRange::Type& b) { + return a.near != b.near || a.far != b.far; +} + +struct DepthTest { + using Type = bool; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(value ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST)); + } + inline static Type Get() { + Type depthTest; + MBGL_CHECK_ERROR(depthTest = glIsEnabled(GL_DEPTH_TEST)); + return depthTest; + } +}; + +struct DepthFunc { + using Type = GLenum; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glDepthFunc(value)); + } + inline static Type Get() { + GLint depthFunc; + MBGL_CHECK_ERROR(glGetIntegerv(GL_DEPTH_FUNC, &depthFunc)); + return depthFunc; + } +}; + +struct Blend { + using Type = bool; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(value ? glEnable(GL_BLEND) : glDisable(GL_BLEND)); + } + inline static Type Get() { + Type blend; + MBGL_CHECK_ERROR(blend = glIsEnabled(GL_BLEND)); + return blend; + } +}; + +struct BlendFunc { + struct Type { GLenum sfactor, dfactor; }; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glBlendFunc(value.sfactor, value.dfactor)); + } + inline static Type Get() { + GLint sfactor, dfactor; + MBGL_CHECK_ERROR(glGetIntegerv(GL_BLEND_SRC_ALPHA, &sfactor)); + MBGL_CHECK_ERROR(glGetIntegerv(GL_BLEND_DST_ALPHA, &dfactor)); + return { static_cast<GLenum>(sfactor), static_cast<GLenum>(dfactor) }; + } +}; + +struct Program { + using Type = GLuint; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glUseProgram(value)); + } + inline static Type Get() { + GLint program; + MBGL_CHECK_ERROR(glGetIntegerv(GL_CURRENT_PROGRAM, &program)); + return program; + } +}; + +struct LineWidth { + using Type = GLfloat; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glLineWidth(value)); + } + inline static Type Get() { + Type lineWidth; + MBGL_CHECK_ERROR(glGetFloatv(GL_LINE_WIDTH, &lineWidth)); + return lineWidth; + } +}; + +#ifndef GL_ES_VERSION_2_0 + +struct PixelZoom { + struct Type { GLfloat xfactor; GLfloat yfactor; }; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glPixelZoom(value.xfactor, value.yfactor)); + } + inline static Type Get() { + Type value; + MBGL_CHECK_ERROR(glGetFloatv(GL_ZOOM_X, &value.xfactor)); + MBGL_CHECK_ERROR(glGetFloatv(GL_ZOOM_Y, &value.yfactor)); + return value; + } +}; + +struct RasterPos { + using Type = std::array<GLdouble, 4>; + static const Type Default; + inline static void Set(const Type& value) { + MBGL_CHECK_ERROR(glRasterPos4d(value[0], value[1], value[2], value[3])); + } + inline static Type Get() { + Type pos; + MBGL_CHECK_ERROR(glGetDoublev(GL_CURRENT_RASTER_POSITION, pos.data())); + return pos; + } +}; + +#endif + +} // namespace gl +} // namespace mbgl + +#endif // MBGL_RENDERER_GL_CONFIG diff --git a/include/mbgl/ios/MGLAccountManager.h b/include/mbgl/ios/MGLAccountManager.h deleted file mode 100644 index c52ef08607..0000000000 --- a/include/mbgl/ios/MGLAccountManager.h +++ /dev/null @@ -1,33 +0,0 @@ -#import <Foundation/Foundation.h> - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** The MGLAccountManager object provides a global way to set a Mapbox API access token, as well as other settings used framework-wide. */ -@interface MGLAccountManager : NSObject - -#pragma mark Authorizing Access - -/** - Set the Mapbox API access token for the framework. - - You can set an access token on MGLAccountManager or on an individual map view. The same token is used throughout the framework. - @param accessToken The Mapbox API access token. - */ -+ (void)setAccessToken:(nullable NSString *)accessToken; - -/** - Retreive the Mapbox API access token for the framework. - - You can set an access token on MGLAccountManager or on an individual map view. The same token is used throughout the framework. - - @return accessToken The Mapbox API access token. - */ -+ (nullable NSString *)accessToken; - -+ (BOOL)mapboxMetricsEnabledSettingShownInApp __attribute__((deprecated("Telemetry settings are now always shown in the ℹ️ menu."))); - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/ios/MGLAnnotationImage.h b/include/mbgl/ios/MGLAnnotationImage.h deleted file mode 100644 index f9d9e70566..0000000000 --- a/include/mbgl/ios/MGLAnnotationImage.h +++ /dev/null @@ -1,44 +0,0 @@ -#import <UIKit/UIKit.h> - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** The MGLAnnotationImage class is responsible for presenting point-based annotations visually on a map view. Annotation image objects wrap `UIImage` objects and may be recycled later and put into a reuse queue that is maintained by the map view. */ -@interface MGLAnnotationImage : NSObject - -#pragma mark Initializing and Preparing the Image Object - -/** - Initializes and returns a new annotation image object. - - @param image The image to be displayed for the annotation. - @param reuseIdentifier The string that identifies that this annotation image is reusable. - @return The initialized annotation image object or `nil` if there was a problem initializing the object. - */ -+ (instancetype)annotationImageWithImage:(UIImage *)image reuseIdentifier:(NSString *)reuseIdentifier; - -#pragma mark Getting and Setting Attributes - -/** The image to be displayed for the annotation. */ -@property (nonatomic, strong) UIImage *image; - -/** - The string that identifies that this annotation image is reusable. (read-only) - - You specify the reuse identifier when you create the image object. You use this type later to retrieve an annotation image object that was created previously but which is currently unused because its annotation is not on screen. - - If you define distinctly different types of annotations (with distinctly different annotation images to go with them), you can differentiate between the annotation types by specifying different reuse identifiers for each one. - */ -@property (nonatomic, readonly) NSString *reuseIdentifier; - -/** - A Boolean value indicating whether the annotation is enabled. - - The default value of this property is `YES`. If the value of this property is `NO`, the annotation image ignores touch events and cannot be selected. - */ -@property (nonatomic, getter=isEnabled) BOOL enabled; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/ios/MGLCalloutView.h b/include/mbgl/ios/MGLCalloutView.h deleted file mode 100644 index 8e72ee9d68..0000000000 --- a/include/mbgl/ios/MGLCalloutView.h +++ /dev/null @@ -1,67 +0,0 @@ -#import <Foundation/Foundation.h> - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -@protocol MGLCalloutViewDelegate; -@protocol MGLAnnotation; - -/** - A protocol for a `UIView` subclass that displays information about a selected annotation near that annotation. - */ -@protocol MGLCalloutView <NSObject> - -/** - An object conforming to the `MGLAnnotation` protocol whose details this callout view displays. - */ -@property (nonatomic, strong) id <MGLAnnotation> representedObject; - -/** - A view that the user may tap to perform an action. This view is conventionally positioned on the left side of the callout view. - */ -@property (nonatomic, strong) UIView *leftAccessoryView; - -/** - A view that the user may tap to perform an action. This view is conventionally positioned on the right side of the callout view. - */ -@property (nonatomic, strong) UIView *rightAccessoryView; - -/** - An object conforming to the `MGLCalloutViewDelegate` method that receives messages related to the callout view’s interactive subviews. - */ -@property (nonatomic, weak) id<MGLCalloutViewDelegate> delegate; - -/** - Presents a callout view by adding it to `inView` and pointing at the given rect of `inView`’s bounds. Constrains the callout to the bounds of the given view. - */ -- (void)presentCalloutFromRect:(CGRect)rect inView:(UIView *)view constrainedToView:(UIView *)constrainedView animated:(BOOL)animated; - -/** - Dismisses the callout view. - */ -- (void)dismissCalloutAnimated:(BOOL)animated; - -@end - -/** - The MGLCalloutViewDelegate protocol defines a set of optional methods that you can use to receive messages from an object that conforms to the MGLCalloutView protocol. The callout view uses these methods to inform the delegate that the user has interacted with the the callout view. - */ -@protocol MGLCalloutViewDelegate <NSObject> - -@optional -/** - Returns a Boolean value indicating whether the entire callout view “highlights” when tapped. The default value is `YES`, which means the callout view highlights when tapped. - - The return value of this method is ignored unless the delegate also responds to the `-calloutViewTapped` method. - */ -- (BOOL)calloutViewShouldHighlight:(UIView<MGLCalloutView> *)calloutView; - -/** - Tells the delegate that the callout view has been tapped. - */ -- (void)calloutViewTapped:(UIView<MGLCalloutView> *)calloutView; - -@end - -NS_ASSUME_NONNULL_END
\ No newline at end of file diff --git a/include/mbgl/ios/MGLMapView+IBAdditions.h b/include/mbgl/ios/MGLMapView+IBAdditions.h deleted file mode 100644 index f18df56e01..0000000000 --- a/include/mbgl/ios/MGLMapView+IBAdditions.h +++ /dev/null @@ -1,49 +0,0 @@ -#import <Foundation/Foundation.h> - -#import "MGLTypes.h" - -@class MGLMapView; - -NS_ASSUME_NONNULL_BEGIN - -@interface MGLMapView (IBAdditions) - -// Core properties that can be manipulated in the Attributes inspector in -// Interface Builder. These redeclarations merely add the IBInspectable keyword. -// They appear here to ensure that they appear above the convenience properties; -// inspectables declared in MGLMapView.h are always sorted before those in -// MGLMapView+IBAdditions.h, due to ASCII sort order. - -#if TARGET_INTERFACE_BUILDER - -// HACK: We want this property to look like a URL bar in the Attributes -// inspector, but just calling it styleURL would violate Cocoa naming -// conventions and conflict with the existing NSURL property. Fortunately, IB -// strips out the two underscores for display. -@property (nonatomic, nullable) IBInspectable NSString *styleURL__; - -#endif // TARGET_INTERFACE_BUILDER - -// Convenience properties related to the initial viewport. These properties -// are not meant to be used outside of Interface Builder. latitude and longitude -// are backed by properties of type CLLocationDegrees, but these declarations -// must use the type double because Interface Builder is unaware that -// CLLocationDegrees is a typedef for double. - -@property (nonatomic) IBInspectable double latitude; -@property (nonatomic) IBInspectable double longitude; -@property (nonatomic) IBInspectable double zoomLevel; - -// Renamed properties. Interface Builder derives the display name of each -// inspectable from the runtime name, but runtime names don’t always make sense -// in UI. - -@property (nonatomic) IBInspectable BOOL allowsZooming; -@property (nonatomic) IBInspectable BOOL allowsScrolling; -@property (nonatomic) IBInspectable BOOL allowsRotating; -@property (nonatomic) IBInspectable BOOL allowsTilting; -@property (nonatomic) IBInspectable BOOL showsUserLocation; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/ios/MGLMapView+MGLCustomStyleLayerAdditions.h b/include/mbgl/ios/MGLMapView+MGLCustomStyleLayerAdditions.h deleted file mode 100644 index de4dc01f99..0000000000 --- a/include/mbgl/ios/MGLMapView+MGLCustomStyleLayerAdditions.h +++ /dev/null @@ -1,26 +0,0 @@ -#import "MGLMapView.h" - -NS_ASSUME_NONNULL_BEGIN - -typedef void (^MGLCustomStyleLayerPreparationHandler)(void); - -typedef void (^MGLCustomStyleLayerDrawingHandler)(CGSize size, - CLLocationCoordinate2D centerCoordinate, - double zoomLevel, - CLLocationDirection direction, - CGFloat pitch, - CGFloat perspectiveSkew); - -typedef void (^MGLCustomStyleLayerCompletionHandler)(void); - -@interface MGLMapView (MGLCustomStyleLayerAdditions) - -- (void)insertCustomStyleLayerWithIdentifier:(NSString *)identifier preparationHandler:(MGLCustomStyleLayerPreparationHandler)preparation drawingHandler:(MGLCustomStyleLayerDrawingHandler)drawing completionHandler:(MGLCustomStyleLayerCompletionHandler)completion belowStyleLayerWithIdentifier:(nullable NSString *)otherIdentifier; - -- (void)removeCustomStyleLayerWithIdentifier:(NSString *)identifier; - -- (void)setCustomStyleLayersNeedDisplay; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h deleted file mode 100644 index dc03c13f7b..0000000000 --- a/include/mbgl/ios/MGLMapView.h +++ /dev/null @@ -1,1259 +0,0 @@ -#import "MGLGeometry.h" -#import "MGLMapCamera.h" - -#import <UIKit/UIKit.h> -#import <CoreLocation/CoreLocation.h> - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -@class MGLAnnotationImage; -@class MGLUserLocation; -@class MGLPolyline; -@class MGLPolygon; -@class MGLShape; - -@protocol MGLMapViewDelegate; -@protocol MGLAnnotation; -@protocol MGLOverlay; -@protocol MGLCalloutView; - -/** The vertical alignment of an annotation within a map view. */ -typedef NS_ENUM(NSUInteger, MGLAnnotationVerticalAlignment) { - /** Aligns the annotation vertically in the center of the map view. */ - MGLAnnotationVerticalAlignmentCenter = 0, - /** Aligns the annotation vertically at the top of the map view. */ - MGLAnnotationVerticalAlignmentTop, - /** Aligns the annotation vertically at the bottom of the map view. */ - MGLAnnotationVerticalAlignmentBottom, -}; - -/** Options for enabling debugging features in an MGLMapView instance. */ -typedef NS_OPTIONS(NSUInteger, MGLMapDebugMaskOptions) { - /** Edges of tile boundaries are shown as thick, red lines to help diagnose - tile clipping issues. */ - MGLMapDebugTileBoundariesMask = 1 << 1, - /** Each tile shows its tile coordinate (x/y/z) in the upper-left corner. */ - MGLMapDebugTileInfoMask = 1 << 2, - /** Each tile shows a timestamp indicating when it was loaded. */ - MGLMapDebugTimestampsMask = 1 << 3, - /** Edges of glyphs and symbols are shown as faint, green lines to help - diagnose collision and label placement issues. */ - MGLMapDebugCollisionBoxesMask = 1 << 4, -}; - -/** - An interactive, customizable map view with an interface similar to the one - provided by Apple's MapKit. - - Using `MGLMapView`, you can embed the map inside a view, allow users to - manipulate it with standard gestures, animate the map between different - viewpoints, and present information in the form of annotations and overlays. - - The map view loads scalable vector tiles that conform to the - [Mapbox Vector Tile Specification](https://github.com/mapbox/vector-tile-spec). - It styles them with a style that conforms to the - [Mapbox GL style specification](https://www.mapbox.com/mapbox-gl-style-spec/). - Such styles can be designed in [Mapbox Studio](https://www.mapbox.com/studio/) - and hosted on mapbox.com. - - A collection of Mapbox-hosted styles is available through the `MGLStyle` - class. These basic styles use - [Mapbox Streets](https://www.mapbox.com/developers/vector-tiles/mapbox-streets) - or [Mapbox Satellite](https://www.mapbox.com/satellite/) data sources, but - you can specify a custom style that makes use of your own data. - - Mapbox-hosted vector tiles and styles require an API access token, which you - can obtain from the - [Mapbox account page](https://www.mapbox.com/studio/account/tokens/). Access - tokens associate requests to Mapbox's vector tile and style APIs with your - Mapbox account. They also deter other developers from using your styles - without your permission. - - @note You are responsible for getting permission to use the map data and for - ensuring that your use adheres to the relevant terms of use. - */ -IB_DESIGNABLE -@interface MGLMapView : UIView - -#pragma mark Creating Instances - -/** - Initializes and returns a newly allocated map view with the specified frame - and the default style. - - @param frame The frame for the view, measured in points. - @return An initialized map view. - */ -- (instancetype)initWithFrame:(CGRect)frame; - -/** - Initializes and returns a newly allocated map view with the specified frame - and style URL. - - @param frame The frame for the view, measured in points. - @param styleURL URL of the map style to display. The URL may be a full HTTP - or HTTPS URL, a Mapbox URL indicating the style's map ID - (`mapbox://styles/{user}/{style}`), or a path to a local file relative - to the application's resource path. Specify `nil` for the default style. - @return An initialized map view. - */ -- (instancetype)initWithFrame:(CGRect)frame styleURL:(nullable NSURL *)styleURL; - -#pragma mark Accessing the Delegate - -/** - The receiver's delegate. - - A map view sends messages to its delegate to notify it of changes to its - contents or the viewpoint. The delegate also provides information about - annotations displayed on the map, such as the styles to apply to individual - annotations. - */ -@property(nonatomic, weak, nullable) IBOutlet id<MGLMapViewDelegate> delegate; - -#pragma mark Configuring the Map's Appearance - -/** - URLs of the styles bundled with the library. - - @deprecated Call the relevant class method of `MGLStyle` for the URL of a - particular default style. - */ -@property (nonatomic, readonly) NS_ARRAY_OF(NSURL *) *bundledStyleURLs __attribute__((deprecated("Call the relevant class method of MGLStyle for the URL of a particular default style."))); - -/** - URL of the style currently displayed in the receiver. - - The URL may be a full HTTP or HTTPS URL, a Mapbox URL indicating the style's - map ID (`mapbox://styles/{user}/{style}`), or a path to a local file - relative to the application's resource path. - - If you set this property to `nil`, the receiver will use the default style - and this property will automatically be set to that style's URL. - */ -@property (nonatomic, null_resettable) NSURL *styleURL; - -/** - A control indicating the map's direction and allowing the user to manipulate - the direction, positioned in the upper-right corner. - */ -@property (nonatomic, readonly) UIImageView *compassView; - -/** - The Mapbox logo, positioned in the lower-left corner. - - @note The Mapbox terms of service, which governs the use of Mapbox-hosted - vector tiles and styles, - [requires](https://www.mapbox.com/help/mapbox-logo/) most Mapbox - customers to display the Mapbox logo. If this applies to you, do not - hide this view or change its contents. - */ -@property (nonatomic, readonly) UIImageView *logoView; - -/** - A view showing legally required copyright notices and telemetry settings, - positioned at the bottom-right of the map view. - - @note The Mapbox terms of service, which governs the use of Mapbox-hosted - vector tiles and styles, - [requires](https://www.mapbox.com/help/attribution/) these copyright - notices to accompany any map that features Mapbox-designed styles, - OpenStreetMap data, or other Mapbox data such as satellite or terrain - data. If that applies to this map view, do not hide this view or remove - any notices from it. - - @note You are additionally - [required](https://www.mapbox.com/help/metrics-opt-out-for-users/) to - provide users with the option to disable anonymous usage and location - sharing (telemetry). If this view is hidden, you must implement this - setting elsewhere in your app or via `Settings.bundle`. See our - [website](https://www.mapbox.com/ios-sdk/#telemetry_opt_out) for - implementation help. - */ -@property (nonatomic, readonly) UIButton *attributionButton; - -/** - Currently active style classes, represented as an array of string identifiers. - */ -@property (nonatomic) NS_ARRAY_OF(NSString *) *styleClasses; - -/** - Returns a Boolean value indicating whether the style class with the given - identifier is currently active. - - @param styleClass The style class to query for. - @return Whether the style class is currently active. - */ -- (BOOL)hasStyleClass:(NSString *)styleClass; - -/** - Activates the style class with the given identifier. - - @param styleClass The style class to activate. - */ -- (void)addStyleClass:(NSString *)styleClass; - -/** - Deactivates the style class with the given identifier. - - @param styleClass The style class to deactivate. - */ -- (void)removeStyleClass:(NSString *)styleClass; - -#pragma mark Displaying the User's Location - -/** - A Boolean value indicating whether the map may display the user location. - - Setting this property to `YES` causes the map view to use the Core Location - framework to find the current location. As long as this property is `YES`, the - map view continues to track the user's location and update it periodically. - - This property does not indicate whether the user's position is actually visible - on the map, only whether the map view is allowed to display it. To determine - whether the user's position is visible, use the `userLocationVisible` property. - The default value of this property is `NO`. - - On iOS 8 and above, your app must specify a value for - `NSLocationWhenInUseUsageDescription` or `NSLocationAlwaysUsageDescription` in - its `Info.plist` to satisfy the requirements of the underlying Core Location - framework when enabling this property. - */ -@property (nonatomic, assign) BOOL showsUserLocation; - -/** - A Boolean value indicating whether the device's current location is visible in - the map view. - - Use `showsUserLocation` to control the visibility of the on-screen user - location annotation. - */ -@property (nonatomic, assign, readonly, getter=isUserLocationVisible) BOOL userLocationVisible; - -/** - Returns the annotation object indicating the user's current location. - */ -@property (nonatomic, readonly, nullable) MGLUserLocation *userLocation; - -/** - The mode used to track the user location. The default value is - `MGLUserTrackingModeNone`. - - Changing the value of this property updates the map view with an animated - transition. If you don’t want to animate the change, use the - `-setUserTrackingMode:animated:` method instead. - */ -@property (nonatomic, assign) MGLUserTrackingMode userTrackingMode; - -/** - Sets the mode used to track the user location, with an optional transition. - - @param mode The mode used to track the user location. - @param animated If `YES`, there is an animated transition from the current - viewport to a viewport that results from the change to `mode`. If `NO`, the - map view instantaneously changes to the new viewport. This parameter only - affects the initial transition; subsequent changes to the user location or - heading are always animated. - */ -- (void)setUserTrackingMode:(MGLUserTrackingMode)mode animated:(BOOL)animated; - -/** - The vertical alignment of the user location annotation within the receiver. The - default value is `MGLAnnotationVerticalAlignmentCenter`. - - Changing the value of this property updates the map view with an animated - transition. If you don’t want to animate the change, use the - `-setUserLocationVerticalAlignment:animated:` method instead. - */ -@property (nonatomic, assign) MGLAnnotationVerticalAlignment userLocationVerticalAlignment; - -/** - Sets the vertical alignment of the user location annotation within the - receiver, with an optional transition. - - @param alignment The vertical alignment of the user location annotation. - @param animated If `YES`, the user location annotation animates to its new - position within the map view. If `NO`, the user location annotation - instantaneously moves to its new position. - */ -- (void)setUserLocationVerticalAlignment:(MGLAnnotationVerticalAlignment)alignment animated:(BOOL)animated; - -/** - Whether the map view should display a heading calibration alert when necessary. - The default value is `YES`. - */ -@property (nonatomic, assign) BOOL displayHeadingCalibration; - -/** - The geographic coordinate that is the subject of observation as the user - location is being tracked. - - By default, this property is set to an invalid coordinate, indicating that - there is no target. In course tracking mode, the target forms one of two foci - in the viewport, the other being the user location annotation. Typically, this - property is set to a destination or waypoint in a real-time navigation scene. - As the user annotation moves toward the target, the map automatically zooms in - to fit both foci optimally within the viewport. - - This property has no effect if the `userTrackingMode` property is set to a - value other than `MGLUserTrackingModeFollowWithCourse`. - - Changing the value of this property updates the map view with an animated - transition. If you don’t want to animate the change, use the - `-setTargetCoordinate:animated:` method instead. - */ -@property (nonatomic, assign) CLLocationCoordinate2D targetCoordinate; - -/** - Sets the geographic coordinate that is the subject of observation as the user - location is being tracked, with an optional transition animation. - - By default, the target coordinate is set to an invalid coordinate, indicating - that there is no target. In course tracking mode, the target forms one of two - foci in the viewport, the other being the user location annotation. Typically, - the target is set to a destination or waypoint in a real-time navigation scene. - As the user annotation moves toward the target, the map automatically zooms in - to fit both foci optimally within the viewport. - - This method has no effect if the `userTrackingMode` property is set to a value - other than `MGLUserTrackingModeFollowWithCourse`. - - @param targetCoordinate The target coordinate to fit within the viewport. - @param animated If `YES`, the map animates to fit the target within the map - view. If `NO`, the map fits the target instantaneously. - */ -- (void)setTargetCoordinate:(CLLocationCoordinate2D)targetCoordinate animated:(BOOL)animated; - -#pragma mark Configuring How the User Interacts with the Map - -/** - A Boolean value that determines whether the user may zoom the map in and - out, changing the zoom level. - - When this property is set to `YES`, the default, the user may zoom the map - in and out by pinching two fingers or by double tapping, holding, and moving - the finger up and down. - - This property controls only user interactions with the map. If you set the - value of this property to `NO`, you may still change the map zoom - programmatically. - */ -@property(nonatomic, getter=isZoomEnabled) BOOL zoomEnabled; - -/** - A Boolean value that determines whether the user may scroll around the map, - changing the center coordinate. - - When this property is set to `YES`, the default, the user may scroll the map - by dragging or swiping with one finger. - - This property controls only user interactions with the map. If you set the - value of this property to `NO`, you may still change the map location - programmatically. - */ -@property(nonatomic, getter=isScrollEnabled) BOOL scrollEnabled; - -/** - A Boolean value that determines whether the user may rotate the map, - changing the direction. - - When this property is set to `YES`, the default, the user may rotate the map - by moving two fingers in a circular motion. - - This property controls only user interactions with the map. If you set the - value of this property to `NO`, you may still rotate the map - programmatically. - */ -@property(nonatomic, getter=isRotateEnabled) BOOL rotateEnabled; - -/** - A Boolean value that determines whether the user may change the pitch (tilt) of - the map. - - When this property is set to `YES`, the default, the user may tilt the map by - vertically dragging two fingers. - - This property controls only user interactions with the map. If you set the - value of this property to `NO`, you may still change the pitch of the map - programmatically. - - The default value of this property is `YES`. - */ -@property(nonatomic, getter=isPitchEnabled) BOOL pitchEnabled; - -#pragma mark Manipulating the Viewpoint - -/** - The geographic coordinate at the center of the map view. - - Changing the value of this property centers the map on the new coordinate - without changing the current zoom level. - - Changing the value of this property updates the map view immediately. If you - want to animate the change, use the `-setCenterCoordinate:animated:` method - instead. - */ -@property (nonatomic) CLLocationCoordinate2D centerCoordinate; - -/** - Changes the center coordinate of the map and optionally animates the change. - - Changing the center coordinate centers the map on the new coordinate without - changing the current zoom level. - - @param coordinate The new center coordinate for the map. - @param animated Specify `YES` if you want the map view to scroll to the new - location or `NO` if you want the map to display the new location - immediately. - */ -- (void)setCenterCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated; - -/** - Changes the center coordinate and zoom level of the map and optionally animates - the change. - - @param centerCoordinate The new center coordinate for the map. - @param zoomLevel The new zoom level for the map. - @param animated Specify `YES` if you want the map view to animate scrolling and - zooming to the new location or `NO` if you want the map to display the new - location immediately. - */ -- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel animated:(BOOL)animated; - -/** - Changes the center coordinate, zoom level, and direction of the map and - optionally animates the change. - - @param centerCoordinate The new center coordinate for the map. - @param zoomLevel The new zoom level for the map. - @param direction The new direction for the map, measured in degrees relative to - true north. - @param animated Specify `YES` if you want the map view to animate scrolling, - zooming, and rotating to the new location or `NO` if you want the map to - display the new location immediately. - */ -- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel direction:(CLLocationDirection)direction animated:(BOOL)animated; - -/** - Changes the center coordinate, zoom level, and direction of the map, calling a - completion handler at the end of an optional animation. - - @param centerCoordinate The new center coordinate for the map. - @param zoomLevel The new zoom level for the map. - @param direction The new direction for the map, measured in degrees relative to - true north. - @param animated Specify `YES` if you want the map view to animate scrolling, - zooming, and rotating to the new location or `NO` if you want the map to - display the new location immediately. - @param completion The block executed after the animation finishes. - */ -- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel direction:(CLLocationDirection)direction animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion; - -/** The zoom level of the receiver. - - In addition to affecting the visual size and detail of features on the map, - the zoom level affects the size of the vector tiles that are loaded. At zoom - level 0, each tile covers the entire world map; at zoom level 1, it covers ¼ - of the world; at zoom level 2, <sup>1</sup>⁄<sub>16</sub> of the world, and - so on. - - Changing the value of this property updates the map view immediately. If you - want to animate the change, use the `-setZoomLevel:animated:` method instead. - */ -@property (nonatomic) double zoomLevel; - -/** - Changes the zoom level of the map and optionally animates the change. - - Changing the zoom level scales the map without changing the current center - coordinate. - - @param zoomLevel The new zoom level for the map. - @param animated Specify `YES` if you want the map view to animate the change - to the new zoom level or `NO` if you want the map to display the new - zoom level immediately. - */ -- (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated; - -/** - * The minimum zoom level at which the map can be shown. - * - * Depending on the map view’s aspect ratio, the map view may be prevented - * from reaching the minimum zoom level, in order to keep the map from - * repeating within the current viewport. - * - * If the value of this property is greater than that of the - * maximumZoomLevel property, the behavior is undefined. - * - * The default minimumZoomLevel is 0. - */ -@property (nonatomic) double minimumZoomLevel; - -/** - * The maximum zoom level the map can be shown at. - * - * If the value of this property is smaller than that of the - * minimumZoomLevel property, the behavior is undefined. - * - * The default maximumZoomLevel is 20. - */ -@property (nonatomic) double maximumZoomLevel; - -/** - The heading of the map, measured in degrees clockwise from true north. - - The value `0` means that the top edge of the map view corresponds to true - north. The value `90` means the top of the map is pointing due east. The - value `180` means the top of the map points due south, and so on. - - Changing the value of this property updates the map view immediately. If you - want to animate the change, use the `-setDirection:animated:` method instead. - */ -@property (nonatomic) CLLocationDirection direction; - -/** - Changes the heading of the map and optionally animates the change. - - @param direction The heading of the map, measured in degrees clockwise from - true north. - @param animated Specify `YES` if you want the map view to animate the change - to the new heading or `NO` if you want the map to display the new - heading immediately. - - Changing the heading rotates the map without changing the current center - coordinate or zoom level. - */ -- (void)setDirection:(CLLocationDirection)direction animated:(BOOL)animated; - -/** - Resets the map rotation to a northern heading — a `direction` of `0` degrees. - */ -- (IBAction)resetNorth; - -/** - The coordinate bounds visible in the receiver's viewport. - - Changing the value of this property updates the receiver immediately. If you - want to animate the change, call `-setVisibleCoordinateBounds:animated:` - instead. - */ -@property (nonatomic) MGLCoordinateBounds visibleCoordinateBounds; - -/** - Changes the receiver’s viewport to fit the given coordinate bounds, - optionally animating the change. - - @param bounds The bounds that the viewport will show in its entirety. - @param animated Specify `YES` to animate the change by smoothly scrolling - and zooming or `NO` to immediately display the given bounds. - */ -- (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds animated:(BOOL)animated; - -/** - Changes the receiver's viewport to fit the given coordinate bounds and - optionally some additional padding on each side. - - @param bounds The bounds that the viewport will show in its entirety. - @param insets The minimum padding (in screen points) that will be visible - around the given coordinate bounds. - @param animated Specify `YES` to animate the change by smoothly scrolling and - zooming or `NO` to immediately display the given bounds. - */ -- (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated; - -/** - Changes the receiver's viewport to fit all of the given coordinates and - optionally some additional padding on each side. - - @param coordinates The coordinates that the viewport will show. - @param count The number of coordinates. This number must not be greater than - the number of elements in `coordinates`. - @param insets The minimum padding (in screen points) that will be visible - around the given coordinate bounds. - @param animated Specify `YES` to animate the change by smoothly scrolling and - zooming or `NO` to immediately display the given bounds. - */ -- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated; - -/** - Changes the receiver's viewport to fit all of the given coordinates and - optionally some additional padding on each side. - - @param coordinates The coordinates that the viewport will show. - @param count The number of coordinates. This number must not be greater than - the number of elements in `coordinates`. - @param insets The minimum padding (in screen points) that will be visible - around the given coordinate bounds. - @param direction The direction to rotate the map to, measured in degrees - relative to true north. - @param duration The duration to animate the change in seconds. - @param function The timing function to animate the change. - @param completion The block executed after the animation finishes. - */ -- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion; - -/** - Sets the visible region so that the map displays the specified annotations. - - Calling this method updates the value in the `visibleCoordinateBounds` property - and potentially other properties to reflect the new map region. A small amount - of padding is reserved around the edges of the map view. To specify a different - amount of padding, use the `-showAnnotations:edgePadding:animated:` method. - - @param annotations The annotations that you want to be visible in the map. - @param animated `YES` if you want the map region change to be animated, or `NO` - if you want the map to display the new region immediately without animations. - */ -- (void)showAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations animated:(BOOL)animated; - -/** - Sets the visible region so that the map displays the specified annotations with - the specified amount of padding on each side. - - Calling this method updates the value in the visibleCoordinateBounds property - and potentially other properties to reflect the new map region. - - @param annotations The annotations that you want to be visible in the map. - @param insets The minimum padding (in screen points) around the edges of the - map view to keep clear of annotations. - @param animated `YES` if you want the map region change to be animated, or `NO` - if you want the map to display the new region immediately without animations. - */ -- (void)showAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated; - -/** - A camera representing the current viewpoint of the map. - */ -@property (nonatomic, copy) MGLMapCamera *camera; - -/** - Moves the viewpoint to a different location with respect to the map with an - optional transition animation. - - @param camera The new viewpoint. - @param animated Specify `YES` if you want the map view to animate the change to - the new viewpoint or `NO` if you want the map to display the new viewpoint - immediately. - */ -- (void)setCamera:(MGLMapCamera *)camera animated:(BOOL)animated; - -/** - Moves the viewpoint to a different location with respect to the map with an - optional transition duration and timing function. - - @param camera The new viewpoint. - @param duration The amount of time, measured in seconds, that the transition - animation should take. Specify `0` to jump to the new viewpoint - instantaneously. - @param function A timing function used for the animation. Set this parameter to - `nil` for a transition that matches most system animations. If the duration - is `0`, this parameter is ignored. - */ -- (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function; - -/** - Moves the viewpoint to a different location with respect to the map with an - optional transition duration and timing function. - - @param camera The new viewpoint. - @param duration The amount of time, measured in seconds, that the transition - animation should take. Specify `0` to jump to the new viewpoint - instantaneously. - @param function A timing function used for the animation. Set this parameter to - `nil` for a transition that matches most system animations. If the duration - is `0`, this parameter is ignored. - @param completion The block to execute after the animation finishes. - */ -- (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion; - -/** - Moves the viewpoint to a different location using a transition animation that - evokes powered flight and a default duration based on the length of the flight - path. - - The transition animation seamlessly incorporates zooming and panning to help - the user find his or her bearings even after traversing a great distance. - - @param camera The new viewpoint. - @param completion The block to execute after the animation finishes. - */ -- (void)flyToCamera:(MGLMapCamera *)camera completionHandler:(nullable void (^)(void))completion; - -/** - Moves the viewpoint to a different location using a transition animation that - evokes powered flight and an optional transition duration. - - The transition animation seamlessly incorporates zooming and panning to help - the user find his or her bearings even after traversing a great distance. - - @param camera The new viewpoint. - @param duration The amount of time, measured in seconds, that the transition - animation should take. Specify `0` to jump to the new viewpoint - instantaneously. Specify a negative value to use the default duration, which - is based on the length of the flight path. - @param completion The block to execute after the animation finishes. - */ -- (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion; - -/** - Moves the viewpoint to a different location using a transition animation that - evokes powered flight and an optional transition duration and peak altitude. - - The transition animation seamlessly incorporates zooming and panning to help - the user find his or her bearings even after traversing a great distance. - - @param camera The new viewpoint. - @param duration The amount of time, measured in seconds, that the transition - animation should take. Specify `0` to jump to the new viewpoint - instantaneously. Specify a negative value to use the default duration, which - is based on the length of the flight path. - @param peakAltitude The altitude, measured in meters, at the midpoint of the - animation. The value of this parameter is ignored if it is negative or if - the animation transition resulting from a similar call to - `-setCamera:animated:` would have a midpoint at a higher altitude. - @param completion The block to execute after the animation finishes. - */ -- (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration peakAltitude:(CLLocationDistance)peakAltitude completionHandler:(nullable void (^)(void))completion; - -/** - The distance from the edges of the map view’s frame to the edges of the map - view’s logical viewport. - - When the value of this property is equal to `UIEdgeInsetsZero`, viewport - properties such as `centerCoordinate` assume a viewport that matches the map - view’s frame. Otherwise, those properties are inset, excluding part of the - frame from the viewport. For instance, if the only the top edge is inset, the - map center is effectively shifted downward. - - When the map view’s superview is an instance of `UIViewController` whose - `automaticallyAdjustsScrollViewInsets` property is `YES`, the value of this - property may be overridden at any time. - - Changing the value of this property updates the map view immediately. If you - want to animate the change, use the `-setContentInset:animated:` method - instead. - */ -@property (nonatomic, assign) UIEdgeInsets contentInset; - -/** - Sets the distance from the edges of the map view’s frame to the edges of the - map view’s logical viewport with an optional transition animation. - - When the value of this property is equal to `UIEdgeInsetsZero`, viewport - properties such as `centerCoordinate` assume a viewport that matches the map - view’s frame. Otherwise, those properties are inset, excluding part of the - frame from the viewport. For instance, if the only the top edge is inset, the - map center is effectively shifted downward. - - When the map view’s superview is an instance of `UIViewController` whose - `automaticallyAdjustsScrollViewInsets` property is `YES`, the value of this - property may be overridden at any time. - - @param contentInset The new values to inset the content by. - @param animated Specify `YES` if you want the map view to animate the change to - the content inset or `NO` if you want the map to inset the content - immediately. - */ -- (void)setContentInset:(UIEdgeInsets)contentInset animated:(BOOL)animated; - -#pragma mark Converting Geographic Coordinates - -/** - Converts a point in the given view's coordinate system to a geographic - coordinate. - - @param point The point to convert. - @param view The view in whose coordinate system the point is expressed. - @return The geographic coordinate at the given point. - */ -- (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(nullable UIView *)view; - -/** - Converts a geographic coordinate to a point in the given view's coordinate - system. - - @param coordinate The geographic coordinate to convert. - @param view The view in whose coordinate system the returned point should be - expressed. If this parameter is `nil`, the returned point is expressed - in the window's coordinate system. If `view` is not `nil`, it must - belong to the same window as the map view. - @return The point (in the appropriate view or window coordinate system) - corresponding to the given geographic coordinate. - */ -- (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(nullable UIView *)view; - -/** - Converts a rectangle in the given view’s coordinate system to a geographic - bounding box. - - @param rect The rectangle to convert. - @param view The view in whose coordinate system the rectangle is expressed. - @return The geographic bounding box coextensive with the given rectangle. - */ -- (MGLCoordinateBounds)convertRect:(CGRect)rect toCoordinateBoundsFromView:(nullable UIView *)view; - -/** - Converts a geographic bounding box to a rectangle in the given view’s - coordinate system. - - @param bounds The geographic bounding box to convert. - @param view The view in whose coordinate system the returned rectangle should - be expressed. If this parameter is `nil`, the returned rectangle is - expressed in the window’s coordinate system. If `view` is not `nil`, it must - belong to the same window as the map view. - */ -- (CGRect)convertCoordinateBounds:(MGLCoordinateBounds)bounds toRectToView:(nullable UIView *)view; - -/** - Returns the distance spanned by one point in the map view's coordinate system - at the given latitude and current zoom level. - - The distance between points decreases as the latitude approaches the poles. - This relationship parallels the relationship between longitudinal coordinates - at different latitudes. - - @param latitude The latitude of the geographic coordinate represented by the - point. - @return The distance in meters spanned by a single point. - */ -- (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude; - -- (CLLocationDistance)metersPerPixelAtLatitude:(CLLocationDegrees)latitude __attribute__((deprecated("Use -metersPerPointAtLatitude:."))); - -#pragma mark Annotating the Map - -/** - The complete list of annotations associated with the receiver. (read-only) - - The objects in this array must adopt the `MGLAnnotation` protocol. If no - annotations are associated with the map view, the value of this property is - `nil`. - */ -@property (nonatomic, readonly, nullable) NS_ARRAY_OF(id <MGLAnnotation>) *annotations; - -/** - Adds an annotation to the map view. - - @param annotation The annotation object to add to the receiver. This object - must conform to the `MGLAnnotation` protocol. The map view retains the - annotation object. */ -- (void)addAnnotation:(id <MGLAnnotation>)annotation; - -/** - Adds an array of annotations to the map view. - - @param annotations An array of annotation objects. Each object in the array - must conform to the `MGLAnnotation` protocol. The map view retains each - individual annotation object. - */ -- (void)addAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations; - -/** - Removes an annotation from the map view, deselecting it if it is selected. - - Removing an annotation object dissociates it from the map view entirely, - preventing it from being displayed on the map. Thus you would typically call - this method only when you want to hide or delete a given annotation. - - @param annotation The annotation object to remove. This object must conform - to the `MGLAnnotation` protocol - */ -- (void)removeAnnotation:(id <MGLAnnotation>)annotation; - -/** - Removes an array of annotations from the map view, deselecting any selected - annotations in the array. - - Removing annotation objects dissociates them from the map view entirely, - preventing them from being displayed on the map. Thus you would typically - call this method only when you want to hide or delete the given annotations. - - @param annotations The array of annotation objects to remove. Objects in the - array must conform to the `MGLAnnotation` protocol. - */ -- (void)removeAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations; - -/** - Returns a reusable annotation image object associated with its identifier. - - For performance reasons, you should generally reuse `MGLAnnotationImage` - objects for identical-looking annotations in your map views. Dequeueing - saves time and memory during performance-critical operations such as - scrolling. - - @param identifier A string identifying the annotation image to be reused. - This string is the same one you specify when initially returning the - annotation image object using the `-mapView:imageForAnnotation:` method. - @return An annotation image object with the given identifier, or `nil` if no - such object exists in the reuse queue. - */ -- (nullable MGLAnnotationImage *)dequeueReusableAnnotationImageWithIdentifier:(NSString *)identifier; - -#pragma mark Managing Annotation Selections - -/** - The currently selected annotations. - - Assigning a new array to this property selects only the first annotation in - the array. - */ -@property (nonatomic, copy) NS_ARRAY_OF(id <MGLAnnotation>) *selectedAnnotations; - -/** - Selects an annotation and displays a callout view for it. - - If the given annotation is not visible within the current viewport, this - method has no effect. - - @param annotation The annotation object to select. - @param animated If `YES`, the callout view is animated into position. - */ -- (void)selectAnnotation:(id <MGLAnnotation>)annotation animated:(BOOL)animated; - -/** - Deselects an annotation and hides its callout view. - - @param annotation The annotation object to deselect. - @param animated If `YES`, the callout view is animated offscreen. - */ -- (void)deselectAnnotation:(nullable id <MGLAnnotation>)annotation animated:(BOOL)animated; - -#pragma mark Overlaying the Map - -/** - Adds a single overlay object to the map. - - To remove an overlay from a map, use the `-removeOverlay:` method. - - @param overlay The overlay object to add. This object must conform to the - `MGLOverlay` protocol. */ -- (void)addOverlay:(id <MGLOverlay>)overlay; - -/** - Adds an array of overlay objects to the map. - - To remove multiple overlays from a map, use the `-removeOverlays:` method. - - @param overlays An array of objects, each of which must conform to the - `MGLOverlay` protocol. - */ -- (void)addOverlays:(NS_ARRAY_OF(id <MGLOverlay>) *)overlays; - -/** - Removes a single overlay object from the map. - - If the specified overlay is not currently associated with the map view, this - method does nothing. - - @param overlay The overlay object to remove. - */ -- (void)removeOverlay:(id <MGLOverlay>)overlay; - -/** - Removes one or more overlay objects from the map. - - If a given overlay object is not associated with the map view, it is ignored. - - @param overlays An array of objects, each of which conforms to the `MGLOverlay` - protocol. - */ -- (void)removeOverlays:(NS_ARRAY_OF(id <MGLOverlay>) *)overlays; - -#pragma mark Debugging the Map - -/** - The options that determine which debugging aids are shown on the map. - - These options are all disabled by default and should remain disabled in - released software for performance and aesthetic reasons. - */ -@property (nonatomic) MGLMapDebugMaskOptions debugMask; - -@property (nonatomic, getter=isDebugActive) BOOL debugActive __attribute__((deprecated("Use -debugMask and -setDebugMask:."))); - -- (void)toggleDebug __attribute__((deprecated("Use -setDebugMask:."))); - -/** - Empties the in-memory tile cache. - */ -- (void)emptyMemoryCache; - -/** - Resets the map to the minimum zoom level, a center coordinate of (0, 0), and - a northern heading. - */ -- (void)resetPosition; - -@end - -#pragma mark - MGLMapViewDelegate - -/** The MGLMapViewDelegate protocol defines a set of optional methods that you can use to receive map-related update messages. Because many map operations require the `MGLMapView` class to load data asynchronously, the map view calls these methods to notify your application when specific operations complete. The map view also uses these methods to request annotation marker symbology and to manage interactions with those markers. */ -@protocol MGLMapViewDelegate <NSObject> - -@optional - -#pragma mark Responding to Map Position Changes - -/** - Tells the delegate that the region displayed by the map view is about to change. - - This method is called whenever the currently displayed map region will start changing. - - @param mapView The map view whose visible region will change. - @param animated Whether the change will cause an animated effect on the map. - */ -- (void)mapView:(MGLMapView *)mapView regionWillChangeAnimated:(BOOL)animated; - -/** - Tells the delegate that the region displayed by the map view is changing. - - This method is called whenever the currently displayed map region changes. During movement, this method may be called many times to report updates to the map position. Therefore, your implementation of this method should be as lightweight as possible to avoid affecting performance. - - @param mapView The map view whose visible region is changing. - */ -- (void)mapViewRegionIsChanging:(MGLMapView *)mapView; - -/** - Tells the delegate that the region displayed by the map view just changed. - - This method is called whenever the currently displayed map region has finished changing. - - @param mapView The map view whose visible region changed. - @param animated Whether the change caused an animated effect on the map. - */ -- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated; - -#pragma mark Loading the Map - -/** - Tells the delegate that the map view will begin to load. - - This method is called whenever the map view starts loading, including when a new style has been set and the map must reload. - - @param mapView The map view that is starting to load. - */ -- (void)mapViewWillStartLoadingMap:(MGLMapView *)mapView; - -/** - Tells the delegate that the map view has finished loading. - - This method is called whenever the map view finishes loading, either after the initial load or after a style change has forced a reload. - - @param mapView The map view that has finished loading. - */ -- (void)mapViewDidFinishLoadingMap:(MGLMapView *)mapView; - -// TODO -- (void)mapViewDidFailLoadingMap:(MGLMapView *)mapView withError:(NSError *)error; - -// TODO -- (void)mapViewWillStartRenderingMap:(MGLMapView *)mapView; - -// TODO -- (void)mapViewDidFinishRenderingMap:(MGLMapView *)mapView fullyRendered:(BOOL)fullyRendered; - -// TODO -- (void)mapViewWillStartRenderingFrame:(MGLMapView *)mapView; - -// TODO -- (void)mapViewDidFinishRenderingFrame:(MGLMapView *)mapView fullyRendered:(BOOL)fullyRendered; - -#pragma mark Tracking User Location - -/** - Tells the delegate that the map view will begin tracking the user's location. - - This method is called when the value of the `showsUserLocation` property changes to `YES`. - - @param mapView The map view that is tracking the user's location. - */ -- (void)mapViewWillStartLocatingUser:(MGLMapView *)mapView; - -/** - Tells the delegate that the map view has stopped tracking the user's location. - - This method is called when the value of the `showsUserLocation` property changes to `NO`. - - @param mapView The map view that is tracking the user's location. - */ -- (void)mapViewDidStopLocatingUser:(MGLMapView *)mapView; - -/** - Tells the delegate that the location of the user was updated. - - While the `showsUserLocation` property is set to `YES`, this method is called whenever a new location update is received by the map view. This method is also called if the map view's user tracking mode is set to `MGLUserTrackingModeFollowWithHeading` and the heading changes, or if it is set to `MGLUserTrackingModeFollowWithCourse` and the course changes. - - This method is not called if the application is currently running in the background. If you want to receive location updates while running in the background, you must use the Core Location framework. - - @param mapView The map view that is tracking the user's location. - @param userLocation The location object representing the user's latest location. This property may be `nil`. - */ -- (void)mapView:(MGLMapView *)mapView didUpdateUserLocation:(nullable MGLUserLocation *)userLocation; - -/** - Tells the delegate that an attempt to locate the user's position failed. - - @param mapView The map view that is tracking the user's location. - @param error An error object containing the reason why location tracking failed. - */ -- (void)mapView:(MGLMapView *)mapView didFailToLocateUserWithError:(NSError *)error; - -/** - Tells the delegate that the map view's user tracking mode has changed. - - This method is called after the map view asynchronously changes to reflect the new user tracking mode, for example by beginning to zoom or rotate. - - @param mapView The map view that changed its tracking mode. - @param mode The new tracking mode. - @param animated Whether the change caused an animated effect on the map. - */ -- (void)mapView:(MGLMapView *)mapView didChangeUserTrackingMode:(MGLUserTrackingMode)mode animated:(BOOL)animated; - -#pragma mark Managing the Display of Annotations - -/** - Returns an image object to use for the marker for the specified point annotation object. - - @param mapView The map view that requested the annotation image. - @param annotation The object representing the annotation that is about to be displayed. - @return The image object to display for the specified annotation or `nil` if you want to display the default marker image. - */ -- (nullable MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id <MGLAnnotation>)annotation; - -/** - Returns the alpha value to use when rendering a shape annotation. Defaults to `1.0`. - - @param mapView The map view rendering the shape annotation. - @param annotation The annotation being rendered. - @return An alpha value between `0` and `1.0`. - */ -- (CGFloat)mapView:(MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation; - -/** - Returns the stroke color to use when rendering a shape annotation. Defaults to black. - - @param mapView The map view rendering the shape annotation. - @param annotation The annotation being rendered. - @return A color to use for the shape outline. - */ -- (UIColor *)mapView:(MGLMapView *)mapView strokeColorForShapeAnnotation:(MGLShape *)annotation; - -/** - Returns the fill color to use when rendering a polygon annotation. Defaults to blue. - - @param mapView The map view rendering the polygon annotation. - @param annotation The annotation being rendered. - @return A color to use for the polygon interior. - */ -- (UIColor *)mapView:(MGLMapView *)mapView fillColorForPolygonAnnotation:(MGLPolygon *)annotation; - -/** - Returns the line width to use when rendering a polyline annotation. Defaults to `3.0`. - - @param mapView The map view rendering the polygon annotation. - @param annotation The annotation being rendered. - @return A line width for the polyline. - */ -- (CGFloat)mapView:(MGLMapView *)mapView lineWidthForPolylineAnnotation:(MGLPolyline *)annotation; - -/** - Returns a Boolean value indicating whether the annotation is able to display extra information in a callout bubble. - - If the value returned is `YES`, a standard callout bubble is shown when the user taps a selected annotation. The callout uses the title and subtitle text from the associated annotation object. If there is no title text, though, the annotation will not show a callout. The callout also displays any custom callout views returned by the delegate for the left and right callout accessory views. - - If the value returned is `NO`, the value of the title and subtitle strings are ignored. - - @param mapView The map view that requested the annotation callout ability. - @param annotation The object representing the annotation. - @return A Boolean indicating whether the annotation should show a callout. - */ -- (BOOL)mapView:(MGLMapView *)mapView annotationCanShowCallout:(id <MGLAnnotation>)annotation; - -/** - Returns a callout view to display for the specified annotation. - - If this method is present in the delegate, it must return a new instance of a view dedicated to display the callout bubble. It will be configured by the map view. If this method is not present, or if it returns `nil`, a standard, two-line, bubble-like callout view is displayed by default. - - @param mapView The map view that requested the callout view. - @param annotation The object representing the annotation. - @return A view conforming to the `MGLCalloutView` protocol, or `nil` to use the default callout view. - */ -- (nullable UIView <MGLCalloutView> *)mapView:(MGLMapView *)mapView calloutViewForAnnotation:(id <MGLAnnotation>)annotation; - -/** - Returns the view to display on the left side of the standard callout bubble. - - The default value is treated as if `nil`. The left callout view is typically used to display information about the annotation or to link to custom information provided by your application. - - If the view you specify is also a descendant of the `UIControl` class, you can use the map view's delegate to receive notifications when your control is tapped. If it does not descend from `UIControl`, your view is responsible for handling any touch events within its bounds. - - @param mapView The map view presenting the annotation callout. - @param annotation The object representing the annotation with the callout. - @return The accessory view to display. - */ -- (nullable UIView *)mapView:(MGLMapView *)mapView leftCalloutAccessoryViewForAnnotation:(id <MGLAnnotation>)annotation; - -/** - Returns the view to display on the right side of the standard callout bubble. - - The default value is treated is if `nil`. The right callout view is typically used to link to more detailed information about the annotation. A common view to specify for this property is `UIButton` object whose type is set to `UIButtonTypeDetailDisclosure`. - - If the view you specify is also a descendant of the `UIControl` class, you can use the map view's delegate to receive notifications when your control is tapped. If it does not descend from `UIControl`, your view is responsible for handling any touch events within its bounds. - - @param mapView The map view presenting the annotation callout. - @param annotation The object representing the annotation with the callout. - @return The accessory view to display. - */ -- (nullable UIView *)mapView:(MGLMapView *)mapView rightCalloutAccessoryViewForAnnotation:(id <MGLAnnotation>)annotation; - -#pragma mark Managing Annotations - -/** - Tells the delegate that the user tapped one of the annotation's accessory buttons. - - Accessory views contain custom content and are positioned on either side of the annotation title text. If a view you specify is a descendant of the `UIControl` class, the map view calls this method as a convenience whenever the user taps your view. You can use this method to respond to taps and perform any actions associated with that control. For example, if your control displayed additional information about the annotation, you could use this method to present a modal panel with that information. - - If your custom accessory views are not descendants of the `UIControl` class, the map view does not call this method. - - @param mapView The map view containing the specified annotation. - @param annotation The annotation whose button was tapped. - @param control The control that was tapped. - */ -- (void)mapView:(MGLMapView *)mapView annotation:(id <MGLAnnotation>)annotation calloutAccessoryControlTapped:(UIControl *)control; - -/** - Tells the delegate that the user tapped on an annotation's callout view. - - @param mapView The map view containing the specified annotation. - @param annotation The annotation whose callout was tapped. - */ -- (void)mapView:(MGLMapView *)mapView tapOnCalloutForAnnotation:(id <MGLAnnotation>)annotation; - -#pragma mark Selecting Annotations - -/** - Tells the delegate that one of its annotations was selected. - - You can use this method to track changes in the selection state of annotations. - - @param mapView The map view containing the annotation. - @param annotation The annotation that was selected. - */ -- (void)mapView:(MGLMapView *)mapView didSelectAnnotation:(id <MGLAnnotation>)annotation; - -/** - Tells the delegate that one of its annotations was deselected. - - You can use this method to track changes in the selection state of annotations. - - @param mapView The map view containing the annotation. - @param annotation The annotation that was deselected. - */ -- (void)mapView:(MGLMapView *)mapView didDeselectAnnotation:(id <MGLAnnotation>)annotation; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/ios/MGLUserLocation.h b/include/mbgl/ios/MGLUserLocation.h deleted file mode 100644 index 6160413510..0000000000 --- a/include/mbgl/ios/MGLUserLocation.h +++ /dev/null @@ -1,42 +0,0 @@ -#import <Foundation/Foundation.h> -#import <CoreLocation/CoreLocation.h> - -#import "MGLAnnotation.h" - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** The MGLUserLocation class defines a specific type of annotation that identifies the user’s current location. You do not create instances of this class directly. Instead, you retrieve an existing MGLUserLocation object from the userLocation property of the map view displayed in your application. */ -@interface MGLUserLocation : NSObject <MGLAnnotation> - -#pragma mark Determining the User’s Position - -/** - The current location of the device. (read-only) - - This property contains `nil` if the map view is not currently showing the user location or if the user’s location has not yet been determined. - */ -@property (nonatomic, readonly, nullable) CLLocation *location; - -/** A Boolean value indicating whether the user’s location is currently being updated. (read-only) */ -@property (nonatomic, readonly, getter=isUpdating) BOOL updating; - -/** - The heading of the user location. (read-only) - - This property is `nil` if the user location tracking mode is not `MGLUserTrackingModeFollowWithHeading`. - */ -@property (nonatomic, readonly, nullable) CLHeading *heading; - -#pragma mark Accessing the User Annotation Text - -/** The title to display for the user location annotation. */ -@property (nonatomic, copy) NSString *title; - -/** The subtitle to display for the user location annotation. */ -@property (nonatomic, copy, nullable) NSString *subtitle; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/ios/Mapbox.h b/include/mbgl/ios/Mapbox.h deleted file mode 100644 index fd4f532a40..0000000000 --- a/include/mbgl/ios/Mapbox.h +++ /dev/null @@ -1,18 +0,0 @@ -#import "MGLAccountManager.h" -#import "MGLAnnotation.h" -#import "MGLAnnotationImage.h" -#import "MGLCalloutView.h" -#import "MGLGeometry.h" -#import "MGLMapCamera.h" -#import "MGLMapView.h" -#import "MGLMapView+IBAdditions.h" -#import "MGLMapView+MGLCustomStyleLayerAdditions.h" -#import "MGLMultiPoint.h" -#import "MGLOverlay.h" -#import "MGLPointAnnotation.h" -#import "MGLPolygon.h" -#import "MGLPolyline.h" -#import "MGLShape.h" -#import "MGLStyle.h" -#import "MGLTypes.h" -#import "MGLUserLocation.h" diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 1afe7e86f6..688565fecb 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -165,6 +165,8 @@ public: AnnotationID addShapeAnnotation(const ShapeAnnotation&); AnnotationIDs addShapeAnnotations(const std::vector<ShapeAnnotation>&); + void updatePointAnnotation(AnnotationID, const PointAnnotation&); + void removeAnnotation(AnnotationID); void removeAnnotations(const AnnotationIDs&); diff --git a/include/mbgl/osx/MGLAccountManager.h b/include/mbgl/osx/MGLAccountManager.h deleted file mode 100644 index efcec5419c..0000000000 --- a/include/mbgl/osx/MGLAccountManager.h +++ /dev/null @@ -1,44 +0,0 @@ -#import <Foundation/Foundation.h> - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** The MGLAccountManager object provides a global way to set a Mapbox API - access token, as well as other settings used framework-wide. */ -@interface MGLAccountManager : NSObject - -#pragma mark Authorizing access -/** @name Authorizing Access */ - -/** Set the - [Mapbox access token](https://www.mapbox.com/help/define-access-token/) to - used by all instances of MGLMapView in the current application. - - Mapbox-hosted vector tiles and styles require an API access token, which you - can obtain from the - [Mapbox account page](https://www.mapbox.com/studio/account/tokens/). Access - tokens associate requests to Mapbox’s vector tile and style APIs with your - Mapbox account. They also deter other developers from using your styles - without your permission. - - @param accessToken A Mapbox access token. Calling this method with a value - of `nil` has no effect. - - @note You must set the access token before attempting to load any - Mapbox-hosted style. Therefore, you should generally set it before - creating an instance of MGLMapView. The recommended way to set an access - token is to add an entry to your application’s Info.plist file with the - key `MGLMapboxAccessToken` and the type String. Alternatively, you may - call this method from your application delegate’s - -applicationDidFinishLaunching: method. */ -+ (void)setAccessToken:(nullable NSString *)accessToken; - -/** Returns the - [Mapbox access token](https://www.mapbox.com/help/define-access-token/) in - use by instances of MGLMapView in the current application. */ -+ (nullable NSString *)accessToken; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/osx/MGLAnnotationImage.h b/include/mbgl/osx/MGLAnnotationImage.h deleted file mode 100644 index a33ea75a5e..0000000000 --- a/include/mbgl/osx/MGLAnnotationImage.h +++ /dev/null @@ -1,58 +0,0 @@ -#import <AppKit/AppKit.h> - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -/** The MGLAnnotationImage class is responsible for presenting point-based - annotations visually on an MGLMapView instance. Annotation image objects - pair NSImage objects with annotation-related metadata. They may be recycled - later and put into a reuse queue that is maintained by the map view. */ -@interface MGLAnnotationImage : NSObject - -#pragma mark Initializing and preparing the image object -/** @name Initializing and Preparing the Image Object */ - -/** Initializes and returns a new annotation image object. - - @param image The image to display for the annotation. - @param reuseIdentifier The string that identifies this annotation image in - the reuse queue. - @return The initialized annotation image object or `nil` if there was a - problem initializing the object. */ -+ (instancetype)annotationImageWithImage:(NSImage *)image reuseIdentifier:(NSString *)reuseIdentifier; - -#pragma mark Getting and setting attributes -/** @name Getting and Setting Attributes */ - -/** The image to display for the annotation. */ -@property (nonatomic, readonly) NSImage *image; - -/** The string that identifies this annotation image in the reuse queue. - (read-only) - - You specify the reuse identifier when you create the image object. You use - this type later to retrieve an annotation image object that was created - previously but which is currently unused because its annotation is not - on-screen. - - If you define distinctly different types of annotations (with distinctly - different annotation images to go with them), you can differentiate between - the annotation types by specifying different reuse identifiers for each one. - */ -@property (nonatomic, readonly) NSString *reuseIdentifier; - -/** A Boolean value indicating whether the annotation is selectable. - - The default value of this property is `YES`. If the value of this property - is `NO`, the annotation image ignores click events and cannot be selected. - */ -@property (nonatomic, getter=isSelectable) BOOL selectable; - -/** The cursor that appears above any annotation using this annotation image. By - default, this property is set to `nil`, representing the current cursor. */ -@property (nonatomic, nullable) NSCursor *cursor; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/osx/MGLMapView+IBAdditions.h b/include/mbgl/osx/MGLMapView+IBAdditions.h deleted file mode 100644 index 81f4506a57..0000000000 --- a/include/mbgl/osx/MGLMapView+IBAdditions.h +++ /dev/null @@ -1,68 +0,0 @@ -#import <Foundation/Foundation.h> - -#import "MGLMapView.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface MGLMapView (IBAdditions) - -#if TARGET_INTERFACE_BUILDER - -// Core properties that can be manipulated in the Attributes inspector in -// Interface Builder. These redeclarations merely add the IBInspectable keyword. -// They appear here to ensure that they appear above the convenience properties; -// inspectables declared in MGLMapView.h are always sorted before those in -// MGLMapView+IBAdditions.h, due to ASCII sort order. - -// We want this property to look like a URL bar in the Attributes inspector, but -// just calling it styleURL would violate Cocoa naming conventions and conflict -// with the existing NSURL property. Fortunately, IB strips out the two -// underscores for display. - -/** URL of the style currently displayed in the receiver. - - The URL may be a full HTTP or HTTPS URL, a Mapbox URL indicating the style’s - map ID (`mapbox://styles/<user>/<style>`), or a path to a local file - relative to the application’s resource path. Leave this field blank for the - default style. */ -@property (nonatomic, nullable) IBInspectable NSString *styleURL__; - -// Convenience properties related to the initial viewport. These properties -// are not meant to be used outside of Interface Builder. latitude and longitude -// are backed by properties of type CLLocationDegrees, but these declarations -// must use the type double because Interface Builder is unaware that -// CLLocationDegrees is a typedef for double. - -/** The initial center latitude. */ -@property (nonatomic) IBInspectable double latitude; - -/** The initial center longitude. */ -@property (nonatomic) IBInspectable double longitude; - -@property (nonatomic) IBInspectable double zoomLevel; - -// Renamed properties. Interface Builder derives the display name of each -// inspectable from the runtime name, but runtime names don’t always make sense -// in UI. - -/** A Boolean value that determines whether the user may zoom the map, changing - its zoom level. */ -@property (nonatomic) IBInspectable BOOL allowsZooming; - -/** A Boolean value that determines whether the user may scroll around the map, - changing its center coordinate. */ -@property (nonatomic) IBInspectable BOOL allowsScrolling; - -/** A Boolean value that determines whether the user may rotate the map, - changing its direction. */ -@property (nonatomic) IBInspectable BOOL allowsRotating; - -/** A Boolean value that determines whether the user may tilt the map, changing - its pitch. */ -@property (nonatomic) IBInspectable BOOL allowsTilting; - -#endif - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/osx/MGLMapView.h b/include/mbgl/osx/MGLMapView.h deleted file mode 100644 index ca55ba7cd5..0000000000 --- a/include/mbgl/osx/MGLMapView.h +++ /dev/null @@ -1,639 +0,0 @@ -#import <Cocoa/Cocoa.h> -#import <CoreLocation/CoreLocation.h> - -#import "MGLGeometry.h" - -NS_ASSUME_NONNULL_BEGIN - -/** Options for enabling debugging features in an MGLMapView instance. */ -typedef NS_OPTIONS(NSUInteger, MGLMapDebugMaskOptions) { - /** Edges of tile boundaries are shown as thick, red lines to help diagnose - tile clipping issues. */ - MGLMapDebugTileBoundariesMask = 1 << 1, - - /** Each tile shows its tile coordinate (x/y/z) in the upper-left corner. */ - MGLMapDebugTileInfoMask = 1 << 2, - - /** Each tile shows a timestamp indicating when it was loaded. */ - MGLMapDebugTimestampsMask = 1 << 3, - - /** Edges of glyphs and symbols are shown as faint, green lines to help - diagnose collision and label placement issues. */ - MGLMapDebugCollisionBoxesMask = 1 << 4, -}; - -@class MGLAnnotationImage; -@class MGLMapCamera; - -@protocol MGLAnnotation; -@protocol MGLMapViewDelegate; -@protocol MGLOverlay; - -/** An interactive, customizable map view with an interface similar to the one - provided by Apple’s MapKit. - - Using MGLMapView, you can embed the map inside a view, allow users to - manipulate it with standard gestures, animate the map between different - viewpoints, and present information in the form of annotations and overlays. - - The map view loads scalable vector tiles that conform to the - [Mapbox Vector Tile Specification](https://github.com/mapbox/vector-tile-spec). - It styles them with a style that conforms to the - [Mapbox GL style specification](https://www.mapbox.com/mapbox-gl-style-spec/). - Such styles can be designed in [Mapbox Studio](https://www.mapbox.com/studio/) - and hosted on mapbox.com. - - A collection of Mapbox-hosted styles is available through the MGLStyle - class. These basic styles use - [Mapbox Streets](https://www.mapbox.com/developers/vector-tiles/mapbox-streets) - or [Mapbox Satellite](https://www.mapbox.com/satellite/) data sources, but - you can specify a custom style that makes use of your own data. - - Mapbox-hosted vector tiles and styles require an API access token, which you - can obtain from the - [Mapbox account page](https://www.mapbox.com/studio/account/tokens/). Access - tokens associate requests to Mapbox’s vector tile and style APIs with your - Mapbox account. They also deter other developers from using your styles - without your permission. - - @note You are responsible for getting permission to use the map data and for - ensuring that your use adheres to the relevant terms of use. */ -IB_DESIGNABLE -@interface MGLMapView : NSView - -#pragma mark Creating instances -/** @name Creating Instances */ - -/** Initializes and returns a newly allocated map view with the specified frame - and the default style. - - @param frame The frame for the view, measured in points. - @return An initialized map view. */ -- (instancetype)initWithFrame:(NSRect)frame; - -/** Initializes and returns a newly allocated map view with the specified frame - and style URL. - - @param frame The frame for the view, measured in points. - @param styleURL URL of the map style to display. The URL may be a full HTTP - or HTTPS URL, a Mapbox URL indicating the style’s map ID - (`mapbox://styles/<user>/<style>`), or a path to a local file relative - to the application’s resource path. Specify `nil` for the default style. - @return An initialized map view. */ -- (instancetype)initWithFrame:(NSRect)frame styleURL:(nullable NSURL *)styleURL; - -#pragma mark Accessing the delegate -/** @name Accessing the Delegate */ - -/** The receiver’s delegate. - - A map view sends messages to its delegate to notify it of changes to its - contents or the viewpoint. The delegate also provides information about - annotations displayed on the map, such as the styles to apply to individual - annotations. */ -@property (nonatomic, weak, nullable) IBOutlet id <MGLMapViewDelegate> delegate; - -#pragma mark Configuring the map’s appearance -/** @name Configuring the Map’s Appearance */ - - -/** URL of the style currently displayed in the receiver. - - The URL may be a full HTTP or HTTPS URL, a Mapbox URL indicating the style’s - map ID (`mapbox://styles/<user>/<style>`), or a path to a local file - relative to the application’s resource path. - - If you set this property to `nil`, the receiver will use the default style - and this property will automatically be set to that style’s URL. */ -@property (nonatomic, null_resettable) NSURL *styleURL; - -/** Reloads the style. - - You do not normally need to call this method. The map view automatically - responds to changes in network connectivity by reloading the style. You may - need to call this method if you change the access token after a style has - loaded but before loading a style associated with a different Mapbox - account. */ -- (IBAction)reloadStyle:(id)sender; - -/** A control for zooming in and out, positioned in the lower-right corner. */ -@property (nonatomic, readonly) NSSegmentedControl *zoomControls; - -/** A control indicating the map’s direction and allowing the user to manipulate - the direction, positioned above the zoom controls in the lower-right corner. - */ -@property (nonatomic, readonly) NSSlider *compass; - -/** The Mapbox logo, positioned in the lower-left corner. - - @note The Mapbox terms of service, which governs the use of Mapbox-hosted - vector tiles and styles, - [requires](https://www.mapbox.com/help/mapbox-logo/) most Mapbox - customers to display the Mapbox logo. If this applies to you, do not - hide this view or change its contents. */ -@property (nonatomic, readonly) NSImageView *logoView; - -/** A view showing legally required copyright notices, positioned along the - bottom of the map view, to the left of the Mapbox logo. - - @note The Mapbox terms of service, which governs the use of Mapbox-hosted - vector tiles and styles, - [requires](https://www.mapbox.com/help/attribution/) these copyright - notices to accompany any map that features Mapbox-designed styles, - OpenStreetMap data, or other Mapbox data such as satellite or terrain - data. If that applies to this map view, do not hide this view or remove - any notices from it. */ -@property (nonatomic, readonly) NSView *attributionView; - -#pragma mark Manipulating the viewpoint -/** @name Manipulating the Viewpoint */ - -/** The geographic coordinate at the center of the map view. - - Changing the value of this property centers the map on the new coordinate - without changing the current zoom level. - - Changing the value of this property updates the map view immediately. If you - want to animate the change, use the -setCenterCoordinate:animated: method - instead. */ -@property (nonatomic) CLLocationCoordinate2D centerCoordinate; - -/** Changes the center coordinate of the map and optionally animates the change. - - Changing the center coordinate centers the map on the new coordinate without - changing the current zoom level. - - @param coordinate The new center coordinate for the map. - @param animated Specify `YES` if you want the map view to scroll to the new - location or `NO` if you want the map to display the new location - immediately. */ -- (void)setCenterCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated; - -/** The zoom level of the receiver. - - In addition to affecting the visual size and detail of features on the map, - the zoom level affects the size of the vector tiles that are loaded. At zoom - level 0, each tile covers the entire world map; at zoom level 1, it covers ¼ - of the world; at zoom level 2, <sup>1</sup>⁄<sub>16</sub> of the world, and - so on. - - Changing the value of this property updates the map view immediately. If you - want to animate the change, use the -setZoomLevel:animated: method instead. - */ -@property (nonatomic) double zoomLevel; - -/** - * The minimum zoom level at which the map can be shown. - * - * Depending on the map view’s aspect ratio, the map view may be prevented - * from reaching the minimum zoom level, in order to keep the map from - * repeating within the current viewport. - * - * If the value of this property is greater than that of the - * maximumZoomLevel property, the behavior is undefined. - * - * The default minimumZoomLevel is 0. - */ -@property (nonatomic) double minimumZoomLevel; - -/** - * The maximum zoom level the map can be shown at. - * - * If the value of this property is smaller than that of the - * minimumZoomLevel property, the behavior is undefined. - * - * The default maximumZoomLevel is 20. - */ -@property (nonatomic) double maximumZoomLevel; - -/** Changes the zoom level of the map and optionally animates the change. - - Changing the zoom level scales the map without changing the current center - coordinate. - - @param zoomLevel The new zoom level for the map. - @param animated Specify `YES` if you want the map view to animate the change - to the new zoom level or `NO` if you want the map to display the new - zoom level immediately. */ -- (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated; - -/** The heading of the map, measured in degrees clockwise from true north. - - The value `0` means that the top edge of the map view corresponds to true - north. The value `90` means the top of the map is pointing due east. The - value `180` means the top of the map points due south, and so on. - - Changing the value of this property updates the map view immediately. If you - want to animate the change, use the -setDirection:animated: method instead. - */ -@property (nonatomic) CLLocationDirection direction; - -/** Changes the heading of the map and optionally animates the change. - - @param direction The heading of the map, measured in degrees clockwise from - true north. - @param animated Specify `YES` if you want the map view to animate the change - to the new heading or `NO` if you want the map to display the new - heading immediately. - - Changing the heading rotates the map without changing the current center - coordinate or zoom level. */ -- (void)setDirection:(CLLocationDirection)direction animated:(BOOL)animated; - -/** A camera representing the current viewpoint of the map. */ -@property (nonatomic, copy) MGLMapCamera *camera; - -/** Moves the viewpoint to a different location with respect to the map with an - optional transition animation. - - @param camera The new viewpoint. - @param animated Specify `YES` if you want the map view to animate the change - to the new viewpoint or `NO` if you want the map to display the new - viewpoint immediately. */ -- (void)setCamera:(MGLMapCamera *)camera animated:(BOOL)animated; - -/** Moves the viewpoint to a different location with respect to the map with an - optional transition duration and timing function. - - @param camera The new viewpoint. - @param duration The amount of time, measured in seconds, that the transition - animation should take. Specify `0` to jump to the new viewpoint - instantaneously. - @param function A timing function used for the animation. Set this parameter - to `nil` for a transition that matches most system animations. If the - duration is `0`, this parameter is ignored. - @param completion The block to execute after the animation finishes. */ -- (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion; - -/** Moves the viewpoint to a different location using a transition animation - that evokes powered flight and a default duration based on the length of the - flight path. - - The transition animation seamlessly incorporates zooming and panning to help - the user find his or her bearings even after traversing a great distance. - - @param camera The new viewpoint. - @param completion The block to execute after the animation finishes. */ -- (void)flyToCamera:(MGLMapCamera *)camera completionHandler:(nullable void (^)(void))completion; - -/** Moves the viewpoint to a different location using a transition animation - that evokes powered flight and an optional transition duration. - - The transition animation seamlessly incorporates zooming and panning to help - the user find his or her bearings even after traversing a great distance. - - @param camera The new viewpoint. - @param duration The amount of time, measured in seconds, that the transition - animation should take. Specify `0` to jump to the new viewpoint - instantaneously. Specify a negative value to use the default duration, - which is based on the length of the flight path. - @param completion The block to execute after the animation finishes. */ -- (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion; - -/** Moves the viewpoint to a different location using a transition animation - that evokes powered flight and an optional transition duration and peak - altitude. - - The transition animation seamlessly incorporates zooming and panning to help - the user find his or her bearings even after traversing a great distance. - - @param camera The new viewpoint. - @param duration The amount of time, measured in seconds, that the transition - animation should take. Specify `0` to jump to the new viewpoint - instantaneously. Specify a negative value to use the default duration, - which is based on the length of the flight path. - @param peakAltitude The altitude, measured in meters, at the midpoint of the - animation. The value of this parameter is ignored if it is negative or - if the animation transition resulting from a similar call to - `-setCamera:animated:` would have a midpoint at a higher altitude. - @param completion The block to execute after the animation finishes. */ -- (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration peakAltitude:(CLLocationDistance)peakAltitude completionHandler:(nullable void (^)(void))completion; - -/** The geographic coordinate bounds visible in the receiver’s viewport. - - Changing the value of this property updates the receiver immediately. If you - want to animate the change, use the -setVisibleCoordinateBounds:animated: - method instead. */ -@property (nonatomic) MGLCoordinateBounds visibleCoordinateBounds; - -/** Changes the receiver’s viewport to fit the given coordinate bounds, - optionally animating the change. - - @param bounds The bounds that the viewport will show in its entirety. - @param animated Specify `YES` to animate the change by smoothly scrolling - and zooming or `NO` to immediately display the given bounds. */ -- (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds animated:(BOOL)animated; - -/** A Boolean value indicating whether the receiver automatically adjusts its - content insets. - - When the value of this property is `YES`, the map view automatically updates - its `contentInsets` property to account for any overlapping title bar or - toolbar. To overlap with the title bar or toolbar, the containing window’s - style mask must have `NSFullSizeContentViewWindowMask` set, and the title - bar must not be transparent. - - The default value of this property is `YES`. */ -@property (nonatomic, assign) BOOL automaticallyAdjustsContentInsets; - -/** The distance from the edges of the map view’s frame to the edges of the map - view’s logical viewport. - - When the value of this property is equal to `NSEdgeInsetsZero`, viewport - properties such as `centerCoordinate` assume a viewport that matches the map - view’s frame. Otherwise, those properties are inset, excluding part of the - frame from the viewport. For instance, if the only the top edge is inset, - the map center is effectively shifted downward. - - When the value of the `automaticallyAdjustsContentInsets` property is `YES`, - the value of this property may be overridden at any time. - - Changing the value of this property updates the map view immediately. If you - want to animate the change, use the `-setContentInsets:animated:` method - instead. */ -@property (nonatomic, assign) NSEdgeInsets contentInsets; - -/** Sets the distance from the edges of the map view’s frame to the edges of the - map view’s logical viewport, with an optional transition animation. - - When the value of this property is equal to `NSEdgeInsetsZero`, viewport - properties such as `centerCoordinate` assume a viewport that matches the map - view’s frame. Otherwise, those properties are inset, excluding part of the - frame from the viewport. For instance, if the only the top edge is inset, - the map center is effectively shifted downward. - - When the value of the `automaticallyAdjustsContentInsets` property is `YES`, - the value of this property may be overridden at any time. - - @param contentInsets The new values to inset the content by. - @param animated Specify `YES` if you want the map view to animate the change - to the content insets or `NO` if you want the map to inset the content - immediately. */ -- (void)setContentInsets:(NSEdgeInsets)contentInsets animated:(BOOL)animated; - -#pragma mark Configuring gesture recognition -/** @name Configuring How the User Interacts with the Map */ - -/** A Boolean value that determines whether the user may zoom the map in and - out, changing the zoom level. - - When this property is set to `YES`, the default, the user may zoom the map - in and out by pinching two fingers, by using a scroll wheel on a - traditional mouse, or by dragging the mouse cursor up and down while holding - down the Shift key. When the receiver has focus, the user may also zoom by - pressing the up and down arrow keys while holding down the Option key. - - This property controls only user interactions with the map. If you set the - value of this property to `NO`, you may still change the map zoom - programmatically. */ -@property (nonatomic, getter=isZoomEnabled) BOOL zoomEnabled; - -/** A Boolean value that determines whether the user may scroll around the map, - changing the center coordinate. - - When this property is set to `YES`, the default, the user may scroll the map - by swiping with two fingers or dragging the mouse cursor. When the receiver - has focus, the user may also scroll around the map by pressing the arrow - keys. - - This property controls only user interactions with the map. If you set the - value of this property to `NO`, you may still change the map location - programmatically. */ -@property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled; - -/** A Boolean value that determines whether the user may rotate the map, - changing the direction. - - When this property is set to `YES`, the default, the user may rotate the map - by moving two fingers in a circular motion or by dragging the mouse cursor - left and right while holding down the Option key. When the receiver has - focus, the user may also zoom by pressing the left and right arrow keys - while holding down the Option key. - - This property controls only user interactions with the map. If you set the - value of this property to `NO`, you may still rotate the map - programmatically. */ -@property (nonatomic, getter=isRotateEnabled) BOOL rotateEnabled; - -/** A Boolean value that determines whether the user may tilt of the map, - changing the pitch. - - When this property is set to `YES`, the default, the user may rotate the map - by dragging the mouse cursor up and down while holding down the Option key. - - This property controls only user interactions with the map. If you set the - value of this property to `NO`, you may still change the pitch of the map - programmatically. */ -@property (nonatomic, getter=isPitchEnabled) BOOL pitchEnabled; - -#pragma mark Annotating the map -/** @name Annotating the Map */ - -/** The complete list of annotations associated with the receiver. (read-only) - - The objects in this array must adopt the MGLAnnotation protocol. If no - annotations are associated with the map view, the value of this property is - `nil`. */ -@property (nonatomic, readonly, nullable) NS_ARRAY_OF(id <MGLAnnotation>) *annotations; - -/** Adds an annotation to the map view. - - @param annotation The annotation object to add to the receiver. This object - must conform to the MGLAnnotation protocol. The map view retains the - annotation object. */ -- (void)addAnnotation:(id <MGLAnnotation>)annotation; - -/** Adds an array of annotations to the map view. - - @param annotations An array of annotation objects. Each object in the array - must conform to the MGLAnnotation protocol. The map view retains each - individual annotation object. */ -- (void)addAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations; - -/** Removes an annotation from the map view, deselecting it if it is selected. - - Removing an annotation object dissociates it from the map view entirely, - preventing it from being displayed on the map. Thus you would typically call - this method only when you want to hide or delete a given annotation. - - @param annotation The annotation object to remove. This object must conform - to the MGLAnnotation protocol. */ -- (void)removeAnnotation:(id <MGLAnnotation>)annotation; - -/** Removes an array of annotations from the map view, deselecting any selected - annotations in the array. - - Removing annotation objects dissociates them from the map view entirely, - preventing them from being displayed on the map. Thus you would typically - call this method only when you want to hide or delete the given annotations. - - @param annotations The array of annotation objects to remove. Objects in the - array must conform to the MGLAnnotation protocol. */ -- (void)removeAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations; - -/** Returns a reusable annotation image object associated with its identifier. - - For performance reasons, you should generally reuse MGLAnnotationImage - objects for identical-looking annotations in your map views. Dequeueing - saves time and memory during performance-critical operations such as - scrolling. - - @param identifier A string identifying the annotation image to be reused. - This string is the same one you specify when initially returning the - annotation image object using the -mapView:imageForAnnotation: method. - @return An annotation image object with the given identifier, or `nil` if no - such object exists in the reuse queue. */ -- (nullable MGLAnnotationImage *)dequeueReusableAnnotationImageWithIdentifier:(NSString *)identifier; - -#pragma mark Managing annotation selections -/** @name Managing Annotation Selections */ - -/** The currently selected annotations. - - Assigning a new array to this property selects only the first annotation in - the array. */ -@property (nonatomic, copy) NS_ARRAY_OF(id <MGLAnnotation>) *selectedAnnotations; - -/** Selects an annotation and displays a callout popover for it. - - If the given annotation is not visible within the current viewport, this - method has no effect. - - @param annotation The annotation object to select. */ -- (void)selectAnnotation:(id <MGLAnnotation>)annotation; - -/** Deselects an annotation and hides its callout popover. - - @param annotation The annotation object to deselect. */ -- (void)deselectAnnotation:(nullable id <MGLAnnotation>)annotation; - -/** A common view controller for managing a callout popover’s content view. - - Like any instance of NSPopover, an annotation callout manages its contents - with a view controller. The annotation object is the view controller’s - represented object. This means that you can bind controls in the view - controller’s content view to KVO-compliant properties of the annotation - object, such as -title and -subtitle. - - This property defines a common view controller that is used for every - annotation’s callout view. If you set this property to `nil`, a default - view controller will be used that manages a simple title label and subtitle - label. If you need distinct view controllers for different annotations, the - map view’s delegate should implement - -mapView:calloutViewControllerForAnnotation: instead. */ -@property (nonatomic, strong, null_resettable) IBOutlet NSViewController *calloutViewController; - -#pragma mark Finding annotations -/** @name Finding Annotations */ - -/** Returns a point annotation located at the given point. - - @param point A point in the view’s coordinate system. - @return A point annotation whose annotation image coincides with the point. - If multiple point annotations coincide with the point, the return value - is the annotation that would be selected if the user clicks at this - point. - */ -- (id <MGLAnnotation>)annotationAtPoint:(NSPoint)point; - -#pragma mark Overlaying the map -/** @name Overlaying the Map */ - -/** Adds a single overlay to the map. - - To remove an overlay from a map, use the -removeOverlay: method. - - @param overlay The overlay object to add. This object must conform to the - MGLOverlay protocol. */ -- (void)addOverlay:(id <MGLOverlay>)overlay; - -/** Adds an array of overlays to the map. - - To remove multiple overlays from a map, use the -removeOverlays: method. - - @param overlays An array of objects, each of which must conform to the - MGLOverlay protocol. */ -- (void)addOverlays:(NS_ARRAY_OF(id <MGLOverlay>) *)overlays; - -/** Removes a single overlay from the map. - - If the specified overlay is not currently associated with the map view, this - method does nothing. - - @param overlay The overlay object to remove. */ -- (void)removeOverlay:(id <MGLOverlay>)overlay; - -/** Removes an array of overlays from the map. - - If a given overlay object is not associated with the map view, it is - ignored. - - @param overlays An array of objects, each of which conforms to the - MGLOverlay protocol. */ -- (void)removeOverlays:(NS_ARRAY_OF(id <MGLOverlay>) *)overlays; - -#pragma mark Converting geographic coordinates -/** @name Converting Geographic Coordinates */ - -/** Converts a geographic coordinate to a point in the given view’s coordinate - system. - - @param coordinate The geographic coordinate to convert. - @param view The view in whose coordinate system the returned point should be - expressed. If this parameter is `nil`, the returned point is expressed - in the window’s coordinate system. If `view` is not `nil`, it must - belong to the same window as the map view. - @return The point (in the appropriate view or window coordinate system) - corresponding to the given geographic coordinate. */ -- (NSPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(nullable NSView *)view; - -/** Converts a point in the given view’s coordinate system to a geographic - coordinate. - - @param point The point to convert. - @param view The view in whose coordinate system the point is expressed. - @return The geographic coordinate at the given point. */ -- (CLLocationCoordinate2D)convertPoint:(NSPoint)point toCoordinateFromView:(nullable NSView *)view; - -/** Converts a geographic bounding box to a rectangle in the given view’s - coordinate system. - - @param bounds The geographic bounding box to convert. - @param view The view in whose coordinate system the returned rectangle - should be expressed. If this parameter is `nil`, the returned rectangle - is expressed in the window’s coordinate system. If `view` is not `nil`, - it must belong to the same window as the map view. */ -- (NSRect)convertCoordinateBounds:(MGLCoordinateBounds)bounds toRectToView:(nullable NSView *)view; - -/** Converts a rectangle in the given view’s coordinate system to a geographic - bounding box. - - @param rect The rectangle to convert. - @param view The view in whose coordinate system the rectangle is expressed. - @return The geographic bounding box coextensive with the given rectangle. */ -- (MGLCoordinateBounds)convertRect:(NSRect)rect toCoordinateBoundsFromView:(nullable NSView *)view; - -/** Returns the distance spanned by one point in the map view’s coordinate - system at the given latitude and current zoom level. - - The distance between points decreases as the latitude approaches the poles. - This relationship parallels the relationship between longitudinal - coordinates at different latitudes. - - @param latitude The latitude of the geographic coordinate represented by the - point. - @return The distance in meters spanned by a single point. */ -- (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude; - -#pragma mark Debugging the map -/** @name Debugging the Map */ - -/** The options that determine which debugging aids are shown on the map. - - These options are all disabled by default and should remain disabled in - released software for performance and aesthetic reasons. */ -@property (nonatomic) MGLMapDebugMaskOptions debugMask; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/osx/MGLMapViewDelegate.h b/include/mbgl/osx/MGLMapViewDelegate.h deleted file mode 100644 index eece606c39..0000000000 --- a/include/mbgl/osx/MGLMapViewDelegate.h +++ /dev/null @@ -1,199 +0,0 @@ -#import <Foundation/Foundation.h> - -#import "MGLTypes.h" - -NS_ASSUME_NONNULL_BEGIN - -@class MGLMapView; -@class MGLAnnotationImage; -@class MGLPolygon; -@class MGLPolyline; -@class MGLShape; - -/** The MGLMapViewDelegate protocol defines a set of optional methods that you - can use to receive messages from an MGLMapView instance. Because many map - operations require the MGLMapView class to load data asynchronously, the map - view calls these methods to notify your application when specific operations - complete. The map view also uses these methods to request information about - annotations displayed on the map, such as the styles and interaction modes - to apply to individual annotations. */ -@protocol MGLMapViewDelegate <NSObject> - -@optional - -#pragma mark Responding to map viewpoint changes -/** @name Responding to Map Viewpoint Changes */ - -/** Tells the delegate that the viewpoint depicted by the map view is about to - change. - - This method is called whenever the currently displayed map camera will start - changing for any reason. - - @param mapView The map view whose viewpoint will change. - @param animated Whether the change will cause an animated effect on the map. - */ -- (void)mapView:(MGLMapView *)mapView cameraWillChangeAnimated:(BOOL)animated; - -/** Tells the delegate that the viewpoint depicted by the map view is changing. - - This method is called as the currently displayed map camera changes due to - animation. During movement, this method may be called many times to report - updates to the viewpoint. Therefore, your implementation of this method - should be as lightweight as possible to avoid affecting performance. - - @param mapView The map view whose viewpoint is changing. */ -- (void)mapViewCameraIsChanging:(MGLMapView *)mapView; - -/** Tells the delegate that the viewpoint depicted by the map view has finished - changing. - - This method is called whenever the currently displayed map camera has - finished changing. - - @param mapView The map view whose viewpoint has changed. - @param animated Whether the change caused an animated effect on the map. */ -- (void)mapView:(MGLMapView *)mapView cameraDidChangeAnimated:(BOOL)animated; - -#pragma mark Loading the map -/** @name Loading the Map */ - -/** Tells the delegate that the map view will begin to load. - - This method is called whenever the map view starts loading, including when a - new style has been set and the map must reload. - - @param mapView The map view that is starting to load. */ -- (void)mapViewWillStartLoadingMap:(MGLMapView *)mapView; - -/** Tells the delegate that the map view has finished loading. - - This method is called whenever the map view finishes loading, either after - the initial load or after a style change has forced a reload. - - @param mapView The map view that has finished loading. */ -- (void)mapViewDidFinishLoadingMap:(MGLMapView *)mapView; - -- (void)mapViewWillStartRenderingMap:(MGLMapView *)mapView; -- (void)mapViewDidFinishRenderingMap:(MGLMapView *)mapView fullyRendered:(BOOL)fullyRendered; -- (void)mapViewWillStartRenderingFrame:(MGLMapView *)mapView; -- (void)mapViewDidFinishRenderingFrame:(MGLMapView *)mapView fullyRendered:(BOOL)fullyRendered; - -#pragma mark Managing the display of annotations -/** @name Managing the Display of Annotations */ - -/** Returns an annotation image object to mark the given point annotation object - on the map. - - @param mapView The map view that requested the annotation image. - @param annotation The object representing the annotation that is about to be - displayed. - @return The image object to display for the given annotation or `nil` if you - want to display the default marker image. */ -- (nullable MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id <MGLAnnotation>)annotation; - -/** Returns the alpha value to use when rendering a shape annotation. - - A value of 0.0 results in a completely transparent shape. A value of 1.0, - the default, results in a completely opaque shape. - - @param mapView The map view rendering the shape annotation. - @param annotation The annotation being rendered. - @return An alpha value between 0 and 1.0. */ -- (CGFloat)mapView:(MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation; - -/** Returns the color to use when rendering the outline of a shape annotation. - - The default stroke color is black. If a pattern color is specified, the - result is undefined. - - @param mapView The map view rendering the shape annotation. - @param annotation The annotation being rendered. - @return A color to use for the shape outline. */ -- (NSColor *)mapView:(MGLMapView *)mapView strokeColorForShapeAnnotation:(MGLShape *)annotation; - -/** Returns the color to use when rendering the fill of a polygon annotation. - - The default fill color is blue. If a pattern color is specified, the result - is undefined. - - @param mapView The map view rendering the polygon annotation. - @param annotation The annotation being rendered. - @return The polygon’s interior fill color. */ -- (NSColor *)mapView:(MGLMapView *)mapView fillColorForPolygonAnnotation:(MGLPolygon *)annotation; - -/** Returns the line width in points to use when rendering the outline of a - polyline annotation. - - By default, the polyline is outlined with a line 3.0 points wide. - - @param mapView The map view rendering the polygon annotation. - @param annotation The annotation being rendered. - @return A line width for the polyline, measured in points. */ -- (CGFloat)mapView:(MGLMapView *)mapView lineWidthForPolylineAnnotation:(MGLPolyline *)annotation; - -#pragma mark Selecting annotations -/** @name Selecting annotations */ - -/** Tells the delegate that one of its annotations has been selected. - - You can use this method to track changes to the selection state of - annotations. - - @param mapView The map view containing the annotation. - @param annotation The annotation that was selected. */ -- (void)mapView:(MGLMapView *)mapView didSelectAnnotation:(id <MGLAnnotation>)annotation; - -/** Tells the delegate that one of its annotations has been deselected. - - You can use this method to track changes in the selection state of - annotations. - - @param mapView The map view containing the annotation. - @param annotation The annotation that was deselected. */ -- (void)mapView:(MGLMapView *)mapView didDeselectAnnotation:(id <MGLAnnotation>)annotation; - -#pragma mark Displaying information about annotations -/** @name Displaying Information About Annotations */ - -/** Returns a Boolean value indicating whether the annotation is able to display - extra information in a callout popover. - - This method is called after an annotation is selected, before any callout is - displayed for the annotation. - - If the return value is `YES`, a callout popover is shown when the user - clicks on a selected annotation. The default callout displays the - annotation’s title and subtitle. You can customize the popover’s contents by - implementing the -mapView:calloutViewControllerForAnnotation: method. - - If the return value is `NO`, or if this method is unimplemented, or if the - annotation lacks a title, the annotation will not show a callout even when - selected. - - @param mapView The map view that has selected the annotation. - @param annotation The object representing the annotation. - @return A Boolean value indicating whether the annotation should show a - callout. - */ -- (BOOL)mapView:(MGLMapView *)mapView annotationCanShowCallout:(id <MGLAnnotation>)annotation; - -/** Returns a view controller to manage the callout popover’s content view. - - Like any instance of NSPopover, an annotation callout manages its contents - with a view controller. The annotation object is the view controller’s - represented object. This means that you can bind controls in the view - controller’s content view to KVO-compliant properties of the annotation - object, such as -title and -subtitle. - - If each annotation should have an identical callout, you can set the - MGLMapView instance’s -setCalloutViewController: method instead. - - @param mapView The map view that is requesting a callout view controller. - @param annotation The object representing the annotation. - @return A view controller for the given annotation. */ -- (nullable NSViewController *)mapView:(MGLMapView *)mapView calloutViewControllerForAnnotation:(id <MGLAnnotation>)annotation; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/platform/default/glfw_view.hpp b/include/mbgl/platform/default/glfw_view.hpp index 0e46f7d87e..ae5bf340d5 100644 --- a/include/mbgl/platform/default/glfw_view.hpp +++ b/include/mbgl/platform/default/glfw_view.hpp @@ -6,6 +6,7 @@ #ifdef MBGL_USE_GLES2 #define GLFW_INCLUDE_ES2 #endif +#define GL_GLEXT_PROTOTYPES #include <GLFW/glfw3.h> #include <atomic> @@ -51,6 +52,9 @@ private: makeSpriteImage(int width, int height, float pixelRatio); void nextOrientation(); + void toggleClipMasks(); + + void renderClipMasks(); void addRandomPointAnnotations(int count); void addRandomShapeAnnotations(int count); @@ -80,6 +84,8 @@ private: int fbHeight; float pixelRatio; + bool showClipMasks = false; + double lastX = 0, lastY = 0; double lastClick = -1; diff --git a/include/mbgl/platform/default/headless_view.hpp b/include/mbgl/platform/default/headless_view.hpp index 68f32ed1ca..8f8d11b297 100644 --- a/include/mbgl/platform/default/headless_view.hpp +++ b/include/mbgl/platform/default/headless_view.hpp @@ -14,7 +14,7 @@ typedef XID GLXPbuffer; #endif #include <mbgl/mbgl.hpp> -#include <mbgl/platform/gl.hpp> +#include <mbgl/gl/gl.hpp> #include <memory> #include <thread> diff --git a/include/mbgl/storage/default_file_source.hpp b/include/mbgl/storage/default_file_source.hpp index bedea25bef..d55e12b778 100644 --- a/include/mbgl/storage/default_file_source.hpp +++ b/include/mbgl/storage/default_file_source.hpp @@ -2,25 +2,100 @@ #define MBGL_STORAGE_DEFAULT_FILE_SOURCE #include <mbgl/storage/file_source.hpp> +#include <mbgl/storage/offline.hpp> +#include <mbgl/util/constants.hpp> + +#include <vector> namespace mbgl { +namespace util { +template <typename T> class Thread; +} // namespace util + class DefaultFileSource : public FileSource { public: - DefaultFileSource(const std::string& cachePath, const std::string& assetRoot); + DefaultFileSource(const std::string& cachePath, + const std::string& assetRoot, + uint64_t maximumCacheSize = util::DEFAULT_MAX_CACHE_SIZE); ~DefaultFileSource() override; void setAccessToken(const std::string&); std::string getAccessToken() const; - void setMaximumCacheSize(uint64_t size); - void setMaximumCacheEntrySize(uint64_t size); - std::unique_ptr<FileRequest> request(const Resource&, Callback) override; -private: + /* + * Retrieve all regions in the offline database. + * + * The query will be executed asynchronously and the results passed to the given + * callback, which will be executed on the database thread; it is the responsibility + * of the SDK bindings to re-execute a user-provided callback on the main thread. + */ + void listOfflineRegions(std::function<void (std::exception_ptr, + optional<std::vector<OfflineRegion>>)>); + + /* + * Create an offline region in the database. + * + * When the initial database queries have completed, the provided callback will be + * executed on the database thread; it is the responsibility of the SDK bindings + * to re-execute a user-provided callback on the main thread. + * + * Note that the resulting region will be in an inactive download state; to begin + * downloading resources, call `setOfflineRegionDownloadState(OfflineRegionDownloadState::Active)`, + * optionally registering an `OfflineRegionObserver` beforehand. + */ + void createOfflineRegion(const OfflineRegionDefinition& definition, + const OfflineRegionMetadata& metadata, + std::function<void (std::exception_ptr, + optional<OfflineRegion>)>); + + /* + * Register an observer to be notified when the state of the region changes. + */ + void setOfflineRegionObserver(OfflineRegion&, std::unique_ptr<OfflineRegionObserver>); + + /* + * Pause or resume downloading of regional resources. + */ + void setOfflineRegionDownloadState(OfflineRegion&, OfflineRegionDownloadState); + + /* + * Retrieve the current status of the region. The query will be executed + * asynchronously and the results passed to the given callback, which will be + * executed on the database thread; it is the responsibility of the SDK bindings + * to re-execute a user-provided callback on the main thread. + */ + void getOfflineRegionStatus(OfflineRegion&, std::function<void (std::exception_ptr, + optional<OfflineRegionStatus>)>) const; + + /* + * Remove an offline region from the database and perform any resources evictions + * necessary as a result. + * + * Eviction works by removing the least-recently requested resources not also required + * by other regions, until the database shrinks below a certain size. + * + * Note that this method takes ownership of the input, reflecting the fact that once + * region deletion is initiated, it is not legal to perform further actions with the + * region. + * + * When the operation is complete or encounters an error, the given callback will be + * executed on the database thread; it is the responsibility of the SDK bindings + * to re-execute a user-provided callback on the main thread. + */ + void deleteOfflineRegion(OfflineRegion&&, std::function<void (std::exception_ptr)>); + + // For testing only. + void put(const Resource&, const Response&); + void goOffline(); + class Impl; - const std::unique_ptr<Impl> impl; + +private: + const std::unique_ptr<util::Thread<Impl>> thread; + const std::unique_ptr<FileSource> assetFileSource; }; } // namespace mbgl diff --git a/include/mbgl/storage/offline.hpp b/include/mbgl/storage/offline.hpp new file mode 100644 index 0000000000..dd63cf968f --- /dev/null +++ b/include/mbgl/storage/offline.hpp @@ -0,0 +1,181 @@ +#pragma once + +#include <mbgl/util/geo.hpp> +#include <mbgl/util/optional.hpp> +#include <mbgl/style/types.hpp> +#include <mbgl/storage/response.hpp> + +#include <string> +#include <vector> +#include <functional> + +namespace mbgl { + +class TileID; +class SourceInfo; + +/* + * An offline region defined by a style URL, geographic bounding box, zoom range, and + * device pixel ratio. + * + * Both minZoom and maxZoom must be ≥ 0, and maxZoom must be ≥ minZoom. + * + * maxZoom may be ∞, in which case for each tile source, the region will include + * tiles from minZoom up to the maximum zoom level provided by that source. + * + * pixelRatio must be ≥ 0 and should typically be 1.0 or 2.0. + */ +class OfflineTilePyramidRegionDefinition { +public: + OfflineTilePyramidRegionDefinition(const std::string&, const LatLngBounds&, double, double, float); + + /* Private */ + std::vector<TileID> tileCover(SourceType, uint16_t tileSize, const SourceInfo&) const; + + const std::string styleURL; + const LatLngBounds bounds; + const double minZoom; + const double maxZoom; + const float pixelRatio; +}; + +/* + * For the present, a tile pyramid is the only type of offline region. In the future, + * other definition types will be available and this will be a variant type. + */ +using OfflineRegionDefinition = OfflineTilePyramidRegionDefinition; + +/* + * The encoded format is private. + */ +std::string encodeOfflineRegionDefinition(const OfflineRegionDefinition&); +OfflineRegionDefinition decodeOfflineRegionDefinition(const std::string&); + +/* + * Arbitrary binary region metadata. The contents are opaque to the mbgl implementation; + * it just stores and retrieves a BLOB. SDK bindings should leave the interpretation of + * this data up to the application; they _should not_ enforce a higher-level data format. + * In the future we want offline database to be portable across target platforms, and a + * platform-specific metadata format would prevent that. + */ +using OfflineRegionMetadata = std::vector<uint8_t>; + +/* + * A region is either inactive (not downloading, but previously-downloaded + * resources are available for use), or active (resources are being downloaded + * or will be downloaded, if necessary, when network access is available). + * + * This state is independent of whether or not the complete set of resources + * is currently available for offline use. To check if that is the case, use + * `OfflineRegionStatus::complete()`. + */ +enum class OfflineRegionDownloadState { + Inactive, + Active +}; + +/* + * A region's status includes its active/inactive state as well as counts + * of the number of resources that have completed downloading, their total + * size in bytes, and the total number of resources that are required. + * + * Note that the total required size in bytes is not currently available. A + * future API release may provide an estimate of this number. + */ +class OfflineRegionStatus { +public: + OfflineRegionDownloadState downloadState = OfflineRegionDownloadState::Inactive; + + /** + * The number of resources that have been fully downloaded and are ready for + * offline access. + */ + uint64_t completedResourceCount = 0; + + /** + * The cumulative size, in bytes, of all resources that have been fully downloaded. + */ + uint64_t completedResourceSize = 0; + + /** + * The number of resources that are known to be required for this region. See the + * documentation for `requiredResourceCountIsIndeterminate` for an important caveat + * about this number. + */ + uint64_t requiredResourceCount = 0; + + /** + * This property is true during early phases of an offline download, when the total + * required resource count is unknown and requiredResourceCount is merely a lower + * bound. + * + * Specifically, it is true before until the style and tile sources have been + * downloaded, and false thereafter. + */ + bool requiredResourceCountIsIndeterminate = true; + + bool complete() const { + return completedResourceCount == requiredResourceCount; + } +}; + +/* + * A region can have a single observer, which gets notified whenever a change + * to the region's status occurs. + */ +class OfflineRegionObserver { +public: + virtual ~OfflineRegionObserver() = default; + + /* + * Implement this method to be notified of a change in the status of an + * offline region. Status changes include any change in state of the members + * of OfflineRegionStatus. + * + * Note that this method will be executed on the database thread; it is the + * responsibility of the SDK bindings to wrap this object in an interface that + * re-executes the user-provided implementation on the main thread. + */ + virtual void statusChanged(OfflineRegionStatus) {} + + /* + * Implement this method to be notified of errors encountered while downloading + * regional resources. Such errors may be recoverable; for example the implementation + * will attempt to re-request failed resources based on an exponential backoff + * algorithm, or when it detects that network access has been restored. + * + * Note that this method will be executed on the database thread; it is the + * responsibility of the SDK bindings to wrap this object in an interface that + * re-executes the user-provided implementation on the main thread. + */ + virtual void responseError(Response::Error) {} +}; + +class OfflineRegion { +public: + // Move-only; not publicly constructible. + OfflineRegion(OfflineRegion&&); + OfflineRegion& operator=(OfflineRegion&&); + ~OfflineRegion(); + + OfflineRegion() = delete; + OfflineRegion(const OfflineRegion&) = delete; + OfflineRegion& operator=(const OfflineRegion&) = delete; + + int64_t getID() const; + const OfflineRegionDefinition& getDefinition() const; + const OfflineRegionMetadata& getMetadata() const; + +private: + friend class OfflineDatabase; + + OfflineRegion(int64_t id, + const OfflineRegionDefinition&, + const OfflineRegionMetadata&); + + const int64_t id; + const OfflineRegionDefinition definition; + const OfflineRegionMetadata metadata; +}; + +} // namespace mbgl diff --git a/include/mbgl/storage/online_file_source.hpp b/include/mbgl/storage/online_file_source.hpp index bdf14c7b34..aceb141fb4 100644 --- a/include/mbgl/storage/online_file_source.hpp +++ b/include/mbgl/storage/online_file_source.hpp @@ -5,15 +5,13 @@ namespace mbgl { -class SQLiteCache; - namespace util { template <typename T> class Thread; } // namespace util class OnlineFileSource : public FileSource { public: - OnlineFileSource(SQLiteCache*); + OnlineFileSource(); ~OnlineFileSource() override; void setAccessToken(const std::string& t) { accessToken = t; } @@ -22,11 +20,8 @@ public: std::unique_ptr<FileRequest> request(const Resource&, Callback) override; private: - friend class OnlineFileRequest; friend class OnlineFileRequestImpl; - void cancel(FileRequest*); - class Impl; const std::unique_ptr<util::Thread<Impl>> thread; std::string accessToken; diff --git a/include/mbgl/storage/resource.hpp b/include/mbgl/storage/resource.hpp index c97384e6a7..edd9f58c72 100644 --- a/include/mbgl/storage/resource.hpp +++ b/include/mbgl/storage/resource.hpp @@ -31,7 +31,7 @@ public: Resource(Kind kind_, const std::string& url_, optional<TileData> tileData_ = {}) : kind(kind_), url(url_), - tileData(tileData_) { + tileData(std::move(tileData_)) { } static Resource style(const std::string& url); @@ -47,8 +47,8 @@ public: static Resource spriteImage(const std::string& base, float pixelRatio); static Resource spriteJSON(const std::string& base, float pixelRatio); - const Kind kind; - const std::string url; + Kind kind; + std::string url; // Includes auxiliary data if this is a tile request. optional<TileData> tileData; diff --git a/include/mbgl/storage/response.hpp b/include/mbgl/storage/response.hpp index a44902e1f9..bec1efe6b1 100644 --- a/include/mbgl/storage/response.hpp +++ b/include/mbgl/storage/response.hpp @@ -20,10 +20,14 @@ public: // When this object is empty, the response was successful. std::unique_ptr<const Error> error; + // This is set to true for 204 Not Modified responses, and, for backward compatibility, + // for 404 Not Found responses for tiles. + bool noContent = false; + // This is set to true for 304 Not Modified responses. bool notModified = false; - // The actual data of the response. This is null if notModified is true. + // The actual data of the response. Present only for non-error, non-notModified responses. std::shared_ptr<const std::string> data; optional<SystemTimePoint> modified; @@ -49,6 +53,8 @@ public: Error(Reason, const std::string& = ""); }; +std::ostream& operator<<(std::ostream&, Response::Error::Reason); + } // namespace mbgl #endif diff --git a/include/mbgl/util/constants.hpp b/include/mbgl/util/constants.hpp index 24f4b5ee72..9ddbcb2568 100644 --- a/include/mbgl/util/constants.hpp +++ b/include/mbgl/util/constants.hpp @@ -21,6 +21,8 @@ extern const double PITCH_MAX; extern const double MIN_ZOOM; extern const double MAX_ZOOM; +extern const uint64_t DEFAULT_MAX_CACHE_SIZE; + } // namespace util namespace debug { diff --git a/include/mbgl/util/gl_helper.hpp b/include/mbgl/util/gl_helper.hpp deleted file mode 100644 index 7d104fb80e..0000000000 --- a/include/mbgl/util/gl_helper.hpp +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef MBGL_UTIL_GL_HELPER -#define MBGL_UTIL_GL_HELPER - -#include <mbgl/platform/gl.hpp> - -#include <array> - -namespace { - -template <typename T, T (*Create)(), void (*Destroy)(const T&)> -class Preserve { -public: - Preserve() : data(Create()) {} - ~Preserve() { Destroy(data); } - -private: - const T data; -}; - -inline bool getBlend() { - return glIsEnabled(GL_BLEND); -} - -inline void setBlend(const bool& enabled) { - enabled ? MBGL_CHECK_ERROR(glEnable(GL_BLEND)) : MBGL_CHECK_ERROR(glDisable(GL_BLEND)); -} - -inline std::array<float, 4> getClearColor() { - std::array<float, 4> color; - MBGL_CHECK_ERROR(glGetFloatv(GL_COLOR_CLEAR_VALUE, color.data())); - return color; -} - -inline void setClearColor(const std::array<float, 4>& color) { - MBGL_CHECK_ERROR(glClearColor(color[0], color[1], color[2], color[3])); -} - - -inline std::array<GLenum, 2> getBlendFunc() { - GLint func[2]; - glGetIntegerv(GL_BLEND_SRC_ALPHA, &func[0]); - glGetIntegerv(GL_BLEND_DST_ALPHA, &func[1]); - return {{ static_cast<GLenum>(func[0]), static_cast<GLenum>(func[1]) }}; -} - -inline void setBlendFunc(const std::array<GLenum, 2>& func) { - MBGL_CHECK_ERROR(glBlendFunc(func[0], func[1])); -} - -#ifndef GL_ES_VERSION_2_0 -inline std::array<double, 2> getPixelZoom() { - std::array<double, 2> zoom; - glGetDoublev(GL_ZOOM_X, &zoom[0]); - glGetDoublev(GL_ZOOM_Y, &zoom[1]); - return zoom; -} - -inline void setPixelZoom(const std::array<double, 2>& func) { - MBGL_CHECK_ERROR(glPixelZoom(func[0], func[1])); -} - - -inline std::array<double, 4> getRasterPos() { - std::array<double, 4> pos; - MBGL_CHECK_ERROR(glGetDoublev(GL_CURRENT_RASTER_POSITION, pos.data())); - return pos; -} - -inline void setRasterPos(const std::array<double, 4>& pos) { - MBGL_CHECK_ERROR(glRasterPos4d(pos[0], pos[1], pos[2], pos[3])); -} -#endif -} // end anonymous namespace - -namespace mbgl { -namespace gl { - -using PreserveBlend = Preserve<bool, getBlend, setBlend>; -using PreserveClearColor = Preserve<std::array<float, 4>, getClearColor, setClearColor>; -using PreserveBlendFunc = Preserve<std::array<GLenum, 2>, getBlendFunc, setBlendFunc>; - -#ifndef GL_ES_VERSION_2_0 -using PreservePixelZoom = Preserve<std::array<double, 2>, getPixelZoom, setPixelZoom>; -using PreserveRasterPos = Preserve<std::array<double, 4>, getRasterPos, setRasterPos>; -#endif - -} // namespace gl -} // namespace mbgl - -#endif diff --git a/include/mbgl/util/math.hpp b/include/mbgl/util/math.hpp index 9be0568e12..08625ffc0c 100644 --- a/include/mbgl/util/math.hpp +++ b/include/mbgl/util/math.hpp @@ -88,6 +88,11 @@ inline T dist(const S1& a, const S2& b) { } template <typename T> +inline T round(const T& a) { + return T(::round(a.x), ::round(a.y)); +} + +template <typename T> inline T length(T a, T b) { return std::sqrt(a * a + b * b); } diff --git a/include/mbgl/util/run_loop.hpp b/include/mbgl/util/run_loop.hpp index 6075d76c8c..fbc4794940 100644 --- a/include/mbgl/util/run_loop.hpp +++ b/include/mbgl/util/run_loop.hpp @@ -41,9 +41,6 @@ public: void runOnce(); void stop(); - void ref(); - void unref(); - // So far only needed by the libcurl backend. void addWatch(int fd, Event, std::function<void(int, Event)>&& callback); void removeWatch(int fd); |