diff --git a/ios/Classes/TiCutoutCircle.h b/ios/Classes/TiCutoutCircle.h index a4ced732..030c321e 100644 --- a/ios/Classes/TiCutoutCircle.h +++ b/ios/Classes/TiCutoutCircle.h @@ -1,9 +1,9 @@ -// -// TiCutoutCircle.h -// map -// -// Created by Hans Knöchel on 30.01.24. -// +/** + * Titanium SDK + * Copyright TiDev, Inc. 04/07/2022-Present. All Rights Reserved. + * Licensed under the terms of the Apache Public License + * Please see the LICENSE included with this distribution for details. + */ #import diff --git a/ios/Classes/TiCutoutCircle.m b/ios/Classes/TiCutoutCircle.m index 2730b527..b1033b36 100644 --- a/ios/Classes/TiCutoutCircle.m +++ b/ios/Classes/TiCutoutCircle.m @@ -1,9 +1,9 @@ -// -// TiCutoutCircle.m -// map -// -// Created by Hans Knöchel on 30.01.24. -// +/** + * Titanium SDK + * Copyright TiDev, Inc. 04/07/2022-Present. All Rights Reserved. + * Licensed under the terms of the Apache Public License + * Please see the LICENSE included with this distribution for details. + */ #import "TiCutoutCircle.h" diff --git a/ios/Classes/TiMapUtils.h b/ios/Classes/TiMapUtils.h index c378e82e..19f553ed 100644 --- a/ios/Classes/TiMapUtils.h +++ b/ios/Classes/TiMapUtils.h @@ -17,7 +17,7 @@ + (MKLocalSearchCompleterResultType)mappedResultTypes:(NSArray *)inputResultTypes; -+ (NSArray *)makeCircleCoordinates:(CLLocationCoordinate2D)coordinate withRadius:(double)radius andTolerance:(double)tolerance; ++ (NSArray *)generateCircleCoordinates:(CLLocationCoordinate2D)coordinate withRadius:(double)radius andTolerance:(double)tolerance; + (CLLocationCoordinate2D)processLocation:(id)locObj; diff --git a/ios/Classes/TiMapUtils.m b/ios/Classes/TiMapUtils.m index a985c738..75a1dd8f 100644 --- a/ios/Classes/TiMapUtils.m +++ b/ios/Classes/TiMapUtils.m @@ -68,7 +68,7 @@ + (MKLocalSearchCompleterResultType)mappedResultTypes:(NSArray *)inp return resultTypes; } -+ (NSArray *)makeCircleCoordinates:(CLLocationCoordinate2D)coordinate withRadius:(double)radius andTolerance:(double)tolerance ++ (NSArray *)generateCircleCoordinates:(CLLocationCoordinate2D)coordinate withRadius:(double)radius andTolerance:(double)tolerance { NSMutableArray *coordinates = [[NSMutableArray alloc] init]; double latRadian = coordinate.latitude * M_PI / 180.0; diff --git a/ios/Classes/TiMapViewProxy.m b/ios/Classes/TiMapViewProxy.m index dda55860..8955d89f 100644 --- a/ios/Classes/TiMapViewProxy.m +++ b/ios/Classes/TiMapViewProxy.m @@ -300,7 +300,7 @@ - (void)addCutoutCircle:(id)arg CGFloat latitude = [TiUtils floatValue:@"latitude" properties:arg]; CGFloat longitude = [TiUtils floatValue:@"longitude" properties:arg]; - double radius = [TiUtils doubleValue:@"radius" properties:arg]; + CGFloat radius = [TiUtils doubleValue:@"radius" properties:arg]; double tolerance = [TiUtils doubleValue:@"tolerance" properties:arg def:3.0]; CLLocationCoordinate2D WORLD_COORDINATES[6]; @@ -312,18 +312,21 @@ - (void)addCutoutCircle:(id)arg WORLD_COORDINATES[5] = CLLocationCoordinate2DMake(90, -180); CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latitude, longitude); - NSArray *circleCoordinates = [TiMapUtils makeCircleCoordinates:coordinate withRadius:radius andTolerance:tolerance]; + NSArray *circleCoordinates = [TiMapUtils generateCircleCoordinates:coordinate + withRadius:radius + andTolerance:tolerance]; + CLLocationCoordinate2D *circleCoordinatesNative = malloc(sizeof(CLLocationCoordinate2D) * [circleCoordinates count]); - for (int i = 0; i < [circleCoordinates count]; ++i) { + for (NSUInteger i = 0; i < [circleCoordinates count]; ++i) { CLLocationCoordinate2D coordinate = [TiMapUtils processLocation:[circleCoordinates objectAtIndex:i]]; circleCoordinatesNative[i] = coordinate; } - MKPolygon *polygon1 = [MKPolygon polygonWithCoordinates:circleCoordinatesNative count:circleCoordinates.count]; - TiCutoutCircle *polygon2 = [TiCutoutCircle polygonWithCoordinates:WORLD_COORDINATES count:6 interiorPolygons:@[ polygon1 ]]; + MKPolygon *circlePolygon = [MKPolygon polygonWithCoordinates:circleCoordinatesNative count:circleCoordinates.count]; + TiCutoutCircle *cutoutPolygon = [TiCutoutCircle polygonWithCoordinates:WORLD_COORDINATES count:6 interiorPolygons:@[ circlePolygon ]]; - [[(TiMapView *)[self view] map] addOverlay:polygon2]; + [[(TiMapView *)[self view] map] addOverlay:cutoutPolygon]; } - (void)setAnnotations:(id)arg diff --git a/ios/map.xcodeproj/project.pbxproj b/ios/map.xcodeproj/project.pbxproj index a9a788fa..1e91fd63 100644 --- a/ios/map.xcodeproj/project.pbxproj +++ b/ios/map.xcodeproj/project.pbxproj @@ -255,6 +255,8 @@ DB07496D1E081A6A009D8A71 /* Circle */ = { isa = PBXGroup; children = ( + 3A699AC72B68CB0E00938935 /* TiCutoutCircle.h */, + 3A699AC82B68CB0E00938935 /* TiCutoutCircle.m */, 27A609EB19F5B84000CA150A /* TiMapCircleProxy.m */, 27A609ED19F5B85900CA150A /* TiMapCircleProxy.h */, ); @@ -269,8 +271,6 @@ DB0CCA022010841A00597F24 /* Pattern */, DB07496B1E081A36009D8A71 /* Polygon */, DB07496A1E081A23009D8A71 /* Polyline */, - 3A699AC72B68CB0E00938935 /* TiCutoutCircle.h */, - 3A699AC82B68CB0E00938935 /* TiCutoutCircle.m */, ); name = Overlays; sourceTree = "";