summaryrefslogtreecommitdiff
path: root/include/mbgl
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl')
-rw-r--r--include/mbgl/ios/MGLAnnotation.h28
-rw-r--r--include/mbgl/ios/MGLMapView.h197
-rw-r--r--include/mbgl/ios/MGLMapboxEvents.h26
-rw-r--r--include/mbgl/ios/MGLMetricsLocationManager.h22
-rw-r--r--include/mbgl/ios/MGLTypes.h9
-rw-r--r--include/mbgl/ios/MGLUserLocation.h26
-rw-r--r--include/mbgl/ios/MapboxGL.h4
-rw-r--r--include/mbgl/map/annotation.hpp55
-rw-r--r--include/mbgl/map/map.hpp66
-rw-r--r--include/mbgl/map/tile.hpp7
-rw-r--r--include/mbgl/map/view.hpp17
-rw-r--r--include/mbgl/platform/darwin/settings_nsuserdefaults.hpp5
-rw-r--r--include/mbgl/util/constants.hpp2
-rw-r--r--include/mbgl/util/geo.hpp7
14 files changed, 397 insertions, 74 deletions
diff --git a/include/mbgl/ios/MGLAnnotation.h b/include/mbgl/ios/MGLAnnotation.h
new file mode 100644
index 0000000000..e4907d9b94
--- /dev/null
+++ b/include/mbgl/ios/MGLAnnotation.h
@@ -0,0 +1,28 @@
+#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
+
+/** 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>
+
+/** @name Position Attributes */
+
+/** The center point (specified as a map coordinate) of the annotation. (required) (read-only) */
+@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
+
+@optional
+
+/** @name 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) NSString *title;
+
+/** The string containing the annotation’s subtitle.
+*
+* This string is displayed in the callout for the associated annotation. */
+@property (nonatomic, readonly, copy) NSString *subtitle;
+
+@end
diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h
index f954340262..b41e2f5d72 100644
--- a/include/mbgl/ios/MGLMapView.h
+++ b/include/mbgl/ios/MGLMapView.h
@@ -1,7 +1,12 @@
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
+#import "MGLTypes.h"
+
+@class MGLUserLocation;
+
@protocol MGLMapViewDelegate;
+@protocol MGLAnnotation;
/** An MGLMapView object provides an embeddable map interface, similar to the one provided by Apple's MapKit. You use this class to display map information and to manipulate the map contents from your application. You can center the map on a given coordinate, specify the size of the area you want to display, and style the features of the map to fit your application's use case.
*
@@ -16,10 +21,17 @@
/** Initialize a map view with a given frame, style, and access token.
* @param frame The frame with which to initialize the map view.
+* @param accessToken A Mapbox API access token.
* @param styleJSON The map stylesheet as JSON text.
+* @return An initialized map view, or `nil` if the map view was unable to be initialized. */
+- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleJSON:(NSString *)styleJSON;
+
+/** Initialize a map view with a given frame, bundled style name, and access token.
+* @param frame The frame with which to initialize the map view.
* @param accessToken A Mapbox API access token.
+* @param styleName The map style name to use.
* @return An initialized map view, or `nil` if the map view was unable to be initialized. */
-- (instancetype)initWithFrame:(CGRect)frame styleJSON:(NSString *)styleJSON accessToken:(NSString *)accessToken;
+- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken bundledStyleNamed:(NSString *)styleName;
/** Initialize a map view with a given frame, the default style, and an access token.
* @param frame The frame with which to initialize the map view.
@@ -177,6 +189,79 @@
* @param styleName The map style name to use. */
- (void)useBundledStyleNamed:(NSString *)styleName;
+#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) NSArray *annotations;
+
+/** Adds the specified 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 specified object. */
+- (void)addAnnotation:(id <MGLAnnotation>)annotation;
+
+/** Adds an array of annotation objects 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 the individual annotation objects. */
+- (void)addAnnotations:(NSArray *)annotations;
+
+/** Removes the specified annotation object from the map view.
+*
+* Removing an annotation object disassociates 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 annotation objects from the map view.
+*
+* Removing annotation objects disassociates 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 specified annotations.
+*
+* @param annotations The array of annotations to remove. Objects in the array must conform to the MGLAnnotation protocol. */
+- (void)removeAnnotations:(NSArray *)annotations;
+
+/** The annotations that are currently selected.
+*
+* Assigning a new array to this property selects only the first annotation in the array. */
+@property (nonatomic, copy) NSArray *selectedAnnotations;
+
+/** Selects the specified annotation and displays a callout view for it.
+*
+* If the specified annotation is not onscreen, 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 the specified 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:(id <MGLAnnotation>)annotation animated:(BOOL)animated;
+
+#pragma mark - Displaying the User's Location
+
+/** A Boolean value indicating whether the map may display the user location.
+
+ 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`.
+
+ 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.
+
+ On iOS 8 and above, your app must specify a value for `NSLocationWhenInUseUsageDescription` in its `Info.plist` to satisfy the requirements of the underlying Core Location framework when enabling this property.
+ */
+@property (nonatomic, assign) BOOL showsUserLocation;
+
+/// Returns a Boolean value indicating whether the user currently sees the user location annotation.
+@property (nonatomic, assign, readonly, getter=isUserLocationVisible) BOOL userLocationVisible;
+
+/// Returns the annotation object indicating the user’s current location.
+@property (nonatomic, readonly) MGLUserLocation *userLocation;
+
+/** The mode used to track the user location. */
+@property (nonatomic, assign) MGLUserTrackingMode userTrackingMode;
+
+/** Whether the map view should display a heading calibration alert when necessary. The default value is `YES`. */
+@property (nonatomic, assign) BOOL displayHeadingCalibration;
+
#pragma mark - Debugging
/** @name Debugging */
@@ -194,19 +279,71 @@
@end
-// TODO
+#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 - Managing the Display of Annotations
+
+/** @name Managing the Display of Annotations */
+
+/** Returns the style's symbol name to use for the marker for the specified point annotation object.
+* @param mapView The map view that requested the annotation symbol name.
+* @param annotation The object representing the annotation that is about to be displayed.
+* @return The marker symbol to display for the specified annotation or `nil` if you want to display the default symbol. */
+- (NSString *)mapView:(MGLMapView *)mapView symbolNameForAnnotation:(id <MGLAnnotation>)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;
+
+/** Return 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. */
+- (UIView *)mapView:(MGLMapView *)mapView leftCalloutAccessoryViewForAnnotation:(id <MGLAnnotation>)annotation;
+
+/** Return 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. */
+- (UIView *)mapView:(MGLMapView *)mapView rightCalloutAccessoryViewForAnnotation:(id <MGLAnnotation>)annotation;
+
+#pragma mark - Responding to Map Position Changes
+
// Responding to Map Position Changes
// TODO
- (void)mapView:(MGLMapView *)mapView regionWillChangeAnimated:(BOOL)animated;
// TODO
+- (void)mapViewRegionIsChanging:(MGLMapView *)mapView;
+
+// TODO
- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated;
+#pragma mark - Loading the Map Data
+
// Loading the Map Data
// TODO
@@ -224,4 +361,60 @@
// TODO
- (void)mapViewDidFinishRenderingMap:(MGLMapView *)mapView fullyRendered:(BOOL)fullyRendered;
+#pragma mark - Tracking the User Location
+
+/// Tells the delegate that the map view will begin tracking the user’s location.
+- (void)mapViewWillStartLocatingUser:(MGLMapView *)mapView;
+
+/// Tells the delegate that the map view has stopped tracking the user’s location.
+- (void)mapViewDidStopLocatingUser:(MGLMapView *)mapView;
+
+/// Tells the delegate that the map view has updated the user’s location to the given location.
+- (void)mapView:(MGLMapView *)mapView didUpdateUserLocation:(MGLUserLocation *)userLocation;
+
+/// Tells the delegate that the map view has failed to locate the user.
+- (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.
+ */
+- (void)mapView:(MGLMapView *)mapView didChangeUserTrackingMode:(MGLUserTrackingMode)mode animated:(BOOL)animated;
+
+#pragma mark - Managing Annotations
+
+/** @name 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;
+
+#pragma mark - Selecting Annotations
+
+/** @name 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
diff --git a/include/mbgl/ios/MGLMapboxEvents.h b/include/mbgl/ios/MGLMapboxEvents.h
new file mode 100644
index 0000000000..bb28ec26c5
--- /dev/null
+++ b/include/mbgl/ios/MGLMapboxEvents.h
@@ -0,0 +1,26 @@
+//
+// MapboxEvents.h
+// MapboxEvents
+//
+// Created by Brad Leege on 3/5/15.
+// Copyright (c) 2015 Mapbox. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface MGLMapboxEvents : NSObject
+
+@property (atomic) NSInteger flushAt;
+@property (atomic) NSInteger flushAfter;
+@property (atomic) NSString *api;
+@property (atomic) NSString *token;
+@property (atomic) NSString *appName;
+@property (atomic) NSString *appVersion;
+
++ (id)sharedManager;
+
+- (void) pushEvent:(NSString *)event withAttributes:(NSDictionary *)attributeDictionary;
+
+- (void) flush;
+
+@end \ No newline at end of file
diff --git a/include/mbgl/ios/MGLMetricsLocationManager.h b/include/mbgl/ios/MGLMetricsLocationManager.h
new file mode 100644
index 0000000000..ce04ae9ef6
--- /dev/null
+++ b/include/mbgl/ios/MGLMetricsLocationManager.h
@@ -0,0 +1,22 @@
+//
+// MBLocationManager.h
+// Hermes
+//
+// Created by Brad Leege on 3/8/15.
+// Copyright (c) 2015 Mapbox. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "CoreLocation/CoreLocation.h"
+
+@interface MGLMetricsLocationManager : NSObject <CLLocationManagerDelegate>
+
++ (id)sharedManager;
+
+- (BOOL) isAuthorizedStatusDetermined;
+- (void) requestAlwaysAuthorization;
+
+- (void) startUpdatingLocation;
+- (void) stopUpdatingLocation;
+
+@end
diff --git a/include/mbgl/ios/MGLTypes.h b/include/mbgl/ios/MGLTypes.h
new file mode 100644
index 0000000000..4c2e58b24b
--- /dev/null
+++ b/include/mbgl/ios/MGLTypes.h
@@ -0,0 +1,9 @@
+#import <Foundation/Foundation.h>
+
+/// The degree to which the map view tracks the user’s location.
+typedef NS_ENUM(NSUInteger, MGLUserTrackingMode)
+{
+ MGLUserTrackingModeNone = 0, ///< does not track the user’s location or heading
+ MGLUserTrackingModeFollow = 1, ///< tracks the user’s location
+ MGLUserTrackingModeFollowWithHeading = 2, ///< tracks the user’s location and heading
+};
diff --git a/include/mbgl/ios/MGLUserLocation.h b/include/mbgl/ios/MGLUserLocation.h
new file mode 100644
index 0000000000..fee3368889
--- /dev/null
+++ b/include/mbgl/ios/MGLUserLocation.h
@@ -0,0 +1,26 @@
+#import "MGLAnnotation.h"
+
+@interface MGLUserLocation : NSObject <MGLAnnotation>
+
+@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
+
+/** @name 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) CLLocation *location;
+
+/** A Boolean value indicating whether the user’s location is currently being updated. (read-only) */
+@property (nonatomic, readonly, getter=isUpdating) BOOL updating; // FIXME
+
+/** The heading of the user location. (read-only)
+*
+* This property is `nil` if the user location tracking mode is not `RMUserTrackingModeFollowWithHeading`. */
+@property (nonatomic, readonly) CLHeading *heading;
+
+@property (nonatomic, copy) NSString *title;
+
+@property (nonatomic, copy) NSString *subtitle;
+
+@end
diff --git a/include/mbgl/ios/MapboxGL.h b/include/mbgl/ios/MapboxGL.h
new file mode 100644
index 0000000000..c32915bc76
--- /dev/null
+++ b/include/mbgl/ios/MapboxGL.h
@@ -0,0 +1,4 @@
+#import "MGLAnnotation.h"
+#import "MGLMapView.h"
+#import "MGLTypes.h"
+#import "MGLUserLocation.h"
diff --git a/include/mbgl/map/annotation.hpp b/include/mbgl/map/annotation.hpp
index e88d98b5c6..efd91d9087 100644
--- a/include/mbgl/map/annotation.hpp
+++ b/include/mbgl/map/annotation.hpp
@@ -2,7 +2,6 @@
#define MBGL_MAP_ANNOTATIONS
#include <mbgl/map/tile.hpp>
-#include <mbgl/map/live_tile.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/std.hpp>
@@ -10,63 +9,47 @@
#include <string>
#include <vector>
-#include <map>
#include <mutex>
#include <memory>
+#include <unordered_map>
+#include <unordered_set>
namespace mbgl {
class Annotation;
class Map;
+class LiveTile;
-typedef std::vector<LatLng> AnnotationSegment;
-
-enum class AnnotationType : uint8_t {
- Point,
- Shape
-};
+using AnnotationIDs = std::vector<uint32_t>;
class AnnotationManager : private util::noncopyable {
public:
AnnotationManager();
+ ~AnnotationManager();
+
+ void setDefaultPointAnnotationSymbol(const std::string& symbol);
+ std::pair<std::vector<Tile::ID>, AnnotationIDs> addPointAnnotations(
+ const std::vector<LatLng>&, const std::vector<std::string>& symbols, const Map&);
+ std::vector<Tile::ID> removeAnnotations(const AnnotationIDs&, const Map&);
+ AnnotationIDs getAnnotationsInBounds(const LatLngBounds&, const Map&) const;
+ LatLngBounds getBoundsForAnnotations(const AnnotationIDs&) const;
- void setDefaultPointAnnotationSymbol(std::string& symbol) { defaultPointAnnotationSymbol = symbol; }
- std::pair<std::vector<Tile::ID>, std::vector<uint32_t>> addPointAnnotations(std::vector<LatLng>, std::vector<std::string>& symbols, const Map&);
- std::vector<Tile::ID> removeAnnotations(std::vector<uint32_t>);
- std::vector<uint32_t> getAnnotationsInBounds(LatLngBounds, const Map&) const;
- LatLngBounds getBoundsForAnnotations(std::vector<uint32_t>) const;
+ const LiveTile* getTile(Tile::ID const& id);
- const std::unique_ptr<LiveTile>& getTile(Tile::ID const& id);
+ static const std::string layerID;
private:
- uint32_t nextID() { return nextID_++; }
- static vec2<double> projectPoint(LatLng& point);
+ inline uint32_t nextID();
+ static vec2<double> projectPoint(const LatLng& point);
private:
- std::mutex mtx;
+ mutable std::mutex mtx;
std::string defaultPointAnnotationSymbol;
- std::map<uint32_t, std::unique_ptr<Annotation>> annotations;
- std::map<Tile::ID, std::pair<std::vector<uint32_t>, std::unique_ptr<LiveTile>>> annotationTiles;
- std::unique_ptr<LiveTile> nullTile;
+ std::unordered_map<uint32_t, std::unique_ptr<Annotation>> annotations;
+ std::unordered_map<Tile::ID, std::pair<std::unordered_set<uint32_t>, std::unique_ptr<LiveTile>>, Tile::ID::Hash> tiles;
uint32_t nextID_ = 0;
};
-class Annotation : private util::noncopyable {
- friend class AnnotationManager;
-public:
- Annotation(AnnotationType, std::vector<AnnotationSegment>);
-
-private:
- LatLng getPoint() const;
- LatLngBounds getBounds() const { return bounds; }
-
-private:
- const AnnotationType type = AnnotationType::Point;
- const std::vector<AnnotationSegment> geometry;
- std::map<Tile::ID, std::vector<std::weak_ptr<const LiveTileFeature>>> tileFeatures;
- LatLngBounds bounds;
-};
-
}
#endif
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 86c89f769d..cb93916284 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -37,7 +37,9 @@ class GlyphAtlas;
class SpriteAtlas;
class LineAtlas;
class Environment;
+class EnvironmentScope;
class AnnotationManager;
+class MapData;
class Map : private util::noncopyable {
friend class View;
@@ -74,7 +76,15 @@ public:
void render();
// Notifies the Map thread that the state has changed and an update might be necessary.
- void triggerUpdate();
+ using UpdateType = uint32_t;
+ enum class Update : UpdateType {
+ Nothing = 0,
+ StyleInfo = 1 << 0,
+ Debug = 1 << 1,
+ DefaultTransitionDuration = 1 << 2,
+ Classes = 1 << 3,
+ };
+ void triggerUpdate(Update = Update::Nothing);
// Triggers a render. Can be called from any thread.
void triggerRender();
@@ -91,8 +101,8 @@ public:
void setDefaultTransitionDuration(std::chrono::steady_clock::duration duration = std::chrono::steady_clock::duration::zero());
std::chrono::steady_clock::duration getDefaultTransitionDuration();
- void setStyleURL(const std::string &url);
- void setStyleJSON(std::string newStyleJSON, const std::string &base = "");
+ void setStyleURL(const std::string& url);
+ void setStyleJSON(const std::string& json, const std::string& base = "");
std::string getStyleJSON() const;
// Transition
@@ -130,7 +140,7 @@ public:
// API
void setAccessToken(const std::string &token);
- const std::string &getAccessToken() const;
+ std::string getAccessToken() const;
// Projection
inline void getWorldBoundsMeters(ProjectedMeters &sw, ProjectedMeters &ne) const { Projection::getWorldBoundsMeters(sw, ne); }
@@ -142,13 +152,15 @@ public:
inline const LatLng latLngForPixel(const vec2<double> pixel) const { return state.latLngForPixel(pixel); }
// Annotations
- void setDefaultPointAnnotationSymbol(std::string&);
- uint32_t addPointAnnotation(LatLng, std::string& symbol);
- std::vector<uint32_t> addPointAnnotations(std::vector<LatLng>, std::vector<std::string>& symbols);
+ void setDefaultPointAnnotationSymbol(const std::string&);
+ double getTopOffsetPixelsForAnnotationSymbol(const std::string&);
+ uint32_t addPointAnnotation(const LatLng&, const std::string& symbol);
+ std::vector<uint32_t> addPointAnnotations(const std::vector<LatLng>&,
+ const std::vector<std::string>& symbols);
void removeAnnotation(uint32_t);
- void removeAnnotations(std::vector<uint32_t>);
- std::vector<uint32_t> getAnnotationsInBounds(LatLngBounds) const;
- LatLngBounds getBoundsForAnnotations(std::vector<uint32_t>) const;
+ void removeAnnotations(const std::vector<uint32_t>&);
+ std::vector<uint32_t> getAnnotationsInBounds(const LatLngBounds&) const;
+ LatLngBounds getBoundsForAnnotations(const std::vector<uint32_t>&) const;
// Debug
void setDebug(bool value);
@@ -156,7 +168,7 @@ public:
bool getDebug() const;
inline const TransformState &getState() const { return state; }
- inline std::chrono::steady_clock::time_point getTime() const { return animationTime; }
+ std::chrono::steady_clock::time_point getTime() const;
inline AnnotationManager& getAnnotationManager() const { return *annotationManager; }
private:
@@ -177,11 +189,18 @@ private:
void updateSources();
void updateSources(const util::ptr<StyleLayerGroup> &group);
+ // Triggered by triggerUpdate();
+ void update();
+
+ // Loads the style set in the data object. Called by Update::StyleInfo
+ void reloadStyle();
+ void loadStyleJSON(const std::string& json, const std::string& base);
+
// Prepares a map render by updating the tiles we need for the current view, as well as updating
// the stylesheet.
void prepare();
- void updateAnnotationTiles(std::vector<Tile::ID>&);
+ void updateAnnotationTiles(const std::vector<Tile::ID>&);
enum class Mode : uint8_t {
None, // we're not doing any processing
@@ -192,6 +211,7 @@ private:
Mode mode = Mode::None;
const std::unique_ptr<Environment> env;
+ std::unique_ptr<EnvironmentScope> scope;
View &view;
private:
@@ -223,26 +243,20 @@ private:
FileSource& fileSource;
util::ptr<Style> style;
- const std::unique_ptr<GlyphAtlas> glyphAtlas;
+ std::unique_ptr<GlyphAtlas> glyphAtlas;
util::ptr<GlyphStore> glyphStore;
- const std::unique_ptr<SpriteAtlas> spriteAtlas;
+ std::unique_ptr<SpriteAtlas> spriteAtlas;
util::ptr<Sprite> sprite;
- const std::unique_ptr<LineAtlas> lineAtlas;
+ std::unique_ptr<LineAtlas> lineAtlas;
util::ptr<TexturePool> texturePool;
- const std::unique_ptr<Painter> painter;
- util::ptr<AnnotationManager> annotationManager;
+ std::unique_ptr<Painter> painter;
+ std::unique_ptr<AnnotationManager> annotationManager;
- std::string styleURL;
- std::string styleJSON = "";
- std::vector<std::string> classes;
- std::string accessToken;
-
- std::chrono::steady_clock::duration defaultTransitionDuration;
-
- bool debug = false;
- std::chrono::steady_clock::time_point animationTime = std::chrono::steady_clock::time_point::min();
+ const std::unique_ptr<MapData> data;
std::set<util::ptr<StyleSource>> activeSources;
+
+ std::atomic<UpdateType> updated;
};
}
diff --git a/include/mbgl/map/tile.hpp b/include/mbgl/map/tile.hpp
index bdb127030b..146ebe6ad7 100644
--- a/include/mbgl/map/tile.hpp
+++ b/include/mbgl/map/tile.hpp
@@ -12,6 +12,7 @@
#include <forward_list>
#include <iosfwd>
#include <string>
+#include <functional>
namespace mbgl {
@@ -44,6 +45,12 @@ public:
return ((std::pow(2, z) * y + x) * 32) + z;
}
+ struct Hash {
+ std::size_t operator()(ID const& i) const {
+ return std::hash<uint64_t>()(i.to_uint64());
+ }
+ };
+
inline bool operator==(const ID& rhs) const {
return w == rhs.w && z == rhs.z && x == rhs.x && y == rhs.y;
}
diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp
index 1ee9d300c5..bcfeb62cfc 100644
--- a/include/mbgl/map/view.hpp
+++ b/include/mbgl/map/view.hpp
@@ -10,14 +10,15 @@ class Map;
enum MapChange : uint8_t {
MapChangeRegionWillChange = 0,
MapChangeRegionWillChangeAnimated = 1,
- MapChangeRegionDidChange = 2,
- MapChangeRegionDidChangeAnimated = 3,
- MapChangeWillStartLoadingMap = 4,
- MapChangeDidFinishLoadingMap = 5,
- MapChangeDidFailLoadingMap = 6,
- MapChangeWillStartRenderingMap = 7,
- MapChangeDidFinishRenderingMap = 8,
- MapChangeDidFinishRenderingMapFullyRendered = 9
+ MapChangeRegionIsChanging = 2,
+ MapChangeRegionDidChange = 3,
+ MapChangeRegionDidChangeAnimated = 4,
+ MapChangeWillStartLoadingMap = 5,
+ MapChangeDidFinishLoadingMap = 6,
+ MapChangeDidFailLoadingMap = 7,
+ MapChangeWillStartRenderingMap = 8,
+ MapChangeDidFinishRenderingMap = 9,
+ MapChangeDidFinishRenderingMapFullyRendered = 10
};
class View {
diff --git a/include/mbgl/platform/darwin/settings_nsuserdefaults.hpp b/include/mbgl/platform/darwin/settings_nsuserdefaults.hpp
index 3533e3da35..6c91fd3029 100644
--- a/include/mbgl/platform/darwin/settings_nsuserdefaults.hpp
+++ b/include/mbgl/platform/darwin/settings_nsuserdefaults.hpp
@@ -1,6 +1,8 @@
#ifndef MBGL_COMMON_SETTINGS_NSUSERDEFAULTS
#define MBGL_COMMON_SETTINGS_NSUSERDEFAULTS
+#import <mbgl/ios/MGLTypes.h>
+
namespace mbgl {
class Settings_NSUserDefaults {
@@ -16,6 +18,9 @@ public:
double zoom = 0;
double bearing = 0;
+ MGLUserTrackingMode userTrackingMode = MGLUserTrackingModeNone;
+ bool showsUserLocation = false;
+
bool debug = false;
};
diff --git a/include/mbgl/util/constants.hpp b/include/mbgl/util/constants.hpp
index 9e0856b68a..e598806c20 100644
--- a/include/mbgl/util/constants.hpp
+++ b/include/mbgl/util/constants.hpp
@@ -16,8 +16,6 @@ extern const double M2PI;
extern const double EARTH_RADIUS_M;
extern const double LATITUDE_MAX;
-extern const std::string ANNOTATIONS_POINTS_LAYER_ID;
-
}
namespace debug {
diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp
index b99a6e6614..6ece6d4de9 100644
--- a/include/mbgl/util/geo.hpp
+++ b/include/mbgl/util/geo.hpp
@@ -32,6 +32,13 @@ struct LatLngBounds {
if (point.longitude < sw.longitude) sw.longitude = point.longitude;
if (point.longitude > ne.longitude) ne.longitude = point.longitude;
}
+
+ inline bool contains(const LatLng& point) {
+ return (point.latitude >= sw.latitude &&
+ point.latitude <= ne.latitude &&
+ point.longitude >= sw.longitude &&
+ point.longitude <= ne.longitude);
+ }
};
}