Skip to content

Commit

Permalink
Update region on camera change event
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Jan 12, 2017
1 parent ac1ebb5 commit a988034
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ios/Classes/TiGooglemapsAutocompleteDialogProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ + (id)arrayFromAddressComponents:(NSArray<GMSAddressComponent*>*)addressComponen
}];
}

return result;
return [result autorelease];
}

+ (id)dictionaryFromPrediction:(GMSAutocompletePrediction*)prediction
Expand Down
3 changes: 2 additions & 1 deletion ios/Classes/TiGooglemapsMarkerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ -(void)setAnimationStyle:(id)value
ENSURE_UI_THREAD_1_ARG(value);
ENSURE_TYPE(value, NSNumber);

[[self marker] setAppearAnimation:NUMINT(value)];
[[self marker] setAppearAnimation:[TiUtils intValue:value def:kGMSMarkerAnimationNone]];
[self replaceValue:value forKey:@"animationStyle" notification:NO];
}

-(void)setUserData:(id)value
{
ENSURE_UI_THREAD_1_ARG(value);

[[self marker] setUserData:value];
[self replaceValue:value forKey:@"userData" notification:NO];
}
Expand Down
10 changes: 8 additions & 2 deletions ios/Classes/TiGooglemapsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,20 @@ - (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition
[[self proxy] fireEvent:@"camerachange" withObject:[self dictionaryFromCameraPosition:position]];
}
if ([[self proxy] _hasListeners:@"regionchanged"]) {
[[self proxy] fireEvent:@"regionchanged" withObject:@{
@"map" : [self proxy],
NSMutableDictionary *updatedRegion = [NSMutableDictionary dictionaryWithDictionary:@{
@"latitude" : NUMDOUBLE(position.target.latitude),
@"longitude" : NUMDOUBLE(position.target.longitude),
@"zoom": NUMFLOAT(position.zoom),
@"bearing": NUMDOUBLE(position.bearing),
@"viewingAngle": NUMDOUBLE(position.viewingAngle)
}];

[(TiGooglemapsViewProxy *)[self proxy] replaceValue:updatedRegion forKey:@"region" notification:NO];

NSMutableDictionary *event = [NSMutableDictionary dictionaryWithDictionary:updatedRegion];
[event setObject:[self proxy] forKey:@"map"];

[[self proxy] fireEvent:@"regionchanged" withObject:event];
}
}

Expand Down
10 changes: 5 additions & 5 deletions ios/Classes/TiGooglemapsViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ -(void)setMapStyle:(id)value
-(void)addAnnotation:(id)args
{
ENSURE_UI_THREAD_1_ARG(args);
ENSURE_SINGLE_ARG(args, TiGooglemapsAnnotationProxy);

TiGooglemapsAnnotationProxy *annotationProxy;
ENSURE_ARG_AT_INDEX(annotationProxy, args, 0, TiGooglemapsAnnotationProxy);
TiGooglemapsAnnotationProxy *annotationProxy = args;

dispatch_barrier_async(q, ^{
[[self markers] addObject:annotationProxy];
Expand All @@ -284,9 +284,9 @@ -(void)addAnnotations:(id)args
-(void)removeAnnotation:(id)args
{
ENSURE_UI_THREAD_1_ARG(args);

TiGooglemapsAnnotationProxy *annotationProxy;
ENSURE_ARG_AT_INDEX(annotationProxy, args, 0, TiGooglemapsAnnotationProxy);
ENSURE_SINGLE_ARG(args, TiGooglemapsAnnotationProxy);

TiGooglemapsAnnotationProxy *annotationProxy = args;

dispatch_barrier_async(q, ^{
[[self markers] removeObject:annotationProxy];
Expand Down

0 comments on commit a988034

Please sign in to comment.