summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-03-10 14:27:21 -0800
committerMinh Nguyễn <mxn@1ec5.org>2017-03-10 15:08:00 -0800
commitb74d7bfdb48d2a1a301945a02e41c422c0198456 (patch)
tree9e8c528787e75cc286d5cbb62cc2ae444c46c22d /platform
parentffce46cae6cdc3a4b952a0aeca80b5d5f7304b6d (diff)
downloadqtlocation-mapboxgl-b74d7bfdb48d2a1a301945a02e41c422c0198456.tar.gz
[ios, macos] Corrected polyline equality
Now that annotation classes override -isEqual:, it’s no longer appropriate to rely on -isEqual: or -containsObject: to check for the preexistence of an annotation. Those methods become deep equality tests, which have worse performance. Checking for identity allows the developer to add a polyline and polygon with identical coordinates, title, etc. to the map. Implemented a missing -[MGLPolyline isEqual:]. Removed outdated comments about -annotationTagForAnnotation: being expensive.
Diffstat (limited to 'platform')
-rw-r--r--platform/darwin/src/MGLPolyline.mm4
-rw-r--r--platform/ios/CHANGELOG.md1
-rw-r--r--platform/ios/src/MGLMapView.mm4
-rw-r--r--platform/macos/CHANGELOG.md1
-rw-r--r--platform/macos/src/MGLMapView.mm5
5 files changed, 10 insertions, 5 deletions
diff --git a/platform/darwin/src/MGLPolyline.mm b/platform/darwin/src/MGLPolyline.mm
index 454a1b964b..ae4fbe61de 100644
--- a/platform/darwin/src/MGLPolyline.mm
+++ b/platform/darwin/src/MGLPolyline.mm
@@ -48,6 +48,10 @@
@"coordinates": self.mgl_coordinates};
}
+- (BOOL)isEqual:(id)other {
+ return self == other || ([other isKindOfClass:[MGLPolyline class]] && [super isEqual:other]);
+}
+
@end
@interface MGLMultiPolyline ()
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index 7ddb503543..6ffad0af16 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -45,6 +45,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Added a method to MGLMapViewDelegate, `-mapView:shouldChangeFromCamera:toCamera:`, that you can implement to restrict which parts the user can navigate to using gestures. ([#5584](https://github.com/mapbox/mapbox-gl-native/pull/5584))
* Annotations are no longer deselected when the map is panned or zoomed, even if the annotation moves out of the visible bounds. ([#8022](https://github.com/mapbox/mapbox-gl-native/pull/8022))
* Changing the coordinates of a point annotation no longer deselects the annotation. ([#8269](https://github.com/mapbox/mapbox-gl-native/pull/8269))
+* Fixed an issue preventing MGLMapView from adding a polyline annotation with the same coordinates as a polygon annotation. ([#8355](https://github.com/mapbox/mapbox-gl-native/pull/8355))
* Fixed an issue where translucent, non-view-backed point annotations along tile boundaries would be drawn darker than expected. ([#6832](https://github.com/mapbox/mapbox-gl-native/pull/6832))
* Double-tap and two-finger tap gestures now zoom to the nearest integer zoom level. ([#8027](https://github.com/mapbox/mapbox-gl-native/pull/8027))
* The `MGLAnnotationView.annotation` property is now read-write. ([#8139](https://github.com/mapbox/mapbox-gl-native/pull/8139))
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 8872261a88..2333df5c9a 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -3068,7 +3068,7 @@ public:
return annotationContext.annotation;
}
-/// Returns the annotation tag assigned to the given annotation. Relatively expensive.
+/// Returns the annotation tag assigned to the given annotation.
- (MGLAnnotationTag)annotationTagForAnnotation:(id <MGLAnnotation>)annotation
{
if ( ! annotation || annotation == self.userLocation
@@ -3108,7 +3108,7 @@ public:
NSAssert([annotation conformsToProtocol:@protocol(MGLAnnotation)], @"annotation should conform to MGLAnnotation");
// adding the same annotation object twice is a no-op
- if ([self.annotations containsObject:annotation])
+ if (_annotationTagsByAnnotation.count(annotation) != 0)
{
continue;
}
diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md
index 7c00f14be7..82cc67e8fe 100644
--- a/platform/macos/CHANGELOG.md
+++ b/platform/macos/CHANGELOG.md
@@ -37,6 +37,7 @@
* Added a method to MGLMapViewDelegate, `-mapView:shouldChangeFromCamera:toCamera:`, that you can implement to restrict which parts the user can navigate to using gestures. ([#5584](https://github.com/mapbox/mapbox-gl-native/pull/5584))
* When a map view is the first responder, pressing <kbd>+</kbd>, <kbd>-</kbd>, or <kbd>=</kbd> now zooms the map. ([#8033](https://github.com/mapbox/mapbox-gl-native/pull/8033))
* Changing the coordinates of a point annotation no longer deselects the annotation. ([#8269](https://github.com/mapbox/mapbox-gl-native/pull/8269))
+* Fixed an issue preventing MGLMapView from adding a polyline annotation with the same coordinates as a polygon annotation. ([#8355](https://github.com/mapbox/mapbox-gl-native/pull/8355))
* Zooming by double-tap, two-finger tap, zoom buttons, shortcut keys, or demo app menu items or shortcut keys now zooms to the nearest integer zoom level. ([#8027](https://github.com/mapbox/mapbox-gl-native/pull/8027))
* Fixed an issue where translucent point annotations along tile boundaries would be drawn darker than expected. ([#6832](https://github.com/mapbox/mapbox-gl-native/pull/6832))
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 68f36e044b..e72a755f51 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -1820,7 +1820,7 @@ public:
return annotationContext.annotation;
}
-/// Returns the annotation tag assigned to the given annotation. Relatively expensive.
+/// Returns the annotation tag assigned to the given annotation.
- (MGLAnnotationTag)annotationTagForAnnotation:(id <MGLAnnotation>)annotation {
if (!annotation || _annotationTagsByAnnotation.count(annotation) == 0) {
return MGLAnnotationTagNotFound;
@@ -1848,8 +1848,7 @@ public:
NSAssert([annotation conformsToProtocol:@protocol(MGLAnnotation)], @"Annotation does not conform to MGLAnnotation");
// adding the same annotation object twice is a no-op
- if ([self.annotations containsObject:annotation])
- {
+ if (_annotationTagsByAnnotation.count(annotation) != 0) {
continue;
}