Skip to content

Commit

Permalink
ASMapNode: Toggle user interaction when liveMap changes (facebookarch…
Browse files Browse the repository at this point in the history
…ive#1753)

ASMapNode: Change map snapshot when updating it with a new region (facebookarchive#1754)
ASMapNode: Commented out code that is causing inaccurate behavior
  • Loading branch information
george-gw committed Jun 17, 2016
1 parent e550373 commit fb46628
Show file tree
Hide file tree
Showing 17 changed files with 1,072 additions and 27 deletions.
18 changes: 9 additions & 9 deletions AsyncDisplayKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1871,12 +1871,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 058D09D2195D04C000B7D73C /* Build configuration list for PBXNativeTarget "AsyncDisplayKitTests" */;
buildPhases = (
2E61B6A0DB0F436A9DDBE86F /* 📦 Check Pods Manifest.lock */,
2E61B6A0DB0F436A9DDBE86F /* [CP] Check Pods Manifest.lock */,
058D09B8195D04C000B7D73C /* Sources */,
058D09B9195D04C000B7D73C /* Frameworks */,
058D09BA195D04C000B7D73C /* Resources */,
3B9D88CDF51B429C8409E4B6 /* 📦 Copy Pods Resources */,
B130AB1AC0A1E5162E211C19 /* 📦 Embed Pods Frameworks */,
3B9D88CDF51B429C8409E4B6 /* [CP] Copy Pods Resources */,
B130AB1AC0A1E5162E211C19 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -1977,44 +1977,44 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
2E61B6A0DB0F436A9DDBE86F /* 📦 Check Pods Manifest.lock */ = {
2E61B6A0DB0F436A9DDBE86F /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Check Pods Manifest.lock";
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
3B9D88CDF51B429C8409E4B6 /* 📦 Copy Pods Resources */ = {
3B9D88CDF51B429C8409E4B6 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Copy Pods Resources";
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
B130AB1AC0A1E5162E211C19 /* 📦 Embed Pods Frameworks */ = {
B130AB1AC0A1E5162E211C19 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Embed Pods Frameworks";
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
2 changes: 1 addition & 1 deletion AsyncDisplayKit/ASEditableTextNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)editableTextNodeDidUpdateText:(ASEditableTextNode *)editableTextNode;

/**
@abstract Indicates to the delegate that teh text node has finished editing.
@abstract Indicates to the delegate that the text node has finished editing.
@param editableTextNode An editable text node.
@discussion The invocation of this method coincides with the keyboard animating to become hidden.
*/
Expand Down
28 changes: 20 additions & 8 deletions AsyncDisplayKit/ASMapNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ @interface ASMapNode()
MKMapSnapshotter *_snapshotter;
BOOL _snapshotAfterLayout;
NSArray *_annotations;
CLLocationCoordinate2D _centerCoordinateOfMap;
// CLLocationCoordinate2D _centerCoordinateOfMap;
}
@end

Expand All @@ -46,7 +46,7 @@ - (instancetype)init

_needsMapReloadOnBoundsChange = YES;
_liveMap = NO;
_centerCoordinateOfMap = kCLLocationCoordinate2DInvalid;
// _centerCoordinateOfMap = kCLLocationCoordinate2DInvalid;
_annotations = @[];
return self;
}
Expand All @@ -55,7 +55,6 @@ - (void)didLoad
{
[super didLoad];
if (self.isLiveMap) {
self.userInteractionEnabled = YES;
[self addLiveMap];
}
}
Expand Down Expand Up @@ -161,7 +160,18 @@ - (MKCoordinateRegion)region

- (void)setRegion:(MKCoordinateRegion)region
{
self.options.region = region;
MKMapSnapshotOptions * __weak oldOptions = self.options;
MKMapSnapshotOptions * options = [[MKMapSnapshotOptions alloc] init];
options.camera = oldOptions.camera;
options.mapRect = oldOptions.mapRect;
options.mapType = oldOptions.mapType;
options.showsPointsOfInterest = oldOptions.showsPointsOfInterest;
options.showsBuildings = oldOptions.showsBuildings;
options.size = oldOptions.size;
options.scale = oldOptions.scale;
options.region = region;
self.options = options;
// self.options.region = region;
}

#pragma mark - Snapshotter
Expand Down Expand Up @@ -257,6 +267,7 @@ - (void)applySnapshotOptions
- (void)addLiveMap
{
ASDisplayNodeAssertMainThread();
self.userInteractionEnabled = YES;
if (!_mapView) {
__weak ASMapNode *weakSelf = self;
_mapView = [[MKMapView alloc] initWithFrame:CGRectZero];
Expand All @@ -266,16 +277,17 @@ - (void)addLiveMap
[weakSelf setNeedsLayout];
[weakSelf.view addSubview:_mapView];

if (CLLocationCoordinate2DIsValid(_centerCoordinateOfMap)) {
[_mapView setCenterCoordinate:_centerCoordinateOfMap];
}
// if (CLLocationCoordinate2DIsValid(_centerCoordinateOfMap)) {
// [_mapView setCenterCoordinate:_centerCoordinateOfMap];
// }
}
}

- (void)removeLiveMap
{
self.userInteractionEnabled = false;
// FIXME: With MKCoordinateRegion, isn't the center coordinate fully specified? Do we need this?
_centerCoordinateOfMap = _mapView.centerCoordinate;
// _centerCoordinateOfMap = _mapView.centerCoordinate;
[_mapView removeFromSuperview];
_mapView = nil;
}
Expand Down
6 changes: 6 additions & 0 deletions examples/ASMapNode/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
target 'Sample' do
pod 'AsyncDisplayKit', :path => '../..'
end

Loading

0 comments on commit fb46628

Please sign in to comment.