Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-17749] iOS: fixed map not movable after animating camera #65

Merged
merged 1 commit into from
Oct 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 28 additions & 13 deletions ios/Classes/TiMapIOS7View.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#import "TiMapIOS7View.h"
#import "TiMapUtils.h"

@implementation TiMapIOS7View

Expand Down Expand Up @@ -37,31 +38,43 @@ -(void)setTintColor_:(id)color

-(void)setCamera_:(TiMapCameraProxy*)value
{
[self map].camera = [value camera];
TiThreadPerformOnMainThread(^{
[self map].camera = [value camera];
}, YES);
}
-(TiMapCameraProxy*)camera
{
return [[[TiMapCameraProxy alloc] initWithCamera:[self map].camera] autorelease];
return [TiMapUtils returnValueOnMainThread:^id{
return [[TiMapCameraProxy alloc] initWithCamera:[self map].camera];
}];
}

-(void)setPitchEnabled_:(id)value
{
[self map].pitchEnabled = [TiUtils boolValue:value];
TiThreadPerformOnMainThread(^{
[self map].pitchEnabled = [TiUtils boolValue:value];
}, YES);
}

-(void)setRotateEnabled_:(id)value
{
[self map].rotateEnabled = [TiUtils boolValue:value];
TiThreadPerformOnMainThread(^{
[self map].rotateEnabled = [TiUtils boolValue:value];
}, YES);
}

-(void)setShowsBuildings_:(id)value
{
[self map].showsBuildings = [TiUtils boolValue:value];
TiThreadPerformOnMainThread(^{
[self map].showsBuildings = [TiUtils boolValue:value];
}, YES);
}

-(void)setShowsPointsOfInterest_:(id)value
{
[self map].showsPointsOfInterest = [TiUtils boolValue:value];
TiThreadPerformOnMainThread(^{
[self map].showsPointsOfInterest = [TiUtils boolValue:value];
}, YES);
}

-(void)animateCamera:(id)args
Expand All @@ -85,13 +98,15 @@ -(void)animateCamera:(id)args

// Apple says to use `mapView:regionDidChangeAnimated:` instead of `completion`
// to know when the camera animation has completed
[UIView animateWithDuration:(duration / 1000)
delay:(delay / 1000)
options:curve
animations:^{
[self map].camera = [cameraProxy camera];
}
completion:nil];
TiThreadPerformOnMainThread(^{
[UIView animateWithDuration:(duration / 1000)
delay:(delay / 1000)
options:curve
animations:^{
[self map].camera = [cameraProxy camera];
}
completion:nil];
}, NO);
}

-(void)showAnnotations:(id)args
Expand Down
13 changes: 10 additions & 3 deletions ios/Classes/TiMapIOS7ViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@

#import "TiMapIOS7ViewProxy.h"
#import "TiMapIOS7View.h"
#import "TiMapUtils.h"

@implementation TiMapIOS7ViewProxy

-(TiMapCameraProxy*)camera
{
return [(TiMapIOS7View *)[self view] camera];
return [TiMapUtils returnValueOnMainThread:^id{
return [(TiMapIOS7View *)[self view] camera];
}];
}

-(void)animateCamera:(id)args
{
[(TiMapIOS7View *)[self view] animateCamera:args];
TiThreadPerformOnMainThread(^{
[(TiMapIOS7View *)[self view] animateCamera:args];
}, NO);
}

-(void)showAnnotations:(id)args
{
[(TiMapIOS7View *)[self view] showAnnotations:args];
TiThreadPerformOnMainThread(^{
[(TiMapIOS7View *)[self view] showAnnotations:args];
}, NO);
}

@end
14 changes: 14 additions & 0 deletions ios/Classes/TiMapUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2014 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

#import <Foundation/Foundation.h>

@interface TiMapUtils : NSObject

+(id)returnValueOnMainThread:(id(^)(void))block;

@end
25 changes: 25 additions & 0 deletions ios/Classes/TiMapUtils.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2014 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

#import "TiMapUtils.h"

@implementation TiMapUtils

+(id)returnValueOnMainThread:(id(^)(void))block
{
if ([NSThread isMainThread]) {
return block();
}

__block id result = nil;
TiThreadPerformOnMainThread(^{
result = [block() retain];
}, YES);
return [result autorelease];
}

