summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2017-07-18 19:11:55 -0400
committerJason Wray <jason@mapbox.com>2017-07-19 15:19:28 -0400
commitd8ce613001e4dd3f1ed06163a3f0e7c6196b446e (patch)
tree68079b014aa074f33d30f2bc94f3aee7cd19da98
parentf8057fc959b03372797c7c7d6dbce7ebc277759e (diff)
downloadqtlocation-mapboxgl-d8ce613001e4dd3f1ed06163a3f0e7c6196b446e.tar.gz
[ios] Warn about using MGLFeature-conforming annotations
-rw-r--r--platform/darwin/src/MGLFeature.h10
-rw-r--r--platform/ios/src/MGLMapView.mm5
2 files changed, 12 insertions, 3 deletions
diff --git a/platform/darwin/src/MGLFeature.h b/platform/darwin/src/MGLFeature.h
index 491c89b608..5b64995d83 100644
--- a/platform/darwin/src/MGLFeature.h
+++ b/platform/darwin/src/MGLFeature.h
@@ -18,15 +18,19 @@ NS_ASSUME_NONNULL_BEGIN
You can add custom data to display on the map by creating feature objects and
adding them to an `MGLShapeSource` using the
`-[MGLShapeSource initWithIdentifier:shape:options:]` method or
- `MGLShapeSource.shape` property. Similarly, you can add `MGLPointFeature`,
- `MGLPolylineFeature`, and `MGLPolygonFeature` objects to the map as annotations
- using `-[MGLMapView addAnnotations:]` and related methods.
+ `MGLShapeSource.shape` property.
In addition to adding data to the map, you can also extract data from the map:
`-[MGLMapView visibleFeaturesAtPoint:]` and related methods return feature
objects that correspond to features in the source. This enables you to inspect
the properties of features in vector tiles loaded by `MGLVectorSource` objects.
You also reuse these feature objects as overlay annotations.
+
+ While it is possible to add `MGLFeature`-conforming objects to the map as
+ annotations using `-[MGLMapView addAnnotations:]` and related methods, doing so
+ will convert feature objects into plain annotations. Features added as
+ annotations will not have `identifier` or `attributes` properties set and
+ should not be used be with feature querying.
*/
@protocol MGLFeature <MGLAnnotation>
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index f3b0d8506a..0be1c87201 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -3187,6 +3187,11 @@ public:
{
NSAssert([annotation conformsToProtocol:@protocol(MGLAnnotation)], @"annotation should conform to MGLAnnotation");
+ if ([annotation conformsToProtocol:@protocol(MGLFeature)])
+ {
+ NSLog(@"Warning: Annotations that conform to the MGLFeature protocol do not keep their `identifier` or `attributes` properties when added to the map as annotations. Add this feature using runtime styling if you intend to later query the map for it. %@", annotation.description);
+ }
+
// adding the same annotation object twice is a no-op
if (_annotationTagsByAnnotation.count(annotation) != 0)
{