Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[not ready] Cocoa annotations API #1037

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
01be9dc
bump
incanus Mar 20, 2015
4de2687
include MGLAnnotation protocol
incanus Mar 20, 2015
9ef49d0
basic stub of annotation add/remove
incanus Mar 20, 2015
0b8ef72
fix typo
incanus Mar 20, 2015
a528866
more stubbing
incanus Mar 20, 2015
b99aabf
use a strong, but not copying, map table to key on annotation models
incanus Mar 20, 2015
53d4813
hook up Cocoa to C++
incanus Mar 20, 2015
b90d771
defer to delegate for annotation symbols
incanus Mar 20, 2015
75cba45
annotations don't need to be copied; adjust parameter name; default s…
incanus Mar 20, 2015
00b587f
bring over C++ fix; rename section
incanus Mar 20, 2015
b0aadc8
be more explicit about styles & versions since related to sprite
incanus Mar 21, 2015
9a39131
stub selection routines
incanus Mar 21, 2015
63168dc
Merge branch 'master' into cocoa-annotations-api
incanus Mar 21, 2015
ff3cf65
Merge branch 'cocoa-annotations-api' of github.com:mapbox/mapbox-gl-n…
incanus Mar 21, 2015
4b21aa7
mock out basic annotation selection matching MapKit behavior
incanus Mar 21, 2015
9f669b9
hold weak reference to selected annotation
incanus Mar 22, 2015
10d7133
set a default marker symbol for the default style
incanus Mar 22, 2015
36444c1
annotation selection/deselection/nearby cycling with tap gesture
incanus Mar 22, 2015
4cf4e2e
ensure delegate provides symbol name before pushing
incanus Mar 22, 2015
5144d49
return nil for no annotations like MapKit does
incanus Mar 22, 2015
0a5e02d
annotation header docs & script updates
incanus Mar 22, 2015
70fd83f
header should include CL for CLLocationCoordinate2D
incanus Mar 22, 2015
1a7368c
fix signed/unsigned comparison
incanus Mar 22, 2015
ade08ee
add conversions, viewport bounds, and don't allow selection of offscr…
incanus Mar 22, 2015
0af36ae
remove accidental comments
incanus Mar 22, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gyp/platform-ios.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'../platform/darwin/reachability.m',
'../include/mbgl/ios/MGLMapView.h',
'../platform/ios/MGLMapView.mm',
'../include/mbgl/ios/MGLAnnotation.h',
'../include/mbgl/ios/MGLStyleFunctionValue.h',
'../platform/ios/MGLStyleFunctionValue.m',
'../include/mbgl/ios/MGLTypes.h',
Expand Down
28 changes: 28 additions & 0 deletions include/mbgl/ios/MGLAnnotation.h
Original file line number Diff line number Diff line change
@@ -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
60 changes: 59 additions & 1 deletion include/mbgl/ios/MGLMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#import <CoreLocation/CoreLocation.h>

@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.
*
Expand Down Expand Up @@ -184,6 +185,55 @@
* @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 - Debugging

/** @name Debugging */
Expand All @@ -201,11 +251,19 @@

@end

// TODO
/** 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

/** @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;

// Responding to Map Position Changes

// TODO
Expand Down
7 changes: 7 additions & 0 deletions include/mbgl/util/geo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

}
Expand Down
2 changes: 1 addition & 1 deletion ios/app/MBXViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ - (void)dealloc
}
}

#pragma mark - Location
#pragma mark - CLLocationManagerDelegate

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
Expand Down
10 changes: 2 additions & 8 deletions ios/docs/install_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [ -z `which appledoc` ]; then
exit 1
fi

VERSION=$( git tag | sort -r | sed -n '1p' )
VERSION=$( git tag | grep ^[0-9] | sort -r | sed -n '1p' )
echo "Creating new docs for $VERSION..."
echo

Expand All @@ -15,10 +15,4 @@ appledoc \
--project-company Mapbox \
--create-docset \
--company-id com.mapbox \
--ignore app \
--ignore dist \
--ignore pkg \
--ignore test \
--ignore .m \
--ignore .mm \
.
../../include/mbgl/ios
2 changes: 1 addition & 1 deletion ios/docs/remove_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ echo
echo "Removing docs from ~/Library/Developer/Shared/Documentation/DocSets..."
echo

rm -rfv ~/Library/Developer/Shared/Documentation/DocSets/com.mapbox.Mapbox-GL-*
rm -rfv ~/Library/Developer/Shared/Documentation/DocSets/com.mapbox.Mapbox-GL-*
Loading