@end
2 changes: 2 additions & 0 deletions ios/documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log
<pre>
v2.0.6 Fixed map not responding to touch after animating camera [TIMOB-17749]

v2.0.5 Fixed exception when setting "centerCoordinate" on camera [TIMOB-17659]

v2.0.4 Fixed "userLocation" permissions for iOS 8 [TIMOB-17665]
Expand Down
2 changes: 1 addition & 1 deletion ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 2.0.5
version: 2.0.6
apiversion: 2
description: External version of Map module
author: Jeff Haynie & Jon Alter
Expand Down
8 changes: 8 additions & 0 deletions ios/map.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
CED651CF17D7AA21007C2954 /* TiMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = CED651C317D7AA21007C2954 /* TiMapView.m */; };
CED651D017D7AA21007C2954 /* TiMapViewProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = CED651C417D7AA21007C2954 /* TiMapViewProxy.h */; };
CED651D117D7AA21007C2954 /* TiMapViewProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = CED651C517D7AA21007C2954 /* TiMapViewProxy.m */; };
CEE33CF319EC4C150005E745 /* TiMapUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = CEE33CF119EC4C150005E745 /* TiMapUtils.h */; };
CEE33CF419EC4C150005E745 /* TiMapUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = CEE33CF219EC4C150005E745 /* TiMapUtils.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -90,6 +92,8 @@
CED651C317D7AA21007C2954 /* TiMapView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiMapView.m; path = Classes/TiMapView.m; sourceTree = "<group>"; };
CED651C417D7AA21007C2954 /* TiMapViewProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiMapViewProxy.h; path = Classes/TiMapViewProxy.h; sourceTree = "<group>"; };
CED651C517D7AA21007C2954 /* TiMapViewProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiMapViewProxy.m; path = Classes/TiMapViewProxy.m; sourceTree = "<group>"; };
CEE33CF119EC4C150005E745 /* TiMapUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiMapUtils.h; path = Classes/TiMapUtils.h; sourceTree = "<group>"; };
CEE33CF219EC4C150005E745 /* TiMapUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiMapUtils.m; path = Classes/TiMapUtils.m; sourceTree = "<group>"; };
D2AAC07E0554694100DB518D /* libTiMap.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTiMap.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -160,6 +164,8 @@
CE92EC1C17DF7B2F0082E943 /* TiMapIOS7ViewProxy.m */,
24DE9E0F11C5FE74003F90F6 /* TiMapModuleAssets.h */,
24DE9E1011C5FE74003F90F6 /* TiMapModuleAssets.m */,
CEE33CF119EC4C150005E745 /* TiMapUtils.h */,
CEE33CF219EC4C150005E745 /* TiMapUtils.m */,
);
name = Classes;
sourceTree = "<group>";
Expand Down Expand Up @@ -187,6 +193,7 @@
24DE9E1111C5FE74003F90F6 /* TiMapModuleAssets.h in Headers */,
CED651C617D7AA21007C2954 /* TiMapAnnotationProxy.h in Headers */,
CE92EC2517DF9A640082E943 /* TiMapCameraProxy.h in Headers */,
CEE33CF319EC4C150005E745 /* TiMapUtils.h in Headers */,
CEC39B4617EB97BA00DCE1EE /* TiMapRouteProxy.h in Headers */,
CED651C817D7AA21007C2954 /* TiMapCustomAnnotationView.h in Headers */,
CED651CA17D7AA21007C2954 /* TiMapImageAnnotationView.h in Headers */,
Expand Down Expand Up @@ -276,6 +283,7 @@
CE92EC1E17DF7B2F0082E943 /* TiMapIOS7View.m in Sources */,
CED651CD17D7AA21007C2954 /* TiMapPinAnnotationView.m in Sources */,
CE92EC2017DF7B2F0082E943 /* TiMapIOS7ViewProxy.m in Sources */,
CEE33CF419EC4C150005E745 /* TiMapUtils.m in Sources */,
CED651CF17D7AA21007C2954 /* TiMapView.m in Sources */,
CED651D117D7AA21007C2954 /* TiMapViewProxy.m in Sources */,
);
Expand Down
Binary file removed ios/ti.map-iphone-2.0.5.zip
Binary file not shown.
Binary file added ios/ti.map-iphone-2.0.6.zip
Binary file not shown.