diff options
author | Nadia Barbosa <nadiabarbosa@me.com> | 2019-09-13 12:35:47 -0700 |
---|---|---|
committer | Nadia Barbosa <captainbarbosa@users.noreply.github.com> | 2019-09-16 12:55:36 -0700 |
commit | 8331b7adfe58d27b865b41bcf926a1b65a4022d9 (patch) | |
tree | 7267e8e4ceeb31fcb821a71755ea45283ccc1a41 /platform/ios | |
parent | 40b0cb74cb9e9aae85d748f4d4ea2156cc40f4fa (diff) | |
download | qtlocation-mapboxgl-8331b7adfe58d27b865b41bcf926a1b65a4022d9.tar.gz |
[ios, macos] Introduce custom drawing overlays for MGLMapSnapshotter
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/CHANGELOG.md | 9 | ||||
-rw-r--r-- | platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m | 57 |
2 files changed, 66 insertions, 0 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 7857c6bf65..8515fd467f 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,6 +2,15 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. +## master + +### Styles and rendering +* Added an `-[MGLMapSnapshotter startWithOverlayHandler:completionHandler:]` method to provide the snapshot's current `CGContext` in order to perform custom drawing on `MGLMapSnapShot` objects. ([#15530](https://github.com/mapbox/mapbox-gl-native/pull/15530)) + +### Performance improvements + +* Newly loaded labels appear faster on the screen. ([#15308](https://github.com/mapbox/mapbox-gl-native/pull/15308)) + ## 5.4.0 ### Styles and rendering diff --git a/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m b/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m index 39646755ba..7707896203 100644 --- a/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m +++ b/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m @@ -393,5 +393,62 @@ MGLMapSnapshotter* snapshotterWithCoordinates(CLLocationCoordinate2D coordinates [self waitForExpectations:@[expectation] timeout:10.0]; } +- (void)testSnapshotWithOverlayHandlerFailure { + if (![self validAccessToken]) { + return; + } + + CGSize size = self.mapView.bounds.size; + + XCTestExpectation *expectation = [self expectationWithDescription:@"snapshot with overlay fails"]; + expectation.expectedFulfillmentCount = 2; + + CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(30.0, 30.0); + + MGLMapSnapshotter *snapshotter = snapshotterWithCoordinates(coord, size); + XCTAssertNotNil(snapshotter); + + [snapshotter startWithOverlayHandler:^(MGLMapSnapshotOverlay * _Nullable snapshotOverlay) { + UIGraphicsEndImageContext(); + [expectation fulfill]; + } completionHandler:^(MGLMapSnapshot * _Nullable snapshot, NSError * _Nullable error) { + XCTAssertNil(snapshot); + XCTAssertNotNil(error); + [expectation fulfill]; + }]; + + [self waitForExpectations:@[expectation] timeout:10.0]; +} + +- (void)testSnapshotWithOverlayHandlerSuccess { + if (![self validAccessToken]) { + return; + } + + CGSize size = self.mapView.bounds.size; + CGRect snapshotRect = CGRectMake(0, 0, size.width, size.height); + + XCTestExpectation *expectation = [self expectationWithDescription:@"snapshot with overlay succeeds"]; + expectation.expectedFulfillmentCount = 2; + + CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(30.0, 30.0); + + MGLMapSnapshotter *snapshotter = snapshotterWithCoordinates(coord, size); + XCTAssertNotNil(snapshotter); + + [snapshotter startWithOverlayHandler:^(MGLMapSnapshotOverlay * _Nullable snapshotOverlay) { + CGContextSetFillColorWithColor(snapshotOverlay.context, [UIColor.greenColor CGColor]); + CGContextSetAlpha(snapshotOverlay.context, 0.2); + CGContextAddRect(snapshotOverlay.context, snapshotRect); + CGContextFillRect(snapshotOverlay.context, snapshotRect); + [expectation fulfill]; + } completionHandler:^(MGLMapSnapshot * _Nullable snapshot, NSError * _Nullable error) { + XCTAssertNil(error); + XCTAssertNotNil(snapshot); + [expectation fulfill]; + }]; + + [self waitForExpectations:@[expectation] timeout:10.0]; +} @end |