From 1f1cc131ea869eae57209bcc6ba74ddb3af14579 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Soto Date: Fri, 3 Mar 2017 20:11:06 -0500 Subject: [ios] Fixed conversion between Duration and NSTimeInerval (#8276) --- platform/macos/src/MGLMapView.mm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'platform/macos/src') diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 827da35076..d70b5c0f03 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -980,7 +980,7 @@ public: [self willChangeValueForKey:@"centerCoordinate"]; _mbglMap->setLatLng(MGLLatLngFromLocationCoordinate2D(centerCoordinate), MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets), - MGLDurationInSecondsFromTimeInterval(animated ? MGLAnimationDuration : 0)); + MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0)); [self didChangeValueForKey:@"centerCoordinate"]; } @@ -989,7 +989,7 @@ public: _mbglMap->cancelTransitions(); MGLMapCamera *oldCamera = self.camera; _mbglMap->moveBy({ delta.x, delta.y }, - MGLDurationInSecondsFromTimeInterval(animated ? MGLAnimationDuration : 0)); + MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0)); if ([self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)] && ![self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:self.camera]) { self.camera = oldCamera; @@ -1029,7 +1029,7 @@ public: [self willChangeValueForKey:@"zoomLevel"]; _mbglMap->setZoom(zoomLevel, MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets), - MGLDurationInSecondsFromTimeInterval(animated ? MGLAnimationDuration : 0)); + MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0)); [self didChangeValueForKey:@"zoomLevel"]; } @@ -1043,7 +1043,7 @@ public: double newZoom = round(self.zoomLevel) + zoomDelta; MGLMapCamera *oldCamera = self.camera; mbgl::ScreenCoordinate center(point.x, self.bounds.size.height - point.y); - _mbglMap->setZoom(newZoom, center, MGLDurationInSecondsFromTimeInterval(animated ? MGLAnimationDuration : 0)); + _mbglMap->setZoom(newZoom, center, MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0)); if ([self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)] && ![self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:self.camera]) { self.camera = oldCamera; @@ -1057,7 +1057,7 @@ public: [self willChangeValueForKey:@"zoomLevel"]; MGLMapCamera *oldCamera = self.camera; mbgl::ScreenCoordinate center(point.x, self.bounds.size.height - point.y); - _mbglMap->scaleBy(scaleFactor, center, MGLDurationInSecondsFromTimeInterval(animated ? MGLAnimationDuration : 0)); + _mbglMap->scaleBy(scaleFactor, center, MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0)); if ([self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)] && ![self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:self.camera]) { self.camera = oldCamera; @@ -1118,7 +1118,7 @@ public: [self willChangeValueForKey:@"direction"]; _mbglMap->setBearing(direction, MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets), - MGLDurationInSecondsFromTimeInterval(animated ? MGLAnimationDuration : 0)); + MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0)); [self didChangeValueForKey:@"direction"]; } @@ -1146,7 +1146,7 @@ public: - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion { mbgl::AnimationOptions animationOptions; if (duration > 0) { - animationOptions.duration.emplace(MGLDurationInSecondsFromTimeInterval(duration)); + animationOptions.duration.emplace(MGLDurationFromTimeInterval(duration)); animationOptions.easing.emplace(MGLUnitBezierForMediaTimingFunction(function)); } if (completion) { @@ -1187,7 +1187,7 @@ public: - (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration peakAltitude:(CLLocationDistance)peakAltitude completionHandler:(nullable void (^)(void))completion { mbgl::AnimationOptions animationOptions; if (duration >= 0) { - animationOptions.duration = MGLDurationInSecondsFromTimeInterval(duration); + animationOptions.duration = MGLDurationFromTimeInterval(duration); } if (peakAltitude >= 0) { CLLocationDegrees peakLatitude = (self.centerCoordinate.latitude + camera.centerCoordinate.latitude) / 2; @@ -1264,7 +1264,7 @@ public: mbgl::CameraOptions cameraOptions = _mbglMap->cameraForLatLngBounds(MGLLatLngBoundsFromCoordinateBounds(bounds), padding); mbgl::AnimationOptions animationOptions; if (animated) { - animationOptions.duration = MGLDurationInSecondsFromTimeInterval(MGLAnimationDuration); + animationOptions.duration = MGLDurationFromTimeInterval(MGLAnimationDuration); } MGLMapCamera *camera = [self cameraForCameraOptions:cameraOptions]; -- cgit v1.2.1 From 7e9701283f96bfcce3a56a3af4c8fe9154f02b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 2 Mar 2017 23:52:14 -0800 Subject: [ios, macos] Update callout when relocating annotation When relocating a selected point annotation, update the associated callout (popover) rather than deselecting the annotation. --- platform/macos/src/MGLMapView.mm | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'platform/macos/src') diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index d70b5c0f03..3e76fa9ad0 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -538,9 +538,7 @@ public: const mbgl::Point point = MGLPointFromLocationCoordinate2D(annotation.coordinate); MGLAnnotationImage *annotationImage = [self imageOfAnnotationWithTag:annotationTag]; _mbglMap->updateAnnotation(annotationTag, mbgl::SymbolAnnotation { point, annotationImage.styleIconIdentifier.UTF8String ?: "" }); - if (annotationTag == _selectedAnnotationTag) { - [self deselectAnnotation:annotation]; - } + [self updateAnnotationCallouts]; } } else if ([keyPath isEqualToString:@"coordinates"] && [object isKindOfClass:[MGLMultiPoint class]]) { @@ -554,12 +552,7 @@ public: // but safely updated. if (annotation == [self annotationWithTag:annotationTag]) { _mbglMap->updateAnnotation(annotationTag, [annotation annotationObjectWithDelegate:self]); - // We don't current support shape multipoint annotation selection, but let's make sure - // deselection is handled just to avoid problems in the future. - if (annotationTag == _selectedAnnotationTag) - { - [self deselectAnnotation:annotation]; - } + [self updateAnnotationCallouts]; } } } -- cgit v1.2.1 From ece19acd10a09922a3106872c720b00089bf4b5b Mon Sep 17 00:00:00 2001 From: Jordan Kiley Date: Tue, 7 Mar 2017 17:39:42 -0800 Subject: [ios, macos] Added a timing note for two delegate methods (#8259) --- platform/macos/src/MGLMapViewDelegate.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'platform/macos/src') diff --git a/platform/macos/src/MGLMapViewDelegate.h b/platform/macos/src/MGLMapViewDelegate.h index 08a9f7eff4..dae5b40286 100644 --- a/platform/macos/src/MGLMapViewDelegate.h +++ b/platform/macos/src/MGLMapViewDelegate.h @@ -40,10 +40,12 @@ NS_ASSUME_NONNULL_BEGIN This method is called as the currently displayed map camera changes as part of an animation, whether due to a user gesture or due to a call to a method such - as `-[MGLMapView setCamera:animated:]`. During the animation, 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. + as `-[MGLMapView setCamera:animated:]`. This method can be called before + `-mapViewDidFinishLoadingMap:` is called. + + During the animation, 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. */ @@ -55,7 +57,9 @@ NS_ASSUME_NONNULL_BEGIN This method is called whenever the currently displayed map camera has finished changing, after any calls to `-mapViewRegionIsChanging:` due to animation. - + This method can be called before `-mapViewDidFinishLoadingMap:` is + called. + @param mapView The map view whose viewpoint has changed. @param animated Whether the change caused an animated effect on the map. */ -- cgit v1.2.1 From b74d7bfdb48d2a1a301945a02e41c422c0198456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Fri, 10 Mar 2017 14:27:21 -0800 Subject: [ios, macos] Corrected polyline equality MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- platform/macos/src/MGLMapView.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'platform/macos/src') 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 )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; } -- cgit v1.2.1 From 936cc33d5291a77bc4e0dda9c7956860bef5f872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 12 Mar 2017 15:43:33 -0700 Subject: [ios, macos] Resolved unused variable warnings Resolved unused variable warnings in Release configuration that occurred because they were only used within NSAssert() invocations, which are omitted from Release builds. --- platform/macos/src/MGLMapView.mm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'platform/macos/src') diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index e72a755f51..8711950554 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -2419,9 +2419,11 @@ public: - (void)addOverlays:(NS_ARRAY_OF(id ) *)overlays { +#if DEBUG for (id overlay in overlays) { NSAssert([overlay conformsToProtocol:@protocol(MGLOverlay)], @"Overlay does not conform to MGLOverlay"); } +#endif [self addAnnotations:overlays]; } @@ -2430,9 +2432,11 @@ public: } - (void)removeOverlays:(NS_ARRAY_OF(id ) *)overlays { +#if DEBUG for (id overlay in overlays) { NSAssert([overlay conformsToProtocol:@protocol(MGLOverlay)], @"Overlay does not conform to MGLOverlay"); } +#endif [self removeAnnotations:overlays]; } -- cgit v1.2.1 From 4430e656036caa6e2d9523222f0c6c630200fa45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Mon, 13 Mar 2017 17:45:37 -0700 Subject: [ios, macos] Expanded feature querying documentation Also fixed a couple incorrect Swift method names on macOS. --- platform/macos/src/MGLMapView.h | 105 +++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 51 deletions(-) (limited to 'platform/macos/src') diff --git a/platform/macos/src/MGLMapView.h b/platform/macos/src/MGLMapView.h index fa07821e19..fb715a506d 100644 --- a/platform/macos/src/MGLMapView.h +++ b/platform/macos/src/MGLMapView.h @@ -783,24 +783,17 @@ MGL_EXPORT IB_DESIGNABLE @return An array of objects conforming to the `MGLFeature` protocol that represent features in the sources used by the current style. */ -- (NS_ARRAY_OF(id ) *)visibleFeaturesAtPoint:(NSPoint)point NS_SWIFT_NAME(visibleFeatures(_:)); +- (NS_ARRAY_OF(id ) *)visibleFeaturesAtPoint:(NSPoint)point NS_SWIFT_NAME(visibleFeatures(at:)); /** Returns an array of rendered map features that intersect with a given point, restricted to the given style layers. - This method may return all features from the specified layers. To filter - the returned features, use the - `-visibleFeaturesAtPoint:inStyleLayersWithIdentifiers:predicate:` method. For more - information about searching for map features, see that method’s documentation. - - @note Layer identifiers are not guaranteed to exist across styles or different - versions of the same style. Applications that use this API must first set the - style URL to an explicitly versioned style using a convenience method like - `+[MGLStyle outdoorsStyleURLWithVersion:]`, `MGLMapView`’s “Style URL” - inspectable in Interface Builder, or a manually constructed `NSURL`. This - approach also avoids layer identifer name changes that will occur in the default - style’s layers over time. + This method returns all the intersecting features from the specified layers. To + filter the returned features, use the + `-visibleFeaturesAtPoint:inStyleLayersWithIdentifiers:predicate:` method. For + more information about searching for map features, see that method’s + documentation. @param point A point expressed in the map view’s coordinate system. @param styleLayerIdentifiers A set of strings that correspond to the names of @@ -813,17 +806,17 @@ MGL_EXPORT IB_DESIGNABLE /** Returns an array of rendered map features that intersect with a given point, - restricted to the given style layers and filtered by the given - predicate. + restricted to the given style layers and filtered by the given predicate. Each object in the returned array represents a feature rendered by the - current style and provides access to attributes specified by the relevant - tile sources. - The returned array includes features specified in vector and GeoJSON tile - sources but does not include anything from raster, image, or video sources. - - Only visible features are returned. For example, suppose the current style uses - the + current style and provides access to attributes specified by the relevant map + content sources. The returned array includes features loaded by + `MGLShapeSource` and `MGLVectorSource` objects but does not include anything + from `MGLRasterSource` objects, or from image, video, or canvas sources, which + are unsupported by this SDK. + + The returned features are drawn by a style layer in the current style. For + example, suppose the current style uses the Mapbox Streets source, but none of the specified style layers includes features that have the `maki` property set to `bus`. If you pass a point corresponding to the location of a @@ -849,22 +842,27 @@ MGL_EXPORT IB_DESIGNABLE To find out the layer names in a particular style, view the style in Mapbox Studio. + + Only visible features are returned. To obtain features regardless of + visibility, use the + `-[MGLVectorSource featuresInSourceLayersWithIdentifiers:predicate:]` and + `-[MGLShapeSource featuresMatchingPredicate:]` methods on the relevant sources. @note Layer identifiers are not guaranteed to exist across styles or different - versions of the same style. Applications that use this API must first set the - style URL to an explicitly versioned style using a convenience method like - `+[MGLStyle outdoorsStyleURLWithVersion:]`, `MGLMapView`’s “Style URL” - inspectable in Interface Builder, or a manually constructed `NSURL`. This - approach also avoids layer identifer name changes that will occur in the default - style’s layers over time. + versions of the same style. Applications that use this API must first set + the style URL to an explicitly versioned style using a convenience method + like `+[MGLStyle outdoorsStyleURLWithVersion:]`, `MGLMapView`’s “Style URL” + inspectable in Interface Builder, or a manually constructed `NSURL`. This + approach also avoids layer identifer name changes that will occur in the + default style’s layers over time. @param point A point expressed in the map view’s coordinate system. @param styleLayerIdentifiers A set of strings that correspond to the names of - layers defined in the current style. Only the features contained in these - layers are included in the returned array. + layers defined in the current style. Only the features contained in these + layers are included in the returned array. @param predicate A predicate to filter the returned features. @return An array of objects conforming to the `MGLFeature` protocol that - represent features in the sources used by the current style. + represent features in the sources used by the current style. */ - (NS_ARRAY_OF(id ) *)visibleFeaturesAtPoint:(NSPoint)point inStyleLayersWithIdentifiers:(nullable NS_SET_OF(NSString *) *)styleLayerIdentifiers predicate:(nullable NSPredicate *)predicate NS_SWIFT_NAME(visibleFeatures(at:styleLayerIdentifiers:predicate:)); @@ -881,14 +879,14 @@ MGL_EXPORT IB_DESIGNABLE @return An array of objects conforming to the `MGLFeature` protocol that represent features in the sources used by the current style. */ -- (NS_ARRAY_OF(id ) *)visibleFeaturesInRect:(NSRect)rect NS_SWIFT_NAME(visibleFeatures(_:)); +- (NS_ARRAY_OF(id ) *)visibleFeaturesInRect:(NSRect)rect NS_SWIFT_NAME(visibleFeatures(in:)); /** Returns an array of rendered map features that intersect with the given rectangle, restricted to the given style layers. - This method may return all features from the specified layers. To filter - the returned features, use the + This method returns all the intersecting features from the specified layers. To + filter the returned features, use the `-visibleFeaturesAtPoint:inStyleLayersWithIdentifiers:predicate:` method. For more information about searching for map features, see that method’s documentation. @@ -906,16 +904,16 @@ MGL_EXPORT IB_DESIGNABLE Returns an array of rendered map features that intersect with the given rectangle, restricted to the given style layers and filtered by the given predicate. - Each object in the returned array represents a feature rendered by the - current style and provides access to attributes specified by the relevant - tile sources. - The returned array includes features specified in vector and GeoJSON tile - sources but does not include anything from raster, image, or video sources. - - Only visible features are returned. For example, suppose the current style uses - the + current style and provides access to attributes specified by the relevant map + content sources. The returned array includes features loaded by + `MGLShapeSource` and `MGLVectorSource` objects but does not include anything + from `MGLRasterSource` objects, or from image, video, or canvas sources, which + are unsupported by this SDK. + + The returned features are drawn by a style layer in the current style. For + example, suppose the current style uses the Mapbox Streets source, but none of the specified style layers includes features that have the `maki` property set to `bus`. If you pass a rectangle containing the location of a bus @@ -942,22 +940,27 @@ MGL_EXPORT IB_DESIGNABLE To find out the layer names in a particular style, view the style in Mapbox Studio. + + Only visible features are returned. To obtain features regardless of + visibility, use the + `-[MGLVectorSource featuresInSourceLayersWithIdentifiers:predicate:]` and + `-[MGLShapeSource featuresMatchingPredicate:]` methods on the relevant sources. @note Layer identifiers are not guaranteed to exist across styles or different - versions of the same style. Applications that use this API must first set the - style URL to an explicitly versioned style using a convenience method like - `+[MGLStyle outdoorsStyleURLWithVersion:]`, `MGLMapView`’s “Style URL” - inspectable in Interface Builder, or a manually constructed `NSURL`. This - approach also avoids layer identifer name changes that will occur in the default - style’s layers over time. + versions of the same style. Applications that use this API must first set + the style URL to an explicitly versioned style using a convenience method + like `+[MGLStyle outdoorsStyleURLWithVersion:]`, `MGLMapView`’s “Style URL” + inspectable in Interface Builder, or a manually constructed `NSURL`. This + approach also avoids layer identifer name changes that will occur in the + default style’s layers over time. @param rect A rectangle expressed in the map view’s coordinate system. @param styleLayerIdentifiers A set of strings that correspond to the names of - layers defined in the current style. Only the features contained in these - layers are included in the returned array. + layers defined in the current style. Only the features contained in these + layers are included in the returned array. @param predicate A predicate to filter the returned features. @return An array of objects conforming to the `MGLFeature` protocol that - represent features in the sources used by the current style. + represent features in the sources used by the current style. */ - (NS_ARRAY_OF(id ) *)visibleFeaturesInRect:(NSRect)rect inStyleLayersWithIdentifiers:(nullable NS_SET_OF(NSString *) *)styleLayerIdentifiers predicate:(nullable NSPredicate *)predicate NS_SWIFT_NAME(visibleFeatures(in:styleLayerIdentifiers:predicate:)); -- cgit v1.2.1