summaryrefslogtreecommitdiff
path: root/platform/ios
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-04-24 09:21:46 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-04-24 09:21:46 -0700
commit0e8b496d317abab1fc810693c2bc770ed3989a0e (patch)
tree921f1833954ff26b4fb556b01ac79a59c6181564 /platform/ios
parentfec1cf0e23a97b0f76f0aaabf0a71004e5a1dac2 (diff)
parent74cb1ccced32b1c7cbfac51e96e424850434966e (diff)
downloadqtlocation-mapboxgl-0e8b496d317abab1fc810693c2bc770ed3989a0e.tar.gz
Merge branch 'master' into 1ec5-constraints-1327
Diffstat (limited to 'platform/ios')
-rw-r--r--platform/ios/MGLMapView.mm17
-rw-r--r--platform/ios/MGLMapboxEvents.m46
2 files changed, 37 insertions, 26 deletions
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 3094d2f8ce..f9ed77041a 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -1203,12 +1203,6 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
if (finished)
{
[self notifyMapChange:@(animated ? mbgl::MapChangeRegionDidChangeAnimated : mbgl::MapChangeRegionDidChange)];
-
- [UIView animateWithDuration:MGLAnimationDuration
- animations:^
- {
- self.compass.alpha = 0;
- }];
}
}];
}
@@ -2307,6 +2301,17 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng)
}
completion:nil];
}
+ else if (mbglMap->getBearing() == 0 && self.compass.alpha > 0)
+ {
+ [UIView animateWithDuration:MGLAnimationDuration
+ delay:0
+ options:UIViewAnimationOptionBeginFromCurrentState
+ animations:^
+ {
+ self.compass.alpha = 0;
+ }
+ completion:nil];
+ }
}
+ (UIImage *)resourceImageNamed:(NSString *)imageName
diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m
index c4bd7cf0bd..ee1ae82e7c 100644
--- a/platform/ios/MGLMapboxEvents.m
+++ b/platform/ios/MGLMapboxEvents.m
@@ -50,7 +50,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
// from within a single thread use underscore syntax.
//
// All captures of `self` from within asynchronous
-// dispatches will use a `weakSelf` to avoid cyclical
+// dispatches will use a `strongSelf` to avoid cyclical
// strong references.
//
@@ -292,6 +292,9 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
__weak MGLMapboxEvents *weakSelf = self;
dispatch_async(_serialQueue, ^{
+ MGLMapboxEvents *strongSelf = weakSelf;
+ if ( ! strongSelf) return;
+
// Opt Out Checking When Built
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"mapbox_metrics_enabled_preference"]) {
[_eventQueue removeAllObjects];
@@ -315,35 +318,35 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
// mapbox-events stock attributes
[evt setObject:event forKey:@"event"];
[evt setObject:@(1) forKey:@"version"];
- [evt setObject:[weakSelf.rfc3339DateFormatter stringFromDate:[NSDate date]] forKey:@"created"];
- [evt setObject:weakSelf.instanceID forKey:@"instance"];
- [evt setObject:weakSelf.advertiserId forKey:@"advertiserId"];
- [evt setObject:weakSelf.vendorId forKey:@"vendorId"];
- [evt setObject:weakSelf.appBundleId forKeyedSubscript:@"appBundleId"];
+ [evt setObject:[strongSelf.rfc3339DateFormatter stringFromDate:[NSDate date]] forKey:@"created"];
+ [evt setObject:strongSelf.instanceID forKey:@"instance"];
+ [evt setObject:strongSelf.advertiserId forKey:@"advertiserId"];
+ [evt setObject:strongSelf.vendorId forKey:@"vendorId"];
+ [evt setObject:strongSelf.appBundleId forKeyedSubscript:@"appBundleId"];
// mapbox-events-ios stock attributes
- [evt setValue:weakSelf.model forKey:@"model"];
- [evt setValue:weakSelf.iOSVersion forKey:@"operatingSystem"];
- [evt setValue:[weakSelf getDeviceOrientation] forKey:@"orientation"];
+ [evt setValue:strongSelf.model forKey:@"model"];
+ [evt setValue:strongSelf.iOSVersion forKey:@"operatingSystem"];
+ [evt setValue:[strongSelf getDeviceOrientation] forKey:@"orientation"];
[evt setValue:@((int)(100 * [UIDevice currentDevice].batteryLevel)) forKey:@"batteryLevel"];
- [evt setValue:@(weakSelf.scale) forKey:@"resolution"];
- [evt setValue:weakSelf.carrier forKey:@"carrier"];
+ [evt setValue:@(strongSelf.scale) forKey:@"resolution"];
+ [evt setValue:strongSelf.carrier forKey:@"carrier"];
- NSString *cell = [weakSelf getCurrentCellularNetworkConnectionType];
+ NSString *cell = [strongSelf getCurrentCellularNetworkConnectionType];
if (cell) {
[evt setValue:cell forKey:@"cellularNetworkType"];
} else {
[evt setObject:[NSNull null] forKey:@"cellularNetworkType"];
}
- NSString *wifi = [weakSelf getWifiNetworkName];
+ NSString *wifi = [strongSelf getWifiNetworkName];
if (wifi) {
[evt setValue:wifi forKey:@"wifi"];
} else {
[evt setObject:[NSNull null] forKey:@"wifi"];
}
- [evt setValue:@([weakSelf getContentSizeScale]) forKey:@"accessibilityFontScale"];
+ [evt setValue:@([strongSelf getContentSizeScale]) forKey:@"accessibilityFontScale"];
// Make Immutable Version
NSDictionary *finalEvent = [NSDictionary dictionaryWithDictionary:evt];
@@ -352,12 +355,12 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
[_eventQueue addObject:finalEvent];
// Has Flush Limit Been Reached?
- if (_eventQueue.count >= weakSelf.flushAt) {
- [weakSelf flush];
+ if (_eventQueue.count >= strongSelf.flushAt) {
+ [strongSelf flush];
}
// Reset Timer (Initial Starting of Timer after first event is pushed)
- [weakSelf startTimer];
+ [strongSelf startTimer];
});
}
@@ -375,10 +378,13 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
__weak MGLMapboxEvents *weakSelf = self;
dispatch_async(_serialQueue, ^{
+ MGLMapboxEvents *strongSelf = weakSelf;
+ if ( ! strongSelf) return;
+
__block NSArray *events;
- NSUInteger upper = weakSelf.flushAt;
- if (weakSelf.flushAt > [_eventQueue count]) {
+ NSUInteger upper = strongSelf.flushAt;
+ if (strongSelf.flushAt > [_eventQueue count]) {
if ([_eventQueue count] == 0) {
return;
}
@@ -393,7 +399,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
[_eventQueue removeObjectsInRange:theRange];
// Send Array of Events to Server
- [weakSelf postEvents:events];
+ [strongSelf postEvents:events];
});
}