From e46fc0ad51bf11eda9c3351f262e5032b300f8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Wed, 21 Sep 2022 13:18:42 +0200 Subject: [PATCH 01/26] feat: add iOS 16 APIs --- ios/Classes/TiMapCircleProxy.h | 1 + ios/Classes/TiMapCircleProxy.m | 15 ++++++- ios/Classes/TiMapModule.h | 7 +++- ios/Classes/TiMapModule.m | 76 +++++++++++++++++++++++++++++++++- ios/Classes/TiMapUtils.h | 3 ++ ios/Classes/TiMapUtils.m | 31 ++++++++++++++ ios/Classes/TiMapView.m | 54 ++++++++++++++++++++++++ ios/TiMap_Prefix.pch | 6 +++ 8 files changed, 190 insertions(+), 3 deletions(-) diff --git a/ios/Classes/TiMapCircleProxy.h b/ios/Classes/TiMapCircleProxy.h index 6258441e..0fc15106 100644 --- a/ios/Classes/TiMapCircleProxy.h +++ b/ios/Classes/TiMapCircleProxy.h @@ -19,6 +19,7 @@ double radius; double alpha; double strokeWidth; + int blendMode; TiColor *strokeColor; TiColor *fillColor; } diff --git a/ios/Classes/TiMapCircleProxy.m b/ios/Classes/TiMapCircleProxy.m index 065bc128..879afa2a 100644 --- a/ios/Classes/TiMapCircleProxy.m +++ b/ios/Classes/TiMapCircleProxy.m @@ -6,6 +6,7 @@ */ #import "TiMapCircleProxy.h" +#import "TiUtils.h" @implementation TiMapCircleProxy @@ -22,7 +23,7 @@ - (void)dealloc - (NSArray *)keySequence { - return @[ @"center", @"radius" ]; + return @[ @"center", @"radius", @"blendMode" ]; } - (void)_initWithProperties:(NSDictionary *)properties @@ -50,6 +51,12 @@ - (MKCircleRenderer *)circleRenderer if (circleRenderer == nil) { circleRenderer = [[[MKCircleRenderer alloc] initWithCircle:[MKCircle circleWithCenterCoordinate:center radius:radius]] retain]; [circleRenderer setFillColor:fillColor ? [fillColor color] : [UIColor blackColor]]; + +#if IS_SDK_IOS_16 + if ([TiUtils isIOSVersionOrGreater:@"16.0"] && blendMode > 0) { + circleRenderer.blendMode = blendMode; + } +#endif } return circleRenderer; @@ -120,4 +127,10 @@ - (void)setOpacity:(id)value [self replaceValue:value forKey:@"opacity" notification:NO]; } +- (void)setBlendMode:(id)value +{ + blendMode = [TiUtils intValue:value]; + [self replaceValue:value forKey:@"blendMode" notification:NO]; +} + @end diff --git a/ios/Classes/TiMapModule.h b/ios/Classes/TiMapModule.h index 2a876931..6d6261dc 100644 --- a/ios/Classes/TiMapModule.h +++ b/ios/Classes/TiMapModule.h @@ -6,8 +6,13 @@ */ #import +#import -@interface TiMapModule : TiModule { +#if IS_SDK_IOS_16 +@interface TiMapModule : TiModule { +#else + @interface TiMapModule : TiModule { +#endif UIColor *colorRed; } diff --git a/ios/Classes/TiMapModule.m b/ios/Classes/TiMapModule.m index 703b70ab..128cb9cc 100644 --- a/ios/Classes/TiMapModule.m +++ b/ios/Classes/TiMapModule.m @@ -9,7 +9,8 @@ #import "TiMapCameraProxy.h" #import "TiMapConstants.h" #import "TiMapViewProxy.h" -#import +#import "TiApp.h" +#import "TiBlob.h" @implementation TiMapModule @@ -44,6 +45,73 @@ - (TiMapCameraProxy *)createCamera:(id)args return [[[TiMapCameraProxy alloc] _initWithPageContext:[self pageContext] args:args] autorelease]; } +#if IS_SDK_IOS_16 +- (void)getLookAroundImage:(id)args +{ + ENSURE_SINGLE_ARG(args, NSDictionary); + + KrollCallback *callback = (KrollCallback *)args[@"callback"]; + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([TiUtils doubleValue:args[@"latitude"]], [TiUtils doubleValue:args[@"longitude"]]); + + MKLookAroundSceneRequest *request = [[MKLookAroundSceneRequest alloc] initWithCoordinate:coordinate]; + + [request getSceneWithCompletionHandler:^(MKLookAroundScene * _Nullable_result scene, NSError * _Nullable error) { + if (error != nil) { + [callback call:@[@{ @"success": @(NO), @"error": error.localizedDescription }] thisObject:self]; + return; + } + + MKLookAroundSnapshotter *snapshotter = [[MKLookAroundSnapshotter alloc] initWithScene:scene options:[MKLookAroundSnapshotOptions new]]; + [snapshotter getSnapshotWithCompletionHandler:^(MKLookAroundSnapshot * _Nullable snapshot, NSError * _Nullable error) { + if (error != nil) { + MKLookAroundViewController *vc; + [callback call:@[@{ @"success": @(NO), @"error": error.localizedDescription }] thisObject:self]; + return; + } + + [callback call:@[@{ @"success": @(YES), @"image": [[TiBlob alloc] initWithImage:snapshot.image] }] thisObject:self]; + }]; + }]; +} + +- (void)openLookAroundDialog:(id)args +{ + ENSURE_SINGLE_ARG(args, NSDictionary); + + if (![TiUtils isIOSVersionOrGreater:@"16.0"]) { + NSLog(@"[ERROR] This method is only available on iOS 16+"); + return; + } + + KrollCallback *callback = (KrollCallback *)args[@"callback"]; + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([TiUtils doubleValue:args[@"latitude"]], [TiUtils doubleValue:args[@"longitude"]]); + + MKLookAroundSceneRequest *request = [[MKLookAroundSceneRequest alloc] initWithCoordinate:coordinate]; + + [request getSceneWithCompletionHandler:^(MKLookAroundScene * _Nullable_result scene, NSError * _Nullable error) { + if (error != nil) { + [callback call:@[@{ @"success": @(NO), @"error": error.localizedDescription }] thisObject:self]; + return; + } + + MKLookAroundViewController *vc = [[MKLookAroundViewController alloc] initWithScene:scene]; + vc.delegate = self; + [[TiApp app] showModalController:vc animated:YES]; + }]; +} + +- (void)lookAroundViewControllerDidDismissFullScreen:(MKLookAroundViewController *)viewController +{ + [self fireEvent:@"lookAroundOpen"]; +} + +- (void)lookAroundViewControllerDidPresentFullScreen:(MKLookAroundViewController *)viewController +{ + [self fireEvent:@"lookAroundClose"]; +} + +#endif + MAKE_SYSTEM_PROP(STANDARD_TYPE, MKMapTypeStandard); MAKE_SYSTEM_PROP(NORMAL_TYPE, MKMapTypeStandard); // For parity with Android MAKE_SYSTEM_PROP(SATELLITE_TYPE, MKMapTypeSatellite); @@ -86,4 +154,10 @@ - (TiMapCameraProxy *)createCamera:(id)args MAKE_SYSTEM_PROP_DBL(FEATURE_DISPLAY_PRIORITY_DEFAULT_HIGH, MKFeatureDisplayPriorityDefaultHigh); MAKE_SYSTEM_PROP_DBL(FEATURE_DISPLAY_PRIORITY_DEFAULT_LOW, MKFeatureDisplayPriorityDefaultLow); +#if IS_SDK_IOS_16 +MAKE_SYSTEM_PROP(FEATURE_TERRITORIES, MKMapFeatureOptionTerritories); +MAKE_SYSTEM_PROP(FEATURE_PHYSICAL_FEATURES, MKMapFeatureOptionPhysicalFeatures); +MAKE_SYSTEM_PROP(FEATURE_TYPE_POINT_OF_INTEREST, MKMapFeatureTypePointOfInterest); +#endif + @end diff --git a/ios/Classes/TiMapUtils.h b/ios/Classes/TiMapUtils.h index a12f3f62..7a7b6d2e 100644 --- a/ios/Classes/TiMapUtils.h +++ b/ios/Classes/TiMapUtils.h @@ -6,9 +6,12 @@ */ #import +#import @interface TiMapUtils : NSObject + (id)returnValueOnMainThread:(id (^)(void))block; ++ (NSDictionary *)dictionaryFromPlacemark:(CLPlacemark *)placemark; + @end diff --git a/ios/Classes/TiMapUtils.m b/ios/Classes/TiMapUtils.m index da609e3b..4e1160a4 100644 --- a/ios/Classes/TiMapUtils.m +++ b/ios/Classes/TiMapUtils.m @@ -7,6 +7,8 @@ #import "TiMapUtils.h" #import "TiMapView.h" +#import +#import @implementation TiMapUtils @@ -25,4 +27,33 @@ + (id)returnValueOnMainThread:(id (^)(void))block return [result autorelease]; } ++ (NSDictionary *)dictionaryFromPlacemark:(CLPlacemark *)placemark +{ + NSMutableDictionary *place = [NSMutableDictionary dictionary]; + + if (placemark.thoroughfare) { + place[@"street"] = placemark.thoroughfare; + } + if (placemark.locality) { + place[@"city"] = placemark.locality; + } + if (placemark.administrativeArea) { + place[@"state"] = placemark.administrativeArea; + } + if (placemark.country) { + place[@"country"] = placemark.country; + } + if (placemark.postalCode) { + place[@"postalCode"] = placemark.postalCode; + } + if (placemark.ISOcountryCode) { + place[@"countryCode"] = placemark.ISOcountryCode; + } + if (placemark.postalAddress) { + place[@"address"] = [CNPostalAddressFormatter stringFromPostalAddress:placemark.postalAddress style:CNPostalAddressFormatterStyleMailingAddress]; + } + + return place; +} + @end diff --git a/ios/Classes/TiMapView.m b/ios/Classes/TiMapView.m index 2f7072b2..636cc73f 100644 --- a/ios/Classes/TiMapView.m +++ b/ios/Classes/TiMapView.m @@ -353,6 +353,23 @@ - (void)selectAnnotation:(id)args } } +#if IS_SDK_IOS_16 +- (void)setSelectableMapFeatures_:(id)args +{ + if (![TiUtils isIOSVersionOrGreater:@"16.0"]) { + return; + } + + __block MKMapFeatureOptions options; + + [(NSArray *)args enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + options |= [TiUtils intValue:obj]; + }]; + + [[self map] setSelectableMapFeatures:options]; +} +#endif + - (void)deselectAnnotation:(id)args { ENSURE_SINGLE_ARG(args, NSObject); @@ -1089,6 +1106,43 @@ - (TiMapAnnotationProxy *)proxyForAnnotation:(MKAnnotationView *)pinview return nil; } +#if IS_SDK_IOS_16 +- (void)mapView:(MKMapView *)mapView didSelectAnnotation:(id)annotation +{ + if (![TiUtils isIOSVersionOrGreater:@"16.0"]) { + return; + } + + if (![annotation isKindOfClass:[MKMapFeatureAnnotation class]]) { + return; + } + + MKMapItemRequest *request = [[MKMapItemRequest alloc] initWithMapFeatureAnnotation:annotation]; + + [request getMapItemWithCompletionHandler:^(MKMapItem * _Nullable mapItem, NSError * _Nullable error) { + if (error != nil) { + NSLog(@"[ERROR] Cannot get POI details: %@", error.localizedDescription); + return; + } + + MKMapFeatureAnnotation *featureAnnotation = (MKMapFeatureAnnotation *)annotation; + + NSDictionary *event = @{ + @"name": NULL_IF_NIL(mapItem.name), + @"featureType": @(featureAnnotation.featureType), + @"pointOfInterestCategory": NULL_IF_NIL(featureAnnotation.pointOfInterestCategory), + @"phoneNumber": NULL_IF_NIL(mapItem.phoneNumber), + @"url": NULL_IF_NIL(mapItem.url.absoluteString), + @"place": [TiMapUtils dictionaryFromPlacemark:mapItem.placemark], + @"latitude": @(annotation.coordinate.latitude), + @"longitude": @(annotation.coordinate.longitude) + }; + + [[self proxy] fireEvent:@"poiclick" withObject:event]; + }]; +} +#endif + - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view { if ([view conformsToProtocol:@protocol(TiMapAnnotation)]) { diff --git a/ios/TiMap_Prefix.pch b/ios/TiMap_Prefix.pch index 8bec24fa..c2a9ccea 100644 --- a/ios/TiMap_Prefix.pch +++ b/ios/TiMap_Prefix.pch @@ -2,3 +2,9 @@ #ifdef __OBJC__ #import #endif + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160000 +#define IS_SDK_IOS_16 true +#else +#define IS_SDK_IOS_16 false +#endif From 289c3c51a1ec308a973df35d4f973bd4bef31010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Wed, 21 Sep 2022 14:57:29 +0200 Subject: [PATCH 02/26] fix(ios): lint sources --- ios/Classes/TiMapModule.h | 4 ++-- ios/Classes/TiMapModule.m | 30 +++++++++++++++++++----------- ios/Classes/TiMapUtils.h | 2 +- ios/Classes/TiMapUtils.m | 2 +- ios/Classes/TiMapView.m | 26 +++++++++++++------------- 5 files changed, 36 insertions(+), 28 deletions(-) diff --git a/ios/Classes/TiMapModule.h b/ios/Classes/TiMapModule.h index 6d6261dc..5eae48bd 100644 --- a/ios/Classes/TiMapModule.h +++ b/ios/Classes/TiMapModule.h @@ -5,13 +5,13 @@ * Please see the LICENSE included with this distribution for details. */ -#import #import +#import #if IS_SDK_IOS_16 @interface TiMapModule : TiModule { #else - @interface TiMapModule : TiModule { +@interface TiMapModule : TiModule { #endif UIColor *colorRed; } diff --git a/ios/Classes/TiMapModule.m b/ios/Classes/TiMapModule.m index 128cb9cc..00fc9e4c 100644 --- a/ios/Classes/TiMapModule.m +++ b/ios/Classes/TiMapModule.m @@ -6,11 +6,11 @@ */ #import "TiMapModule.h" +#import "TiApp.h" +#import "TiBlob.h" #import "TiMapCameraProxy.h" #import "TiMapConstants.h" #import "TiMapViewProxy.h" -#import "TiApp.h" -#import "TiBlob.h" @implementation TiMapModule @@ -55,21 +55,27 @@ - (void)getLookAroundImage:(id)args MKLookAroundSceneRequest *request = [[MKLookAroundSceneRequest alloc] initWithCoordinate:coordinate]; - [request getSceneWithCompletionHandler:^(MKLookAroundScene * _Nullable_result scene, NSError * _Nullable error) { + [request getSceneWithCompletionHandler:^(MKLookAroundScene *_Nullable_result scene, NSError *_Nullable error) { if (error != nil) { - [callback call:@[@{ @"success": @(NO), @"error": error.localizedDescription }] thisObject:self]; + [callback call:@[ @{@"success" : @(NO), + @"error" : error.localizedDescription} ] + thisObject:self]; return; } - + MKLookAroundSnapshotter *snapshotter = [[MKLookAroundSnapshotter alloc] initWithScene:scene options:[MKLookAroundSnapshotOptions new]]; - [snapshotter getSnapshotWithCompletionHandler:^(MKLookAroundSnapshot * _Nullable snapshot, NSError * _Nullable error) { + [snapshotter getSnapshotWithCompletionHandler:^(MKLookAroundSnapshot *_Nullable snapshot, NSError *_Nullable error) { if (error != nil) { MKLookAroundViewController *vc; - [callback call:@[@{ @"success": @(NO), @"error": error.localizedDescription }] thisObject:self]; + [callback call:@[ @{@"success" : @(NO), + @"error" : error.localizedDescription} ] + thisObject:self]; return; } - [callback call:@[@{ @"success": @(YES), @"image": [[TiBlob alloc] initWithImage:snapshot.image] }] thisObject:self]; + [callback call:@[ @{@"success" : @(YES), + @"image" : [[TiBlob alloc] initWithImage:snapshot.image]} ] + thisObject:self]; }]; }]; } @@ -88,12 +94,14 @@ - (void)openLookAroundDialog:(id)args MKLookAroundSceneRequest *request = [[MKLookAroundSceneRequest alloc] initWithCoordinate:coordinate]; - [request getSceneWithCompletionHandler:^(MKLookAroundScene * _Nullable_result scene, NSError * _Nullable error) { + [request getSceneWithCompletionHandler:^(MKLookAroundScene *_Nullable_result scene, NSError *_Nullable error) { if (error != nil) { - [callback call:@[@{ @"success": @(NO), @"error": error.localizedDescription }] thisObject:self]; + [callback call:@[ @{@"success" : @(NO), + @"error" : error.localizedDescription} ] + thisObject:self]; return; } - + MKLookAroundViewController *vc = [[MKLookAroundViewController alloc] initWithScene:scene]; vc.delegate = self; [[TiApp app] showModalController:vc animated:YES]; diff --git a/ios/Classes/TiMapUtils.h b/ios/Classes/TiMapUtils.h index 7a7b6d2e..4440cbd3 100644 --- a/ios/Classes/TiMapUtils.h +++ b/ios/Classes/TiMapUtils.h @@ -5,8 +5,8 @@ * Please see the LICENSE included with this distribution for details. */ -#import #import +#import @interface TiMapUtils : NSObject diff --git a/ios/Classes/TiMapUtils.m b/ios/Classes/TiMapUtils.m index 4e1160a4..8ae44b37 100644 --- a/ios/Classes/TiMapUtils.m +++ b/ios/Classes/TiMapUtils.m @@ -52,7 +52,7 @@ + (id)returnValueOnMainThread:(id (^)(void))block if (placemark.postalAddress) { place[@"address"] = [CNPostalAddressFormatter stringFromPostalAddress:placemark.postalAddress style:CNPostalAddressFormatterStyleMailingAddress]; } - + return place; } diff --git a/ios/Classes/TiMapView.m b/ios/Classes/TiMapView.m index c831b290..46ed4380 100644 --- a/ios/Classes/TiMapView.m +++ b/ios/Classes/TiMapView.m @@ -361,8 +361,8 @@ - (void)setSelectableMapFeatures_:(id)args } __block MKMapFeatureOptions options; - - [(NSArray *)args enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + [(NSArray *)args enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) { options |= [TiUtils intValue:obj]; }]; @@ -1119,25 +1119,25 @@ - (void)mapView:(MKMapView *)mapView didSelectAnnotation:(id)annot MKMapItemRequest *request = [[MKMapItemRequest alloc] initWithMapFeatureAnnotation:annotation]; - [request getMapItemWithCompletionHandler:^(MKMapItem * _Nullable mapItem, NSError * _Nullable error) { + [request getMapItemWithCompletionHandler:^(MKMapItem *_Nullable mapItem, NSError *_Nullable error) { if (error != nil) { NSLog(@"[ERROR] Cannot get POI details: %@", error.localizedDescription); return; } - + MKMapFeatureAnnotation *featureAnnotation = (MKMapFeatureAnnotation *)annotation; NSDictionary *event = @{ - @"name": NULL_IF_NIL(mapItem.name), - @"featureType": @(featureAnnotation.featureType), - @"pointOfInterestCategory": NULL_IF_NIL(featureAnnotation.pointOfInterestCategory), - @"phoneNumber": NULL_IF_NIL(mapItem.phoneNumber), - @"url": NULL_IF_NIL(mapItem.url.absoluteString), - @"place": [TiMapUtils dictionaryFromPlacemark:mapItem.placemark], - @"latitude": @(annotation.coordinate.latitude), - @"longitude": @(annotation.coordinate.longitude) + @"name" : NULL_IF_NIL(mapItem.name), + @"featureType" : @(featureAnnotation.featureType), + @"pointOfInterestCategory" : NULL_IF_NIL(featureAnnotation.pointOfInterestCategory), + @"phoneNumber" : NULL_IF_NIL(mapItem.phoneNumber), + @"url" : NULL_IF_NIL(mapItem.url.absoluteString), + @"place" : [TiMapUtils dictionaryFromPlacemark:mapItem.placemark], + @"latitude" : @(annotation.coordinate.latitude), + @"longitude" : @(annotation.coordinate.longitude) }; - + [[self proxy] fireEvent:@"poiclick" withObject:event]; }]; } From 93239bd1e64192f46c925f17ea51edea78ad61e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Wed, 21 Sep 2022 14:59:03 +0200 Subject: [PATCH 03/26] chore: bump version --- ios/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/manifest b/ios/manifest index 5fc32659..fb3ca147 100644 --- a/ios/manifest +++ b/ios/manifest @@ -3,7 +3,7 @@ # during compilation, packaging, distribution, etc. # -version: 7.0.0 +version: 7.1.0 apiversion: 2 architectures: arm64 x86_64 description: External version of Map module From a31f70447ff9d9d3bf620a1385d16f11616f4c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Wed, 7 Dec 2022 19:31:20 +0100 Subject: [PATCH 04/26] fix: fix typo --- ios/Classes/TiMapModule.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Classes/TiMapModule.m b/ios/Classes/TiMapModule.m index 00fc9e4c..772c8b07 100644 --- a/ios/Classes/TiMapModule.m +++ b/ios/Classes/TiMapModule.m @@ -165,7 +165,7 @@ - (void)lookAroundViewControllerDidPresentFullScreen:(MKLookAroundViewController #if IS_SDK_IOS_16 MAKE_SYSTEM_PROP(FEATURE_TERRITORIES, MKMapFeatureOptionTerritories); MAKE_SYSTEM_PROP(FEATURE_PHYSICAL_FEATURES, MKMapFeatureOptionPhysicalFeatures); -MAKE_SYSTEM_PROP(FEATURE_TYPE_POINT_OF_INTEREST, MKMapFeatureTypePointOfInterest); +MAKE_SYSTEM_PROP(FEATURE_TYPE_POINT_OF_INTEREST, MKMapFeatureOptionPointsOfInterest); #endif @end From 2dbd6a69111808e1268816f0cf014429271924fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Wed, 7 Dec 2022 19:56:26 +0100 Subject: [PATCH 05/26] feat: add documentation --- apidoc/Circle.yml | 10 +++++++ apidoc/Map.yml | 57 +++++++++++++++++++++++++++++++++++++ apidoc/View.yml | 59 +++++++++++++++++++++++++++++++++++++-- ios/Classes/TiMapModule.m | 4 --- 4 files changed, 124 insertions(+), 6 deletions(-) diff --git a/apidoc/Circle.yml b/apidoc/Circle.yml index b7f43b5b..9b123c5c 100644 --- a/apidoc/Circle.yml +++ b/apidoc/Circle.yml @@ -22,6 +22,16 @@ properties: type: Number optional: true + - name: blendMode + summary: The blend mode to apply to the overlay. + availability: creation + type: Number + constants: Titanium.UI.BLEND_MODE_NORMAL_* + platforms: [iphone, ipad, macos] + osver: { ios: { min: "16.0"} } + since: "12.0.0" + optional: true + - name: fillColor summary: | Color to use when shading the circle, as a color name or hex triplet. diff --git a/apidoc/Map.yml b/apidoc/Map.yml index 092c98c5..9cf981a6 100644 --- a/apidoc/Map.yml +++ b/apidoc/Map.yml @@ -435,6 +435,34 @@ properties: exclude-platforms: [android] since: "6.3.0" + - name: FEATURE_TERRITORIES + summary: | + The option that represents territorial boundaries such as a national border, + a state boundary, or a neighborhood. + type: Number + permission: read-only + osver: { ios: { min: "16.0" } } + exclude-platforms: [iphone, ipad, macos] + since: "12.0.0" + + - name: FEATURE_PHYSICAL_FEATURES + summary: | + The option that represents physical map features such as mountain ranges, rivers, + and ocean basins. + type: Number + permission: read-only + osver: { ios: { min: "16.0" } } + exclude-platforms: [iphone, ipad, macos] + since: "12.0.0" + + - name: FEATURE_TYPE_POINT_OF_INTEREST + summary: The option that represents points of interest such as museums, cafes, parks, or schools. + type: Number + permission: read-only + osver: { ios: { min: "16.0" } } + exclude-platforms: [iphone, ipad, macos] + since: "12.0.0" + - name: ANNOTATION_VIEW_COLLISION_MODE_RECTANGLE summary: | Constant indicating that the full collision frame rectangle should be used for @@ -468,6 +496,35 @@ methods: since: "3.1.1" platforms: [android] + - name: getLookAroundImage + summary: A utility function that you use to create a static image from a LookAround scene. + parameters: + - name: callback + summary: Function to be called upon completion (either success with an image or an error). + type: Callback + optional: false + - name: latitude + summary: Latitude of the preferred region. + type: Number + - name: longitude + summary: Longitude of the preferred region. + type: Number + osver: { ios: { min: "16.0"} } + since: "12.0.0" + platforms: [iphone, ipad, macos] + + - name: openLookAroundDialog + summary: Opens a LookAround window modally. + parameters: + - name: latitude + summary: Latitude of the preferred region. + type: Number + - name: longitude + summary: Longitude of the preferred region. + type: Number + osver: { ios: { min: "16.0"} } + since: "12.0.0" + platforms: [iphone, ipad, macos] examples: - title: Basic Map Example diff --git a/apidoc/View.yml b/apidoc/View.yml index 04109548..8f3764cb 100644 --- a/apidoc/View.yml +++ b/apidoc/View.yml @@ -597,11 +597,56 @@ events: since: { android: "7.3.0" } properties: - name: latitude - summary: latitude of the point on the ground that was pressed. + summary: Latitude of the point on the ground that was pressed. type: Number - name: longitude - summary: longitude of the point on the ground that was pressed. + summary: Longitude of the point on the ground that was pressed. + type: Number + + - name: poiclick + summary: Fired when the user selects a Point of Interest (e.g. restaurant or hotel). + description: | + Make sure to use the property to define + annotations tha should be selectable. + since: "12.0.0" + osver: { ios: "16.0.0" } + platforms: [iphone, ipad, macos] + properties: + - name: name + summary: The descriptive name associated with the map item. + type: String + + - name: featureType + summary: | + The type of map feature this annotation represents. See the [Apple docs](https://developer.apple.com/documentation/mapkit/mkmapfeaturetype) + for all possible enum values. + type: Number + + - name: pointOfInterestCategory + summary: | + The point-of-interest category for the map item. See the [Apple docs](https://developer.apple.com/documentation/mapkit/mkpointofinterestcategory) + for all possible enum values. + type: Number + + - name: phoneNumber + summary: The phone number associated with a business at the specified location. + type: String + + - name: url + summary: The URL associated with the specified location. + type: String + + - name: place + summary: The placemark object containing the location information. + type: Object + + - name: latitude + summary: Latitude of the annotation that was selected. + type: Number + + - name: longitude + summary: Longitude of the annotation that was selected. type: Number properties: @@ -958,6 +1003,16 @@ properties: since: "5.0.2" platforms: [android] + - name: selectableMapFeatures + summary: The property that describes which selectable features the map responds to. + description: | + Pass one or more of , + or as an array to make these features selectable. + type: Array + osver: { ios: { min: "16.0" } } + platforms: [iphone, ipad, macos] + since: "12.0.0" + --- name: MapLocationTypeV2 summary: | diff --git a/ios/Classes/TiMapModule.m b/ios/Classes/TiMapModule.m index 772c8b07..dd006ede 100644 --- a/ios/Classes/TiMapModule.m +++ b/ios/Classes/TiMapModule.m @@ -89,16 +89,12 @@ - (void)openLookAroundDialog:(id)args return; } - KrollCallback *callback = (KrollCallback *)args[@"callback"]; CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([TiUtils doubleValue:args[@"latitude"]], [TiUtils doubleValue:args[@"longitude"]]); MKLookAroundSceneRequest *request = [[MKLookAroundSceneRequest alloc] initWithCoordinate:coordinate]; [request getSceneWithCompletionHandler:^(MKLookAroundScene *_Nullable_result scene, NSError *_Nullable error) { if (error != nil) { - [callback call:@[ @{@"success" : @(NO), - @"error" : error.localizedDescription} ] - thisObject:self]; return; } From f5ba682e68ad00a70f82c4fb94bda078e9ad8377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Thu, 8 Dec 2022 14:49:38 +0100 Subject: [PATCH 06/26] fix: remove osver from event --- apidoc/View.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apidoc/View.yml b/apidoc/View.yml index 8f3764cb..cb75737c 100644 --- a/apidoc/View.yml +++ b/apidoc/View.yml @@ -608,9 +608,8 @@ events: summary: Fired when the user selects a Point of Interest (e.g. restaurant or hotel). description: | Make sure to use the property to define - annotations tha should be selectable. + annotations tha should be selectable. Available in iOS 16+ since: "12.0.0" - osver: { ios: "16.0.0" } platforms: [iphone, ipad, macos] properties: - name: name From 49c650444b69413d55ba37438712ec31736a8b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Thu, 8 Dec 2022 14:51:42 +0100 Subject: [PATCH 07/26] fix(docs): fix typos --- apidoc/Circle.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apidoc/Circle.yml b/apidoc/Circle.yml index 9b123c5c..e0e99726 100644 --- a/apidoc/Circle.yml +++ b/apidoc/Circle.yml @@ -26,9 +26,9 @@ properties: summary: The blend mode to apply to the overlay. availability: creation type: Number - constants: Titanium.UI.BLEND_MODE_NORMAL_* + constants: Titanium.UI.BLEND_MODE_* platforms: [iphone, ipad, macos] - osver: { ios: { min: "16.0"} } + osver: { ios: { min: "16.0" } } since: "12.0.0" optional: true From bcaab7300d5ea734ad7f48cb8541f3a040b9756f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Thu, 8 Dec 2022 14:54:38 +0100 Subject: [PATCH 08/26] fix(docs): workaround core SDK docs issue --- apidoc/Circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apidoc/Circle.yml b/apidoc/Circle.yml index e0e99726..48f603c9 100644 --- a/apidoc/Circle.yml +++ b/apidoc/Circle.yml @@ -24,9 +24,9 @@ properties: - name: blendMode summary: The blend mode to apply to the overlay. + description: Use one of the `Ti.UI.BLEND_MODE_*` constants! availability: creation type: Number - constants: Titanium.UI.BLEND_MODE_* platforms: [iphone, ipad, macos] osver: { ios: { min: "16.0" } } since: "12.0.0" From 5a734836f9f3603820fa3c4f6a8358a4c556319e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Wed, 14 Dec 2022 23:21:13 +0100 Subject: [PATCH 09/26] fix: guard invalid blob creation Fixes: Uncaught Error: Could not copy bitmap to parcel blob. --- android/src/ti/map/AnnotationProxy.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/android/src/ti/map/AnnotationProxy.java b/android/src/ti/map/AnnotationProxy.java index 8a584f48..45e067c9 100644 --- a/android/src/ti/map/AnnotationProxy.java +++ b/android/src/ti/map/AnnotationProxy.java @@ -324,6 +324,7 @@ private void handleImage(Object image) markerOptions.icon(BitmapDescriptorFactory.fromBitmap(bitmap)); setIconImageDimensions(bitmap.getWidth(), bitmap.getHeight()); } catch (Exception e) { + Log.e(TAG, e.getMessage()); } return; } @@ -333,8 +334,12 @@ private void handleImage(Object image) if (image instanceof TiBlob) { Bitmap bitmap = ((TiBlob) image).getImage(); if (bitmap != null) { - markerOptions.icon(BitmapDescriptorFactory.fromBitmap(bitmap)); - setIconImageDimensions(bitmap.getWidth(), bitmap.getHeight()); + try { + markerOptions.icon(BitmapDescriptorFactory.fromBitmap(bitmap)); + setIconImageDimensions(bitmap.getWidth(), bitmap.getHeight()); + } catch (Exception e) { + Log.e(TAG, e.getMessage()); + } return; } } From 15759998177e5274c8f1f38c25e75a8053d07293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Wed, 14 Dec 2022 23:23:33 +0100 Subject: [PATCH 10/26] chore(android): bump version --- android/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/manifest b/android/manifest index 1380c543..136e47af 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 5.5.0 +version: 5.5.1 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 x86_64 description: External version of Map module using native Google Maps library From 384719b320e38f1ffb521f03ee1928c471c2a4d1 Mon Sep 17 00:00:00 2001 From: m1ga Date: Fri, 17 Feb 2023 13:47:46 +0100 Subject: [PATCH 11/26] feat(android): update libraries --- android/build.gradle | 4 ++-- android/manifest | 2 +- android/src/ti/map/TiMarker.java | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index a9172ed4..b3058e17 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -4,8 +4,8 @@ dependencies { implementation 'com.google.android.gms:play-services-maps:18.1.0' // https://github.com/googlemaps/android-maps-utils/releases - implementation 'com.google.maps.android:android-maps-utils:2.4.0' + implementation 'com.google.maps.android:android-maps-utils:3.4.0' // https://developer.android.com/jetpack/androidx/releases/fragment - implementation 'androidx.fragment:fragment:1.5.2' + implementation 'androidx.fragment:fragment:1.5.5' } diff --git a/android/manifest b/android/manifest index 136e47af..427791bb 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 5.5.1 +version: 5.5.2 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 x86_64 description: External version of Map module using native Google Maps library diff --git a/android/src/ti/map/TiMarker.java b/android/src/ti/map/TiMarker.java index f4068607..449787f7 100644 --- a/android/src/ti/map/TiMarker.java +++ b/android/src/ti/map/TiMarker.java @@ -74,4 +74,13 @@ public String getSnippet() } return null; } + + @Override + public Float getZIndex() + { + if (proxy != null) { + return proxy.getMarkerOptions().getZIndex(); + } + return null; + } } From 8636692c61328f1d438987075ed383adb3ebbfc4 Mon Sep 17 00:00:00 2001 From: m1ga Date: Thu, 4 May 2023 12:10:01 +0200 Subject: [PATCH 12/26] fix(android): use activity in toColor --- android/src/ti/map/CircleProxy.java | 13 +++++++++---- android/src/ti/map/PolygonProxy.java | 15 +++++++++------ android/src/ti/map/PolylineProxy.java | 14 +++++++++----- android/src/ti/map/RouteProxy.java | 9 ++++++--- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/android/src/ti/map/CircleProxy.java b/android/src/ti/map/CircleProxy.java index 7d3888f7..3946a8bd 100644 --- a/android/src/ti/map/CircleProxy.java +++ b/android/src/ti/map/CircleProxy.java @@ -6,6 +6,7 @@ */ package ti.map; +import android.app.Activity; import android.graphics.Color; import android.os.Message; import android.view.ViewGroup; @@ -146,6 +147,7 @@ public boolean handleMessage(Message msg) public void processOptions() { options = new CircleOptions(); + Activity currentActivity = TiApplication.getAppCurrentActivity(); if (hasProperty(MapModule.PROPERTY_CENTER)) { options.center(TiMapUtils.parseLocation(getProperty(MapModule.PROPERTY_CENTER))); @@ -160,11 +162,13 @@ public void processOptions() } if (hasProperty(MapModule.PROPERTY_STROKE_COLOR)) { - options.strokeColor(alphaColor(TiConvert.toColor((String) getProperty(MapModule.PROPERTY_STROKE_COLOR)))); + options.strokeColor( + alphaColor(TiConvert.toColor((String) getProperty(MapModule.PROPERTY_STROKE_COLOR), currentActivity))); } if (hasProperty(MapModule.PROPERTY_FILL_COLOR)) { - options.fillColor(alphaColor(TiConvert.toColor((String) getProperty(MapModule.PROPERTY_FILL_COLOR)))); + options.fillColor( + alphaColor(TiConvert.toColor((String) getProperty(MapModule.PROPERTY_FILL_COLOR), currentActivity))); } if (hasProperty(MapModule.PROPERTY_ZINDEX)) { @@ -184,6 +188,7 @@ public void processOptions() public void onPropertyChanged(String name, Object value) { super.onPropertyChanged(name, value); + Activity currentActivity = TiApplication.getAppCurrentActivity(); if (circle == null) { return; } @@ -203,12 +208,12 @@ else if (name.equals(MapModule.PROPERTY_STROKE_WIDTH)) { else if (name.equals(MapModule.PROPERTY_STROKE_COLOR)) { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_STROKE_COLOR), - TiConvert.toColor((String) value)); + TiConvert.toColor((String) value, currentActivity)); } else if (name.equals(MapModule.PROPERTY_FILL_COLOR)) { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_FILL_COLOR), - TiConvert.toColor((String) value)); + TiConvert.toColor((String) value, currentActivity)); } else if (name.equals(MapModule.PROPERTY_ZINDEX)) { diff --git a/android/src/ti/map/PolygonProxy.java b/android/src/ti/map/PolygonProxy.java index 3fd766d2..45df62c4 100644 --- a/android/src/ti/map/PolygonProxy.java +++ b/android/src/ti/map/PolygonProxy.java @@ -6,6 +6,7 @@ */ package ti.map; +import android.app.Activity; import android.os.Message; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.Polygon; @@ -18,6 +19,7 @@ import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.kroll.common.AsyncResult; import org.appcelerator.kroll.common.TiMessenger; +import org.appcelerator.titanium.TiApplication; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.util.TiConvert; import ti.map.Shape.IShape; @@ -109,7 +111,7 @@ public void processOptions() { options = new PolygonOptions(); - + Activity currentActivity = TiApplication.getAppCurrentActivity(); if (hasProperty(MapModule.PROPERTY_POINTS)) { processPoints(getProperty(MapModule.PROPERTY_POINTS), false); } @@ -119,7 +121,8 @@ public void processOptions() } if (hasProperty(MapModule.PROPERTY_STROKE_COLOR)) { - options.strokeColor(TiConvert.toColor((String) getProperty(MapModule.PROPERTY_STROKE_COLOR))); + options.strokeColor( + TiConvert.toColor((String) getProperty(MapModule.PROPERTY_STROKE_COLOR), currentActivity)); } if (hasProperty(MapModule.PROPERTY_STROKE_WIDTH)) { @@ -127,7 +130,7 @@ public void processOptions() } if (hasProperty(MapModule.PROPERTY_FILL_COLOR)) { - options.fillColor(TiConvert.toColor((String) getProperty(MapModule.PROPERTY_FILL_COLOR))); + options.fillColor(TiConvert.toColor((String) getProperty(MapModule.PROPERTY_FILL_COLOR), currentActivity)); } if (hasProperty(MapModule.PROPERTY_ZINDEX)) { @@ -266,7 +269,7 @@ public void onPropertyChanged(String name, Object value) { super.onPropertyChanged(name, value); - + Activity currentActivity = TiApplication.getAppCurrentActivity(); if (polygon == null) { return; } @@ -282,12 +285,12 @@ else if (name.equals(MapModule.PROPERTY_POINTS)) { else if (name.equals(MapModule.PROPERTY_STROKE_COLOR)) { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_STROKE_COLOR), - TiConvert.toColor((String) value)); + TiConvert.toColor((String) value, currentActivity)); } else if (name.equals(MapModule.PROPERTY_FILL_COLOR)) { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_FILL_COLOR), - TiConvert.toColor((String) value)); + TiConvert.toColor((String) value, currentActivity)); } else if (name.equals(MapModule.PROPERTY_ZINDEX)) { diff --git a/android/src/ti/map/PolylineProxy.java b/android/src/ti/map/PolylineProxy.java index ef677f05..097fd3c3 100644 --- a/android/src/ti/map/PolylineProxy.java +++ b/android/src/ti/map/PolylineProxy.java @@ -6,6 +6,7 @@ */ package ti.map; +import android.app.Activity; import android.os.Message; import com.google.android.gms.maps.model.Dash; import com.google.android.gms.maps.model.Dot; @@ -24,6 +25,7 @@ import org.appcelerator.kroll.common.AsyncResult; import org.appcelerator.kroll.common.Log; import org.appcelerator.kroll.common.TiMessenger; +import org.appcelerator.titanium.TiApplication; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.util.TiConvert; import ti.map.Shape.IShape; @@ -134,6 +136,7 @@ public void processOptions() { options = new PolylineOptions(); + Activity currentActivity = TiApplication.getAppCurrentActivity(); // (int) strokeColor // (float) strokeWidth // (int) fillColor @@ -144,12 +147,13 @@ public void processOptions() } if (hasProperty(MapModule.PROPERTY_STROKE_COLOR)) { - options.color(TiConvert.toColor((String) getProperty(MapModule.PROPERTY_STROKE_COLOR))); + options.color(TiConvert.toColor((String) getProperty(MapModule.PROPERTY_STROKE_COLOR), currentActivity)); } // alternate API if (hasProperty(PolylineProxy.PROPERTY_STROKE_COLOR2)) { - options.color(TiConvert.toColor((String) getProperty(PolylineProxy.PROPERTY_STROKE_COLOR2))); + options.color( + TiConvert.toColor((String) getProperty(PolylineProxy.PROPERTY_STROKE_COLOR2), currentActivity)); } if (hasProperty(MapModule.PROPERTY_STROKE_WIDTH)) { @@ -243,7 +247,7 @@ public void onPropertyChanged(String name, Object value) { super.onPropertyChanged(name, value); - + Activity currentActivity = TiApplication.getAppCurrentActivity(); if (polyline == null) { return; } @@ -264,12 +268,12 @@ else if (name.equals(PolylineProxy.PROPERTY_STROKE_WIDTH2)) { else if (name.equals(MapModule.PROPERTY_STROKE_COLOR)) { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_STROKE_COLOR), - TiConvert.toColor((String) value)); + TiConvert.toColor((String) value, currentActivity)); } // alternate API else if (name.equals(PolylineProxy.PROPERTY_STROKE_COLOR2)) { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_STROKE_COLOR), - TiConvert.toColor((String) value)); + TiConvert.toColor((String) value, currentActivity)); } else if (name.equals(PolylineProxy.PROPERTY_ZINDEX)) { diff --git a/android/src/ti/map/RouteProxy.java b/android/src/ti/map/RouteProxy.java index 951c2b45..3fe01454 100644 --- a/android/src/ti/map/RouteProxy.java +++ b/android/src/ti/map/RouteProxy.java @@ -18,6 +18,7 @@ import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.kroll.common.AsyncResult; import org.appcelerator.kroll.common.TiMessenger; +import org.appcelerator.titanium.TiApplication; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.util.TiConvert; @@ -86,7 +87,8 @@ public void processOptions() } if (hasProperty(TiC.PROPERTY_COLOR)) { - options.color(TiConvert.toColor((String) getProperty(TiC.PROPERTY_COLOR))); + options.color( + TiConvert.toColor((String) getProperty(TiC.PROPERTY_COLOR), TiApplication.getAppCurrentActivity())); } } @@ -160,8 +162,9 @@ else if (name.equals(MapModule.PROPERTY_POINTS)) { } else if (name.equals(TiC.PROPERTY_COLOR)) { - TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_COLOR), - TiConvert.toColor((String) value)); + TiMessenger.sendBlockingMainMessage( + getMainHandler().obtainMessage(MSG_SET_COLOR), + TiConvert.toColor((String) value, TiApplication.getAppCurrentActivity())); } else if (name.equals(TiC.PROPERTY_WIDTH)) { From c20183a293db9d4b6c6a883bf3d252a8430de6d1 Mon Sep 17 00:00:00 2001 From: m1ga Date: Fri, 12 May 2023 14:33:32 +0200 Subject: [PATCH 13/26] version --- android/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/manifest b/android/manifest index 136e47af..427791bb 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 5.5.1 +version: 5.5.2 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 x86_64 description: External version of Map module using native Google Maps library From e4c3692e7127e6b679c081a92d18e91727a18441 Mon Sep 17 00:00:00 2001 From: m1ga Date: Wed, 23 Aug 2023 21:52:12 +0200 Subject: [PATCH 14/26] update utils --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index b3058e17..a14c545e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -4,7 +4,7 @@ dependencies { implementation 'com.google.android.gms:play-services-maps:18.1.0' // https://github.com/googlemaps/android-maps-utils/releases - implementation 'com.google.maps.android:android-maps-utils:3.4.0' + implementation 'com.google.maps.android:android-maps-utils:3.5.3' // https://developer.android.com/jetpack/androidx/releases/fragment implementation 'androidx.fragment:fragment:1.5.5' From a550593c90e9f0d4bae95cb8376bc00c4689d672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Sat, 26 Aug 2023 21:37:18 +0200 Subject: [PATCH 15/26] feat(ios): add poideselect event --- apidoc/View.yml | 5 +++++ ios/Classes/TiMapView.m | 13 +++++++++++++ ios/manifest | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/apidoc/View.yml b/apidoc/View.yml index cb75737c..b0b46440 100644 --- a/apidoc/View.yml +++ b/apidoc/View.yml @@ -603,6 +603,11 @@ events: - name: longitude summary: Longitude of the point on the ground that was pressed. type: Number + + - name: poideselect + summary: Fired when the user deselects a Point of Interest (e.g. restaurant or hotel). + since: "12.2.0" + platforms: [iphone, ipad, macos] - name: poiclick summary: Fired when the user selects a Point of Interest (e.g. restaurant or hotel). diff --git a/ios/Classes/TiMapView.m b/ios/Classes/TiMapView.m index 46ed4380..4195b662 100644 --- a/ios/Classes/TiMapView.m +++ b/ios/Classes/TiMapView.m @@ -1175,6 +1175,19 @@ - (void)findCalloutView:(UIView *)node } } +#if IS_SDK_IOS_16 +- (void)mapView:(MKMapView *)mapView didDeselectAnnotation:(id)annotation +{ + if (![TiUtils isIOSVersionOrGreater:@"16.0"]) { + return; + } + + if ([annotation isKindOfClass:MKMapFeatureAnnotation.class]) { + [self.proxy fireEvent:@"poideselect"]; + } +} +#endif + - (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view { if ([view conformsToProtocol:@protocol(TiMapAnnotation)]) { diff --git a/ios/manifest b/ios/manifest index fb3ca147..4bdd1a61 100644 --- a/ios/manifest +++ b/ios/manifest @@ -3,7 +3,7 @@ # during compilation, packaging, distribution, etc. # -version: 7.1.0 +version: 7.2.0 apiversion: 2 architectures: arm64 x86_64 description: External version of Map module From 8e668320d6aa288e52276871b7ca6834b50c7ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Sun, 27 Aug 2023 09:50:47 +0200 Subject: [PATCH 16/26] chore: update annotation handling, handle deselect --- ios/Classes/TiMapFeatureAnnotationProxy.h | 22 +++++++++++++++++ ios/Classes/TiMapFeatureAnnotationProxy.m | 29 +++++++++++++++++++++++ ios/Classes/TiMapView.m | 4 ++++ ios/map.xcodeproj/project.pbxproj | 8 +++++++ 4 files changed, 63 insertions(+) create mode 100644 ios/Classes/TiMapFeatureAnnotationProxy.h create mode 100644 ios/Classes/TiMapFeatureAnnotationProxy.m diff --git a/ios/Classes/TiMapFeatureAnnotationProxy.h b/ios/Classes/TiMapFeatureAnnotationProxy.h new file mode 100644 index 00000000..92eded87 --- /dev/null +++ b/ios/Classes/TiMapFeatureAnnotationProxy.h @@ -0,0 +1,22 @@ +/** + * Axway Titanium + * Copyright (c) 2009-present by Axway Appcelerator. All Rights Reserved. + * Licensed under the terms of the Apache Public License + * Please see the LICENSE included with this distribution for details. + */ + +#import "TiProxy.h" +#import + +@interface TiMapFeatureAnnotationProxy : TiProxy { +#if IS_SDK_IOS_16 + MKMapFeatureAnnotation *_annotation; +#endif +} + +#if IS_SDK_IOS_16 +- (id)_initWithPageContext:(id)context andAnnotation:(MKMapFeatureAnnotation *)annotation; +- (MKMapFeatureAnnotation *)annotation; +#endif + +@end diff --git a/ios/Classes/TiMapFeatureAnnotationProxy.m b/ios/Classes/TiMapFeatureAnnotationProxy.m new file mode 100644 index 00000000..9e8822c6 --- /dev/null +++ b/ios/Classes/TiMapFeatureAnnotationProxy.m @@ -0,0 +1,29 @@ +/** + * Axway Titanium + * Copyright (c) 2009-present by Axway Appcelerator. All Rights Reserved. + * Licensed under the terms of the Apache Public License + * Please see the LICENSE included with this distribution for details. + */ + +#import "TiMapFeatureAnnotationProxy.h" +#import + +@implementation TiMapFeatureAnnotationProxy + +#if IS_SDK_IOS_16 +- (id)_initWithPageContext:(id)context andAnnotation:(MKMapFeatureAnnotation *)annotation +{ + if (self = [super _initWithPageContext:pageContext]) { + _annotation = annotation; + } + + return self; +} + +- (MKMapFeatureAnnotation *)annotation +{ + return _annotation; +} +#endif + +@end diff --git a/ios/Classes/TiMapView.m b/ios/Classes/TiMapView.m index 4195b662..fe41c818 100644 --- a/ios/Classes/TiMapView.m +++ b/ios/Classes/TiMapView.m @@ -10,6 +10,7 @@ #import "TiMapCircleProxy.h" #import "TiMapCustomAnnotationView.h" #import "TiMapImageAnnotationView.h" +#import "TiMapFeatureAnnotationProxy.h" #import "TiMapImageOverlayProxy.h" #import "TiMapMarkerAnnotationView.h" #import "TiMapModule.h" @@ -386,6 +387,8 @@ - (void)deselectAnnotation:(id)args } } else if ([args isKindOfClass:[TiMapAnnotationProxy class]]) { [[self map] deselectAnnotation:args animated:animate]; + } else if ([args isKindOfClass:[TiMapFeatureAnnotationProxy class]]) { + [[self map] deselectAnnotation:[(TiMapFeatureAnnotationProxy *)args annotation] animated:animate]; } } @@ -1128,6 +1131,7 @@ - (void)mapView:(MKMapView *)mapView didSelectAnnotation:(id)annot MKMapFeatureAnnotation *featureAnnotation = (MKMapFeatureAnnotation *)annotation; NSDictionary *event = @{ + @"annotation": [[TiMapFeatureAnnotationProxy alloc] _initWithPageContext:[(TiMapViewProxy *)[self proxy] pageContext] andAnnotation:featureAnnotation], @"name" : NULL_IF_NIL(mapItem.name), @"featureType" : @(featureAnnotation.featureType), @"pointOfInterestCategory" : NULL_IF_NIL(featureAnnotation.pointOfInterestCategory), diff --git a/ios/map.xcodeproj/project.pbxproj b/ios/map.xcodeproj/project.pbxproj index 1ec8edf9..2fd7b6d7 100644 --- a/ios/map.xcodeproj/project.pbxproj +++ b/ios/map.xcodeproj/project.pbxproj @@ -35,6 +35,8 @@ 27A609EA19F5927000CA150A /* WildcardGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 27A609E919F5927000CA150A /* WildcardGestureRecognizer.m */; }; 27A609EC19F5B84000CA150A /* TiMapCircleProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 27A609EB19F5B84000CA150A /* TiMapCircleProxy.m */; }; 27A609F019F711B700CA150A /* TiMapPolylineProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 27A609EF19F711B700CA150A /* TiMapPolylineProxy.m */; }; + 3A155BE82A9B35C000247646 /* TiMapFeatureAnnotationProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A155BE62A9B35C000247646 /* TiMapFeatureAnnotationProxy.h */; }; + 3A155BE92A9B35C000247646 /* TiMapFeatureAnnotationProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A155BE72A9B35C000247646 /* TiMapFeatureAnnotationProxy.m */; }; 815136F31D355BF5009E3E2C /* TiMapSnapshotterProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 815136F11D355BF5009E3E2C /* TiMapSnapshotterProxy.h */; }; 815136F41D355BF5009E3E2C /* TiMapSnapshotterProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 815136F21D355BF5009E3E2C /* TiMapSnapshotterProxy.m */; }; AA747D9F0F9514B9006C5449 /* TiMap_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* TiMap_Prefix.pch */; }; @@ -94,6 +96,8 @@ 27A609ED19F5B85900CA150A /* TiMapCircleProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TiMapCircleProxy.h; path = Classes/TiMapCircleProxy.h; sourceTree = ""; }; 27A609EE19F7112C00CA150A /* TiMapPolylineProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TiMapPolylineProxy.h; path = Classes/TiMapPolylineProxy.h; sourceTree = ""; }; 27A609EF19F711B700CA150A /* TiMapPolylineProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiMapPolylineProxy.m; path = Classes/TiMapPolylineProxy.m; sourceTree = ""; }; + 3A155BE62A9B35C000247646 /* TiMapFeatureAnnotationProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TiMapFeatureAnnotationProxy.h; path = Classes/TiMapFeatureAnnotationProxy.h; sourceTree = ""; }; + 3A155BE72A9B35C000247646 /* TiMapFeatureAnnotationProxy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = TiMapFeatureAnnotationProxy.m; path = Classes/TiMapFeatureAnnotationProxy.m; sourceTree = ""; }; 815136F11D355BF5009E3E2C /* TiMapSnapshotterProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiMapSnapshotterProxy.h; path = Classes/TiMapSnapshotterProxy.h; sourceTree = ""; }; 815136F21D355BF5009E3E2C /* TiMapSnapshotterProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiMapSnapshotterProxy.m; path = Classes/TiMapSnapshotterProxy.m; sourceTree = ""; }; AA747D9E0F9514B9006C5449 /* TiMap_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiMap_Prefix.pch; sourceTree = SOURCE_ROOT; }; @@ -236,6 +240,8 @@ CED651C117D7AA21007C2954 /* TiMapPinAnnotationView.m */, DB0CC9FF2010840900597F24 /* TiMapMarkerAnnotationView.h */, DB0CC9FE2010840900597F24 /* TiMapMarkerAnnotationView.m */, + 3A155BE62A9B35C000247646 /* TiMapFeatureAnnotationProxy.h */, + 3A155BE72A9B35C000247646 /* TiMapFeatureAnnotationProxy.m */, ); name = Annotation; sourceTree = ""; @@ -349,6 +355,7 @@ CED651D017D7AA21007C2954 /* TiMapViewProxy.h in Headers */, DB0CCA062010843000597F24 /* TiMapOverlayPattern.h in Headers */, 27A609E619F54FC300CA150A /* TiMapPolygonProxy.h in Headers */, + 3A155BE82A9B35C000247646 /* TiMapFeatureAnnotationProxy.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -439,6 +446,7 @@ 27A609EA19F5927000CA150A /* WildcardGestureRecognizer.m in Sources */, 815136F41D355BF5009E3E2C /* TiMapSnapshotterProxy.m in Sources */, CED651CB17D7AA21007C2954 /* TiMapImageAnnotationView.m in Sources */, + 3A155BE92A9B35C000247646 /* TiMapFeatureAnnotationProxy.m in Sources */, CED651CD17D7AA21007C2954 /* TiMapPinAnnotationView.m in Sources */, 27A609EC19F5B84000CA150A /* TiMapCircleProxy.m in Sources */, CEE33CF419EC4C150005E745 /* TiMapUtils.m in Sources */, From ba1f947c398ad9479242427b10e079b256633df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Sun, 27 Aug 2023 09:52:59 +0200 Subject: [PATCH 17/26] fix: move imports --- ios/Classes/TiMapView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Classes/TiMapView.m b/ios/Classes/TiMapView.m index fe41c818..f19fbb9b 100644 --- a/ios/Classes/TiMapView.m +++ b/ios/Classes/TiMapView.m @@ -9,8 +9,8 @@ #import "TiMapAnnotationProxy.h" #import "TiMapCircleProxy.h" #import "TiMapCustomAnnotationView.h" -#import "TiMapImageAnnotationView.h" #import "TiMapFeatureAnnotationProxy.h" +#import "TiMapImageAnnotationView.h" #import "TiMapImageOverlayProxy.h" #import "TiMapMarkerAnnotationView.h" #import "TiMapModule.h" From f1cf64cfc9cfb19992d397ee4579dc21295405d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Sun, 27 Aug 2023 09:59:31 +0200 Subject: [PATCH 18/26] fix: fix typos --- ios/Classes/TiMapFeatureAnnotationProxy.m | 2 +- ios/Classes/TiMapView.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/Classes/TiMapFeatureAnnotationProxy.m b/ios/Classes/TiMapFeatureAnnotationProxy.m index 9e8822c6..1c409eea 100644 --- a/ios/Classes/TiMapFeatureAnnotationProxy.m +++ b/ios/Classes/TiMapFeatureAnnotationProxy.m @@ -16,7 +16,7 @@ - (id)_initWithPageContext:(id)context andAnnotation:(MKMapFeatureA if (self = [super _initWithPageContext:pageContext]) { _annotation = annotation; } - + return self; } diff --git a/ios/Classes/TiMapView.m b/ios/Classes/TiMapView.m index f19fbb9b..610680e3 100644 --- a/ios/Classes/TiMapView.m +++ b/ios/Classes/TiMapView.m @@ -1131,7 +1131,7 @@ - (void)mapView:(MKMapView *)mapView didSelectAnnotation:(id)annot MKMapFeatureAnnotation *featureAnnotation = (MKMapFeatureAnnotation *)annotation; NSDictionary *event = @{ - @"annotation": [[TiMapFeatureAnnotationProxy alloc] _initWithPageContext:[(TiMapViewProxy *)[self proxy] pageContext] andAnnotation:featureAnnotation], + @"annotation" : [[TiMapFeatureAnnotationProxy alloc] _initWithPageContext:[(TiMapViewProxy *)[self proxy] pageContext] andAnnotation:featureAnnotation], @"name" : NULL_IF_NIL(mapItem.name), @"featureType" : @(featureAnnotation.featureType), @"pointOfInterestCategory" : NULL_IF_NIL(featureAnnotation.pointOfInterestCategory), From c72c4301343275ef179fba373990d20fb09cb0b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Wed, 13 Sep 2023 19:57:57 +0200 Subject: [PATCH 19/26] fix(macos): fix blend mode --- ios/Classes/TiMapCircleProxy.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Classes/TiMapCircleProxy.m b/ios/Classes/TiMapCircleProxy.m index 879afa2a..e12f4c4d 100644 --- a/ios/Classes/TiMapCircleProxy.m +++ b/ios/Classes/TiMapCircleProxy.m @@ -52,7 +52,7 @@ - (MKCircleRenderer *)circleRenderer circleRenderer = [[[MKCircleRenderer alloc] initWithCircle:[MKCircle circleWithCenterCoordinate:center radius:radius]] retain]; [circleRenderer setFillColor:fillColor ? [fillColor color] : [UIColor blackColor]]; -#if IS_SDK_IOS_16 +#if IS_SDK_IOS_16 && !TARGET_OS_MACCATALYST if ([TiUtils isIOSVersionOrGreater:@"16.0"] && blendMode > 0) { circleRenderer.blendMode = blendMode; } From 0e3db68b9c678e7a64f76f9e4066fdfc23faf019 Mon Sep 17 00:00:00 2001 From: m1ga Date: Wed, 13 Sep 2023 20:01:23 +0200 Subject: [PATCH 20/26] update fragment to match SDK --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index a14c545e..a323ad2b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -7,5 +7,5 @@ dependencies { implementation 'com.google.maps.android:android-maps-utils:3.5.3' // https://developer.android.com/jetpack/androidx/releases/fragment - implementation 'androidx.fragment:fragment:1.5.5' + implementation 'androidx.fragment:fragment:1.5.7' } From 42d6a1addc324b988118cf02d1da97611d6c6b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Wed, 13 Sep 2023 20:06:46 +0200 Subject: [PATCH 21/26] chore(android): bump version --- android/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/manifest b/android/manifest index 427791bb..190854b8 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 5.5.2 +version: 5.5.3 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 x86_64 description: External version of Map module using native Google Maps library From 6b5bdbc74b411ed12bab7535253f8dbae17aa098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Fri, 22 Sep 2023 21:23:50 +0200 Subject: [PATCH 22/26] feat(ios): add new search completion APIs --- apidoc/Map.yml | 138 +++++++++++++++++++++++++------- ios/Classes/TiMapModule.h | 3 +- ios/Classes/TiMapModule.m | 117 +++++++++++++++++++++++++++ ios/Classes/TiMapModuleAssets.m | 4 +- ios/manifest | 2 +- 5 files changed, 230 insertions(+), 34 deletions(-) diff --git a/apidoc/Map.yml b/apidoc/Map.yml index 9cf981a6..d26e601d 100644 --- a/apidoc/Map.yml +++ b/apidoc/Map.yml @@ -42,13 +42,14 @@ description: | ``` - - Instantiate the module with the `require('ti.map')` method, then make subsequent API calls with + - Instantiate the module with the `import Map from 'ti.map'` API, then make subsequent API calls with the new map object. ``` javascript - var Map = require('ti.map'); - var mapview = Map.createView({ - mapType: Map.NORMAL_TYPE + import Map from 'ti.map'; + + const mapView = Map.createView({ + mapType: Map.NORMAL_TYPE }); ``` @@ -99,12 +100,13 @@ description: | ``` - - Instantiate the module with the `require('ti.map')` method, then make subsequent API calls with + - Instantiate the module with the `import Map from 'ti.map'` API, then make subsequent API calls with the new map object. ``` javascript - var Map = require('ti.map'); - var mapview = Map.createView({ + import Map from 'ti.map'; + + const mapView = Map.createView({ mapType: Map.NORMAL_TYPE }); ``` @@ -495,6 +497,43 @@ methods: summary: Returns a code to indicate whether Google Play Services is available on the device. since: "3.1.1" platforms: [android] + + - name: search + summary: | + Uses the native `MKLocalSearchCompleter` class to search places for + a given input value. + description: | + Please use the `didUpdateResults` event to get updates for a search + completion request via the `results` field. If the search failed, the + `results` field is empty and an `error` is provided. + parameters: + - name: value + summary: The value to search with. + type: String + - name: options + summary: Additional options to fine-tune the search request. + type: SearchCompletionOptions + platforms: [iphone, ipad, macos] + since: "12.3.0" + + - name: geocodeAddress + summary: | + Resolve address details using the `CLGeocoder` to get information (e.g. + latitude, longitude, postal code and city) about a given input address. + description: | + The result is provided via the callback (second function argument). + parameters: + - name: address + summary: The address to resolve. + type: String + - name: callback + summary: | + Function to be called upon completion (either success with a place + or an error). + type: Callback + optional: false + platforms: [iphone, ipad, macos] + since: "12.3.0" - name: getLookAroundImage summary: A utility function that you use to create a static image from a LookAround scene. @@ -539,10 +578,11 @@ examples: and it is not practical to identify them by title. ``` javascript - var Map = require('ti.map'); - var win = Titanium.UI.createWindow(); + import Map from 'ti.map'; + + const window = Ti.UI.createWindow(); - var mountainView = Map.createAnnotation({ + const mountainView = Map.createAnnotation({ latitude: 37.390749, longitude: -122.081651, title: 'Appcelerator Headquarters', @@ -551,7 +591,7 @@ examples: myid: 1 // Custom property to uniquely identify this annotation. }); - var mapview = Map.createView({ + const mapView = Map.createView({ mapType: Map.NORMAL_TYPE, region: { latitude: 33.74511, @@ -565,7 +605,7 @@ examples: annotations: [ mountainView ] }); - var circle = Map.createCircle({ + const circle = Map.createCircle({ center: { latitude: 33.74511, longitude: -84.38993 @@ -573,14 +613,15 @@ examples: radius: 1000, // = 1.0 km fillColor: '#20FF0000' }); - mapview.addCircle(circle); - win.add(mapview); + mapView.addCircle(circle); + window.add(mapView); - mapview.addEventListener('click', function(event) { + mapView.addEventListener('click', event => { Ti.API.info('Clicked ' + event.clicksource + ' on ' + event.latitude + ', ' + event.longitude); }); - win.open(); + + windown.open(); ``` - title: Alloy XML Markup example: | @@ -605,7 +646,7 @@ examples: ``` xml - + @@ -615,7 +656,7 @@ examples: `app/styles/index.tss`: ``` javascript - "#mapview": { + "#mapView": { region: { latitude: 33.74511, longitude: -84.38993, @@ -651,11 +692,12 @@ examples: view instance. ``` javascript - var Map = require('ti.map'); - var win = Titanium.UI.createWindow(); - var annotations = []; + import Map from 'ti.map'; + + const window = Ti.UI.createWindow(); + const annotations = []; - for (var i = 0; i < 10; i++) { + for (let i = 0; i < 10; i++) { annotations.push(Map.createAnnotation({ title: 'Appcelerator Inc.', subtitle: 'TiRocks!', @@ -675,7 +717,7 @@ examples: })); } - var mapview = Map.createView({ + const mapView = Map.createView({ annotations: annotations, rotateEnabled: true, mapType: Map.MUTED_STANDARD_TYPE, @@ -683,23 +725,37 @@ examples: userLocation: true }); - mapview.addEventListener('clusterstart', function(e) { + mapView.addEventListener('clusterstart', event => { Ti.API.info('clustering started!'); - var clusterAnnotation = Map.createAnnotation({ + const clusterAnnotation = Map.createAnnotation({ showAsMarker: true, - markerText: e.memberAnnotations.length.toString(), + markerText: event.memberAnnotations.length.toString(), title: 'Cluster Title', subtitle: 'Cluster Subtitle', }); - mapview.setClusterAnnotation({ + mapView.setClusterAnnotation({ annotation: clusterAnnotation, - memberAnnotations: e.memberAnnotations + memberAnnotations: event.memberAnnotations }); }); - win.add(mapview); - win.open(); + window.add(mapView); + window.open(); + ``` + - title: Search Request (iOS only) + example: | + The following example shows the MapKit based search request: + + ```javascript + import Map from 'ti.map'; + + Map.addEventListener('didUpdateResults', event => { + console.warn('Found place:'); + console.warn(event) + }); + + Map.search('Colloseum Rome'); ``` --- @@ -709,7 +765,27 @@ properties: - name: longitude summary: Longitude value of the map point, in decimal degrees. type: Number - - name: latitude summary: Latitude value of the map point, in decimal degrees. type: Number + +--- +name: SearchCompletionOptions +summary: Additional options to fine-tune the search request. +description: The latitute and longitude describe the location, the delta values the distance to include. +properties: + - name: latitude + summary: Latitude value of the search request, in decimal degrees. + type: Number + - name: longitude + summary: Longitude value of the search request, in decimal degrees. + type: Number + - name: latitude + summary: Latitude value of the search request, in decimal degrees. + type: Number + - name: latitudeDelta + summary: The amount of north-to-south distance displayed on the map, measured in decimal degrees. + type: Number + - name: longitudeDelta + summary: The amount of east-to-west distance displayed on the map, measured in decimal degrees. + type: Number \ No newline at end of file diff --git a/ios/Classes/TiMapModule.h b/ios/Classes/TiMapModule.h index 5eae48bd..f5bbc629 100644 --- a/ios/Classes/TiMapModule.h +++ b/ios/Classes/TiMapModule.h @@ -9,11 +9,12 @@ #import #if IS_SDK_IOS_16 -@interface TiMapModule : TiModule { +@interface TiMapModule : TiModule { #else @interface TiMapModule : TiModule { #endif UIColor *colorRed; + MKLocalSearchCompleter *_searchCompleter; } @property (nonatomic, readonly) NSNumber *STANDARD_TYPE; diff --git a/ios/Classes/TiMapModule.m b/ios/Classes/TiMapModule.m index dd006ede..4ae3b461 100644 --- a/ios/Classes/TiMapModule.m +++ b/ios/Classes/TiMapModule.m @@ -116,6 +116,123 @@ - (void)lookAroundViewControllerDidPresentFullScreen:(MKLookAroundViewController #endif +- (MKLocalSearchCompleter *)searchCompleter +{ + if (_searchCompleter == nil) { + _searchCompleter = [[MKLocalSearchCompleter alloc] init]; + _searchCompleter.delegate = self; + + // Do not show queries like "show my location" or "show nearby items" + if ([TiUtils isIOSVersionOrGreater:@"13.0"]) { + if (@available(iOS 13.0, *)) { + _searchCompleter.resultTypes = MKLocalSearchCompleterResultTypeAddress | MKLocalSearchCompleterResultTypePointOfInterest; + } else {} + } else { + _searchCompleter.filterType = MKSearchCompletionFilterTypeLocationsOnly; + } + } + + return _searchCompleter; +} + +- (void)search:(id)args +{ + ENSURE_UI_THREAD(search, args); + + NSString *value = [TiUtils stringValue:args[0]]; + NSDictionary *options = (NSDictionary *)args[1]; + + // Require a search value + if (!value) { + [self throwException:@"Missing required search value" subreason:@"Please provide the value as a String" location:CODELOCATION]; + return; + } + + // Pass additional options like search region + if (options != nil) { + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([TiUtils doubleValue:options[@"latitude"]], [TiUtils doubleValue:options[@"longitude"]]); + MKCoordinateSpan span = MKCoordinateSpanMake([TiUtils doubleValue:options[@"latitudeDelta"]], [TiUtils doubleValue:options[@"longitudeDelta"]]); + + if (CLLocationCoordinate2DIsValid(coordinate)) { + [[self searchCompleter] setRegion:MKCoordinateRegionMake(coordinate, span)]; + } + } + + [[self searchCompleter] setQueryFragment:value]; +} + +- (void)geocodeAddress:(id)args +{ + NSString *address = (NSString *)args[0]; + KrollCallback *callback = (KrollCallback *)args[1]; + + CLGeocoder *geocoder = [[CLGeocoder alloc] init]; + [geocoder geocodeAddressString:address completionHandler:^(NSArray * _Nullable placemarks, NSError * _Nullable error) { + if (placemarks.count == 0 || error != nil) { + [callback call:@[@{ @"success": @(NO), @"error": error.localizedDescription ?: @"Unknown error" }] thisObject:self]; + return; + } + + CLPlacemark *place = placemarks[0]; + + NSDictionary *proxyPlace = @{ + @"name": NULL_IF_NIL(place.name), + @"street": NULL_IF_NIL([self formattedStreetNameFromPlace:place]), + @"postalCode": NULL_IF_NIL(place.postalCode), + @"city": NULL_IF_NIL(place.locality), + @"country": NULL_IF_NIL(place.country), + @"state": NULL_IF_NIL(place.administrativeArea), + @"latitude": @(place.location.coordinate.latitude), + @"longitude": @(place.location.coordinate.longitude), + }; + + [callback call:@[@{ @"success": @(YES), @"place": proxyPlace }] thisObject:self]; + }]; +} + +- (NSString *)formattedStreetNameFromPlace:(CLPlacemark *)place +{ + if (place.thoroughfare == nil) { + return nil; + } else if (place.subThoroughfare == nil) { + return place.thoroughfare; + } + + return [NSString stringWithFormat:@"%@ %@", place.thoroughfare, place.subThoroughfare]; +} + +- (void)completer:(MKLocalSearchCompleter *)completer didFailWithError:(NSError *)error +{ + [self fireEvent:@"didUpdateResults" withObject:@{ @"results": @[], @"error": error.localizedDescription }]; +} + +- (void)completerDidUpdateResults:(MKLocalSearchCompleter *)completer +{ + NSMutableArray *> *proxyResults = [NSMutableArray arrayWithCapacity:completer.results.count]; + + [completer.results enumerateObjectsUsingBlock:^(MKLocalSearchCompletion * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + NSMutableArray *> *titleHighlightRanges = [NSMutableArray arrayWithCapacity:obj.titleHighlightRanges.count]; + NSMutableArray *> *subtitleHighlightRanges = [NSMutableArray arrayWithCapacity:obj.subtitleHighlightRanges.count]; + + [obj.titleHighlightRanges enumerateObjectsUsingBlock:^(NSValue * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [titleHighlightRanges addObject:@{ @"offset": @(obj.rangeValue.location), @"length": @(obj.rangeValue.length) }]; + }]; + + [obj.subtitleHighlightRanges enumerateObjectsUsingBlock:^(NSValue * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [subtitleHighlightRanges addObject:@{ @"offset": @(obj.rangeValue.location), @"length": @(obj.rangeValue.length) }]; + }]; + + [proxyResults addObject:@{ + @"title": obj.title, + @"subtitle": obj.subtitle, + @"titleHighlightRanges": titleHighlightRanges, + @"subtitleHighlightRanges": subtitleHighlightRanges + }]; + }]; + + [self fireEvent:@"didUpdateResults" withObject:@{ @"results": proxyResults }]; +} + MAKE_SYSTEM_PROP(STANDARD_TYPE, MKMapTypeStandard); MAKE_SYSTEM_PROP(NORMAL_TYPE, MKMapTypeStandard); // For parity with Android MAKE_SYSTEM_PROP(SATELLITE_TYPE, MKMapTypeSatellite); diff --git a/ios/Classes/TiMapModuleAssets.m b/ios/Classes/TiMapModuleAssets.m index 1f348e39..a169d2dd 100644 --- a/ios/Classes/TiMapModuleAssets.m +++ b/ios/Classes/TiMapModuleAssets.m @@ -3,18 +3,20 @@ */ #import "TiMapModuleAssets.h" -extern NSData *filterDataInRange(NSData *thedata, NSRange range); +extern NSData* filterDataInRange(NSData* thedata, NSRange range); @implementation TiMapModuleAssets - (NSData *)moduleAsset { + return nil; } - (NSData *)resolveModuleAsset:(NSString *)path { + return nil; } diff --git a/ios/manifest b/ios/manifest index 4bdd1a61..6f0a1dcd 100644 --- a/ios/manifest +++ b/ios/manifest @@ -3,7 +3,7 @@ # during compilation, packaging, distribution, etc. # -version: 7.2.0 +version: 7.3.0 apiversion: 2 architectures: arm64 x86_64 description: External version of Map module From 57f1bee85a205f6bd73051504f1664369308c623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Fri, 22 Sep 2023 21:35:22 +0200 Subject: [PATCH 23/26] fix: fix linting error --- ios/Classes/TiMapModule.m | 81 ++++++++++++++++++--------------- ios/Classes/TiMapModuleAssets.m | 4 +- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/ios/Classes/TiMapModule.m b/ios/Classes/TiMapModule.m index 4ae3b461..092e7b97 100644 --- a/ios/Classes/TiMapModule.m +++ b/ios/Classes/TiMapModule.m @@ -126,12 +126,12 @@ - (MKLocalSearchCompleter *)searchCompleter if ([TiUtils isIOSVersionOrGreater:@"13.0"]) { if (@available(iOS 13.0, *)) { _searchCompleter.resultTypes = MKLocalSearchCompleterResultTypeAddress | MKLocalSearchCompleterResultTypePointOfInterest; - } else {} + } } else { _searchCompleter.filterType = MKSearchCompletionFilterTypeLocationsOnly; } } - + return _searchCompleter; } @@ -152,7 +152,7 @@ - (void)search:(id)args if (options != nil) { CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([TiUtils doubleValue:options[@"latitude"]], [TiUtils doubleValue:options[@"longitude"]]); MKCoordinateSpan span = MKCoordinateSpanMake([TiUtils doubleValue:options[@"latitudeDelta"]], [TiUtils doubleValue:options[@"longitudeDelta"]]); - + if (CLLocationCoordinate2DIsValid(coordinate)) { [[self searchCompleter] setRegion:MKCoordinateRegionMake(coordinate, span)]; } @@ -167,27 +167,32 @@ - (void)geocodeAddress:(id)args KrollCallback *callback = (KrollCallback *)args[1]; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; - [geocoder geocodeAddressString:address completionHandler:^(NSArray * _Nullable placemarks, NSError * _Nullable error) { - if (placemarks.count == 0 || error != nil) { - [callback call:@[@{ @"success": @(NO), @"error": error.localizedDescription ?: @"Unknown error" }] thisObject:self]; - return; - } - - CLPlacemark *place = placemarks[0]; - - NSDictionary *proxyPlace = @{ - @"name": NULL_IF_NIL(place.name), - @"street": NULL_IF_NIL([self formattedStreetNameFromPlace:place]), - @"postalCode": NULL_IF_NIL(place.postalCode), - @"city": NULL_IF_NIL(place.locality), - @"country": NULL_IF_NIL(place.country), - @"state": NULL_IF_NIL(place.administrativeArea), - @"latitude": @(place.location.coordinate.latitude), - @"longitude": @(place.location.coordinate.longitude), - }; - - [callback call:@[@{ @"success": @(YES), @"place": proxyPlace }] thisObject:self]; - }]; + [geocoder geocodeAddressString:address + completionHandler:^(NSArray *_Nullable placemarks, NSError *_Nullable error) { + if (placemarks.count == 0 || error != nil) { + [callback call:@[ @{@"success" : @(NO), + @"error" : error.localizedDescription ?: @"Unknown error"} ] + thisObject:self]; + return; + } + + CLPlacemark *place = placemarks[0]; + + NSDictionary *proxyPlace = @{ + @"name" : NULL_IF_NIL(place.name), + @"street" : NULL_IF_NIL([self formattedStreetNameFromPlace:place]), + @"postalCode" : NULL_IF_NIL(place.postalCode), + @"city" : NULL_IF_NIL(place.locality), + @"country" : NULL_IF_NIL(place.country), + @"state" : NULL_IF_NIL(place.administrativeArea), + @"latitude" : @(place.location.coordinate.latitude), + @"longitude" : @(place.location.coordinate.longitude), + }; + + [callback call:@[ @{@"success" : @(YES), + @"place" : proxyPlace} ] + thisObject:self]; + }]; } - (NSString *)formattedStreetNameFromPlace:(CLPlacemark *)place @@ -203,34 +208,36 @@ - (NSString *)formattedStreetNameFromPlace:(CLPlacemark *)place - (void)completer:(MKLocalSearchCompleter *)completer didFailWithError:(NSError *)error { - [self fireEvent:@"didUpdateResults" withObject:@{ @"results": @[], @"error": error.localizedDescription }]; + [self fireEvent:@"didUpdateResults" withObject:@{ @"results" : @[], @"error" : error.localizedDescription }]; } - (void)completerDidUpdateResults:(MKLocalSearchCompleter *)completer { NSMutableArray *> *proxyResults = [NSMutableArray arrayWithCapacity:completer.results.count]; - - [completer.results enumerateObjectsUsingBlock:^(MKLocalSearchCompletion * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + [completer.results enumerateObjectsUsingBlock:^(MKLocalSearchCompletion *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) { NSMutableArray *> *titleHighlightRanges = [NSMutableArray arrayWithCapacity:obj.titleHighlightRanges.count]; NSMutableArray *> *subtitleHighlightRanges = [NSMutableArray arrayWithCapacity:obj.subtitleHighlightRanges.count]; - - [obj.titleHighlightRanges enumerateObjectsUsingBlock:^(NSValue * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - [titleHighlightRanges addObject:@{ @"offset": @(obj.rangeValue.location), @"length": @(obj.rangeValue.length) }]; + + [obj.titleHighlightRanges enumerateObjectsUsingBlock:^(NSValue *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) { + [titleHighlightRanges addObject:@{@"offset" : @(obj.rangeValue.location), + @"length" : @(obj.rangeValue.length)}]; }]; - [obj.subtitleHighlightRanges enumerateObjectsUsingBlock:^(NSValue * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - [subtitleHighlightRanges addObject:@{ @"offset": @(obj.rangeValue.location), @"length": @(obj.rangeValue.length) }]; + [obj.subtitleHighlightRanges enumerateObjectsUsingBlock:^(NSValue *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) { + [subtitleHighlightRanges addObject:@{@"offset" : @(obj.rangeValue.location), + @"length" : @(obj.rangeValue.length)}]; }]; [proxyResults addObject:@{ - @"title": obj.title, - @"subtitle": obj.subtitle, - @"titleHighlightRanges": titleHighlightRanges, - @"subtitleHighlightRanges": subtitleHighlightRanges + @"title" : obj.title, + @"subtitle" : obj.subtitle, + @"titleHighlightRanges" : titleHighlightRanges, + @"subtitleHighlightRanges" : subtitleHighlightRanges }]; }]; - [self fireEvent:@"didUpdateResults" withObject:@{ @"results": proxyResults }]; + [self fireEvent:@"didUpdateResults" withObject:@{ @"results" : proxyResults }]; } MAKE_SYSTEM_PROP(STANDARD_TYPE, MKMapTypeStandard); diff --git a/ios/Classes/TiMapModuleAssets.m b/ios/Classes/TiMapModuleAssets.m index a169d2dd..1f348e39 100644 --- a/ios/Classes/TiMapModuleAssets.m +++ b/ios/Classes/TiMapModuleAssets.m @@ -3,20 +3,18 @@ */ #import "TiMapModuleAssets.h" -extern NSData* filterDataInRange(NSData* thedata, NSRange range); +extern NSData *filterDataInRange(NSData *thedata, NSRange range); @implementation TiMapModuleAssets - (NSData *)moduleAsset { - return nil; } - (NSData *)resolveModuleAsset:(NSString *)path { - return nil; } From 9540f3ab720520d4af28a26662da2a736a082a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Sat, 23 Sep 2023 14:31:54 +0200 Subject: [PATCH 24/26] =?UTF-8?q?chore:=20expose=20=E2=80=9CresultTypes?= =?UTF-8?q?=E2=80=9D=20API,=20fix=20optional=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/TiMapModule.m | 42 ++++++++++++++++++++----------- ios/Classes/TiMapUtils.h | 3 +++ ios/Classes/TiMapUtils.m | 12 +++++++++ ios/Classes/TiMapViewProxy.h | 1 - ios/map.xcodeproj/project.pbxproj | 4 +-- 5 files changed, 44 insertions(+), 18 deletions(-) diff --git a/ios/Classes/TiMapModule.m b/ios/Classes/TiMapModule.m index 092e7b97..8b403a83 100644 --- a/ios/Classes/TiMapModule.m +++ b/ios/Classes/TiMapModule.m @@ -10,6 +10,7 @@ #import "TiBlob.h" #import "TiMapCameraProxy.h" #import "TiMapConstants.h" +#import "TiMapUtils.h" #import "TiMapViewProxy.h" @implementation TiMapModule @@ -121,15 +122,6 @@ - (MKLocalSearchCompleter *)searchCompleter if (_searchCompleter == nil) { _searchCompleter = [[MKLocalSearchCompleter alloc] init]; _searchCompleter.delegate = self; - - // Do not show queries like "show my location" or "show nearby items" - if ([TiUtils isIOSVersionOrGreater:@"13.0"]) { - if (@available(iOS 13.0, *)) { - _searchCompleter.resultTypes = MKLocalSearchCompleterResultTypeAddress | MKLocalSearchCompleterResultTypePointOfInterest; - } - } else { - _searchCompleter.filterType = MKSearchCompletionFilterTypeLocationsOnly; - } } return _searchCompleter; @@ -140,7 +132,6 @@ - (void)search:(id)args ENSURE_UI_THREAD(search, args); NSString *value = [TiUtils stringValue:args[0]]; - NSDictionary *options = (NSDictionary *)args[1]; // Require a search value if (!value) { @@ -149,12 +140,29 @@ - (void)search:(id)args } // Pass additional options like search region - if (options != nil) { - CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([TiUtils doubleValue:options[@"latitude"]], [TiUtils doubleValue:options[@"longitude"]]); - MKCoordinateSpan span = MKCoordinateSpanMake([TiUtils doubleValue:options[@"latitudeDelta"]], [TiUtils doubleValue:options[@"longitudeDelta"]]); + if ([args count] > 1) { + NSDictionary *options = (NSDictionary *)args[1]; + if (options == nil) { + [self throwException:@"Options have to be called within an Object" subreason:@"Please provide the value as an Object" location:CODELOCATION]; + } + + // Handle search region + if (options[@"latitude"] && options[@"longitude"] && options[@"latitudeDelta"] && options[@"longitudeDelta"]) { + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([TiUtils doubleValue:options[@"latitude"]], [TiUtils doubleValue:options[@"longitude"]]); + MKCoordinateSpan span = MKCoordinateSpanMake([TiUtils doubleValue:options[@"latitudeDelta"]], [TiUtils doubleValue:options[@"longitudeDelta"]]); - if (CLLocationCoordinate2DIsValid(coordinate)) { - [[self searchCompleter] setRegion:MKCoordinateRegionMake(coordinate, span)]; + if (CLLocationCoordinate2DIsValid(coordinate)) { + [[self searchCompleter] setRegion:MKCoordinateRegionMake(coordinate, span)]; + } + } + + // Handle filter types + if ([TiUtils isIOSVersionOrGreater:@"13.0"] && options[@"resultTypes"]) { + if (@available(iOS 13.0, *)) { + _searchCompleter.resultTypes = [TiMapUtils mappedResultTypes:options[@"resultTypes"]]; + } else { + NSLog(@"[ERROR] The \"resultTypes\" options are only available on iOS 13+"); + } } } @@ -288,4 +296,8 @@ - (void)completerDidUpdateResults:(MKLocalSearchCompleter *)completer MAKE_SYSTEM_PROP(FEATURE_TYPE_POINT_OF_INTEREST, MKMapFeatureOptionPointsOfInterest); #endif +MAKE_SYSTEM_PROP(SEARCH_RESULT_TYPE_ADDRESS, MKLocalSearchCompleterResultTypeAddress); +MAKE_SYSTEM_PROP(SEARCH_RESULT_TYPE_POINT_OF_INTEREST, MKLocalSearchCompleterResultTypePointOfInterest); +MAKE_SYSTEM_PROP(SEARCH_RESULT_TYPE_QUERY, MKLocalSearchCompleterResultTypeQuery); + @end diff --git a/ios/Classes/TiMapUtils.h b/ios/Classes/TiMapUtils.h index 4440cbd3..ece8353c 100644 --- a/ios/Classes/TiMapUtils.h +++ b/ios/Classes/TiMapUtils.h @@ -7,6 +7,7 @@ #import #import +#import @interface TiMapUtils : NSObject @@ -14,4 +15,6 @@ + (NSDictionary *)dictionaryFromPlacemark:(CLPlacemark *)placemark; ++ (MKLocalSearchCompleterResultType)mappedResultTypes:(NSArray *)inputResultTypes; + @end diff --git a/ios/Classes/TiMapUtils.m b/ios/Classes/TiMapUtils.m index 8ae44b37..85aec6fc 100644 --- a/ios/Classes/TiMapUtils.m +++ b/ios/Classes/TiMapUtils.m @@ -56,4 +56,16 @@ + (id)returnValueOnMainThread:(id (^)(void))block return place; } ++ (MKLocalSearchCompleterResultType)mappedResultTypes:(NSArray *)inputResultTypes +{ + MKLocalSearchCompleterResultType resultTypes = 0; + + for (NSNumber *number in inputResultTypes) { + MKLocalSearchCompleterResultType typeValue = [number unsignedIntegerValue]; + resultTypes |= typeValue; + } + + return resultTypes; +} + @end diff --git a/ios/Classes/TiMapViewProxy.h b/ios/Classes/TiMapViewProxy.h index a479d522..0eec9e8d 100644 --- a/ios/Classes/TiMapViewProxy.h +++ b/ios/Classes/TiMapViewProxy.h @@ -65,7 +65,6 @@ - (void)removeImageOverlay:(id)arg; - (void)removeAllImageOverlays:(id)args; - (void)setClusterAnnotation:(id)args; -- (void)setLocation:(id)location; - (NSNumber *)containsCoordinate:(id)args; @end diff --git a/ios/map.xcodeproj/project.pbxproj b/ios/map.xcodeproj/project.pbxproj index 2fd7b6d7..a6d15353 100644 --- a/ios/map.xcodeproj/project.pbxproj +++ b/ios/map.xcodeproj/project.pbxproj @@ -183,6 +183,8 @@ DB3656EF1E50BA740040E0B9 /* TiMapConstants.h */, 24DD6CF71134B3F500162E58 /* TiMapModule.h */, 24DD6CF81134B3F500162E58 /* TiMapModule.m */, + CEE33CF119EC4C150005E745 /* TiMapUtils.h */, + CEE33CF219EC4C150005E745 /* TiMapUtils.m */, 24DE9E0F11C5FE74003F90F6 /* TiMapModuleAssets.h */, 24DE9E1011C5FE74003F90F6 /* TiMapModuleAssets.m */, ); @@ -293,8 +295,6 @@ CED651C317D7AA21007C2954 /* TiMapView.m */, CED651C417D7AA21007C2954 /* TiMapViewProxy.h */, CED651C517D7AA21007C2954 /* TiMapViewProxy.m */, - CEE33CF119EC4C150005E745 /* TiMapUtils.h */, - CEE33CF219EC4C150005E745 /* TiMapUtils.m */, 27A609E819F5922B00CA150A /* WildcardGestureRecognizer.h */, 27A609E919F5927000CA150A /* WildcardGestureRecognizer.m */, ); From 0635f87c189d03dc72f8c15f1126f75f053f7faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Sat, 23 Sep 2023 14:39:50 +0200 Subject: [PATCH 25/26] chore: add new docs --- apidoc/Map.yml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/apidoc/Map.yml b/apidoc/Map.yml index d26e601d..9f80383a 100644 --- a/apidoc/Map.yml +++ b/apidoc/Map.yml @@ -484,6 +484,27 @@ properties: osver: {ios: {min: "11.0"} } exclude-platforms: [android] since: "6.3.0" + + - name: SEARCH_RESULT_TYPE_ADDRESS + summary: A value that indicates that search results include addresses. + type: Number + permission: read-only + osver: {ios: {min: "13.0"} } + since: "12.3.0" + + - name: SEARCH_RESULT_TYPE_POINT_OF_INTEREST + summary: A value that indicates that search results include points of interest. + type: Number + permission: read-only + osver: {ios: {min: "13.0"} } + since: "12.3.0" + + - name: SEARCH_RESULT_TYPE_QUERY + summary: A value that indicates that the search completer includes query completions in results. + type: Number + permission: read-only + osver: {ios: {min: "13.0"} } + since: "12.3.0" methods: - name: isGooglePlayServicesAvailable @@ -788,4 +809,12 @@ properties: type: Number - name: longitudeDelta summary: The amount of east-to-west distance displayed on the map, measured in decimal degrees. - type: Number \ No newline at end of file + type: Number + - name: resultTypes + summary: These options configure the types of search results you want to receive, including points of interest and addresses. + description: | + Use one or more of the following constants: + - + - + - + type: Array \ No newline at end of file From 27e977ffdd9bccef24ac15ff184c9818ccb5fc3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Sat, 23 Sep 2023 15:23:02 +0200 Subject: [PATCH 26/26] chore: move region to own key --- apidoc/Map.yml | 34 +++++++++++++++++----------------- ios/Classes/TiMapModule.m | 7 ++++--- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/apidoc/Map.yml b/apidoc/Map.yml index 9f80383a..3b980deb 100644 --- a/apidoc/Map.yml +++ b/apidoc/Map.yml @@ -766,7 +766,9 @@ examples: ``` - title: Search Request (iOS only) example: | - The following example shows the MapKit based search request: + The following example shows the MapKit based search request. + The options in `search` (2nd parameter) are optional, but improve + the accuracy of the results. ```javascript import Map from 'ti.map'; @@ -776,7 +778,15 @@ examples: console.warn(event) }); - Map.search('Colloseum Rome'); + Map.search('Colosseum', { + region: { + latitude: 41.890560, + longitude: 12.494270, + latitudeDelta: 1, + longitudeDelta: 1, + }, + resultTypes: [Map.SEARCH_RESULT_TYPE_POINT_OF_INTEREST, Map.SEARCH_RESULT_TYPE_ADDRESS] + }); ``` --- @@ -795,21 +805,11 @@ name: SearchCompletionOptions summary: Additional options to fine-tune the search request. description: The latitute and longitude describe the location, the delta values the distance to include. properties: - - name: latitude - summary: Latitude value of the search request, in decimal degrees. - type: Number - - name: longitude - summary: Longitude value of the search request, in decimal degrees. - type: Number - - name: latitude - summary: Latitude value of the search request, in decimal degrees. - type: Number - - name: latitudeDelta - summary: The amount of north-to-south distance displayed on the map, measured in decimal degrees. - type: Number - - name: longitudeDelta - summary: The amount of east-to-west distance displayed on the map, measured in decimal degrees. - type: Number + - name: region + summary: | + The region to look for results. Note that only `latitude`, `longitude`, `latitudeDelta` and `longitudeDelta` + are currently handled to define the region. + type: MapRegionTypev2 - name: resultTypes summary: These options configure the types of search results you want to receive, including points of interest and addresses. description: | diff --git a/ios/Classes/TiMapModule.m b/ios/Classes/TiMapModule.m index 8b403a83..d39b3c3b 100644 --- a/ios/Classes/TiMapModule.m +++ b/ios/Classes/TiMapModule.m @@ -147,9 +147,10 @@ - (void)search:(id)args } // Handle search region - if (options[@"latitude"] && options[@"longitude"] && options[@"latitudeDelta"] && options[@"longitudeDelta"]) { - CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([TiUtils doubleValue:options[@"latitude"]], [TiUtils doubleValue:options[@"longitude"]]); - MKCoordinateSpan span = MKCoordinateSpanMake([TiUtils doubleValue:options[@"latitudeDelta"]], [TiUtils doubleValue:options[@"longitudeDelta"]]); + if (options[@"region"]) { + NSDictionary *region = options[@"region"]; + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([TiUtils doubleValue:region[@"latitude"]], [TiUtils doubleValue:region[@"longitude"]]); + MKCoordinateSpan span = MKCoordinateSpanMake([TiUtils doubleValue:region[@"latitudeDelta"]], [TiUtils doubleValue:region[@"longitudeDelta"]]); if (CLLocationCoordinate2DIsValid(coordinate)) { [[self searchCompleter] setRegion:MKCoordinateRegionMake(coordinate, span)];