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-8092] Fix map rendering #1801

Merged
merged 3 commits into from
Mar 23, 2012
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
53 changes: 27 additions & 26 deletions iphone/Classes/TiMapView.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ -(void)dealloc

-(void)render
{
if (![NSThread isMainThread]) {
TiThreadPerformOnMainThread(^{[self render];}, NO);
return;
}
if (region.center.latitude!=0 && region.center.longitude!=0)
{
[map setRegion:[map regionThatFits:region] animated:animate];
}
if (![NSThread isMainThread]) {
TiThreadPerformOnMainThread(^{[self render];}, NO);
return;
}
if (region.center.latitude!=0 && region.center.longitude!=0)
{
if (regionFits) {
[map setRegion:[map regionThatFits:region] animated:animate];
}
else {
[map setRegion:region animated:animate];
}
}
}

-(MKMapView*)map
Expand Down Expand Up @@ -86,8 +91,9 @@ -(void)didFirePropertyChanges

-(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds
{
[TiUtils setView:[self map] positionRect:bounds];
[TiUtils setView:[self map] positionRect:bounds];
[super frameSizeChanged:frame bounds:bounds];
[self render];
}

-(TiMapAnnotationProxy*)annotationFromArg:(id)arg
Expand Down Expand Up @@ -340,12 +346,20 @@ -(MKCoordinateRegion)regionFromDict:(NSDictionary*)dict

-(CLLocationDegrees) longitudeDelta
{
return region.span.longitudeDelta;
if (loaded) {
MKCoordinateRegion _region = [[self map] region];
return _region.span.longitudeDelta;
}
return 0.0;
}

-(CLLocationDegrees) latitudeDelta
{
return region.span.latitudeDelta;
if (loaded) {
MKCoordinateRegion _region = [[self map] region];
return _region.span.latitudeDelta;
}
return 0.0;
}


Expand Down Expand Up @@ -376,18 +390,6 @@ -(void)setRegion_:(id)value
else
{
region = [self regionFromDict:value];
if (regionFits)
{
MKCoordinateRegion fitRegion = [[self map] regionThatFits:region];
// this seems to happen sometimes where we get an invalid span back
if (fitRegion.span.latitudeDelta == 0 || fitRegion.span.longitudeDelta == 0)
{
// this seems to happen when you try and call this with the same region
// which means we can ignore (otherwise you'll get an NSInvalidException
return;
}
region = fitRegion;
}
[self render];
}
}
Expand All @@ -399,9 +401,8 @@ -(void)setAnimate_:(id)value

-(void)setRegionFit_:(id)value
{
id aregion = [self.proxy valueForKey:@"region"];
regionFits = [TiUtils boolValue:value];
[self setRegion_:aregion];
regionFits = [TiUtils boolValue:value];
[self render];
}

-(void)setUserLocation_:(id)value
Expand Down
9 changes: 5 additions & 4 deletions iphone/Classes/TiMapViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ @implementation TiMapViewProxy

-(NSArray *)keySequence
{
return [NSArray arrayWithObjects:
@"animate",
@"location",
nil];
return [NSArray arrayWithObjects:
@"animate",
@"location",
@"regionFit",
nil];
}

-(void)_destroy
Expand Down