Skip to content

Commit

Permalink
Merge pull request #637 from hansemannn/feature/poi-deselect
Browse files Browse the repository at this point in the history
feat(ios): add "poideselect" event
  • Loading branch information
hansemannn authored Sep 13, 2023
2 parents d0bde93 + f1cf64c commit ed944dc
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 1 deletion.
5 changes: 5 additions & 0 deletions apidoc/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
22 changes: 22 additions & 0 deletions ios/Classes/TiMapFeatureAnnotationProxy.h
Original file line number Diff line number Diff line change
@@ -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 <MapKit/MapKit.h>

@interface TiMapFeatureAnnotationProxy : TiProxy {
#if IS_SDK_IOS_16
MKMapFeatureAnnotation *_annotation;
#endif
}

#if IS_SDK_IOS_16
- (id)_initWithPageContext:(id<TiEvaluator>)context andAnnotation:(MKMapFeatureAnnotation *)annotation;
- (MKMapFeatureAnnotation *)annotation;
#endif

@end
29 changes: 29 additions & 0 deletions ios/Classes/TiMapFeatureAnnotationProxy.m
Original file line number Diff line number Diff line change
@@ -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 <MapKit/MapKit.h>

@implementation TiMapFeatureAnnotationProxy

#if IS_SDK_IOS_16
- (id)_initWithPageContext:(id<TiEvaluator>)context andAnnotation:(MKMapFeatureAnnotation *)annotation
{
if (self = [super _initWithPageContext:pageContext]) {
_annotation = annotation;
}

return self;
}

- (MKMapFeatureAnnotation *)annotation
{
return _annotation;
}
#endif

@end
17 changes: 17 additions & 0 deletions ios/Classes/TiMapView.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "TiMapAnnotationProxy.h"
#import "TiMapCircleProxy.h"
#import "TiMapCustomAnnotationView.h"
#import "TiMapFeatureAnnotationProxy.h"
#import "TiMapImageAnnotationView.h"
#import "TiMapImageOverlayProxy.h"
#import "TiMapMarkerAnnotationView.h"
Expand Down Expand Up @@ -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];
}
}

Expand Down Expand Up @@ -1128,6 +1131,7 @@ - (void)mapView:(MKMapView *)mapView didSelectAnnotation:(id<MKAnnotation>)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),
Expand Down Expand Up @@ -1175,6 +1179,19 @@ - (void)findCalloutView:(UIView *)node
}
}

#if IS_SDK_IOS_16
- (void)mapView:(MKMapView *)mapView didDeselectAnnotation:(id<MKAnnotation>)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)]) {
Expand Down
2 changes: 1 addition & 1 deletion ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions ios/map.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -94,6 +96,8 @@
27A609ED19F5B85900CA150A /* TiMapCircleProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TiMapCircleProxy.h; path = Classes/TiMapCircleProxy.h; sourceTree = "<group>"; };
27A609EE19F7112C00CA150A /* TiMapPolylineProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TiMapPolylineProxy.h; path = Classes/TiMapPolylineProxy.h; sourceTree = "<group>"; };
27A609EF19F711B700CA150A /* TiMapPolylineProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiMapPolylineProxy.m; path = Classes/TiMapPolylineProxy.m; sourceTree = "<group>"; };
3A155BE62A9B35C000247646 /* TiMapFeatureAnnotationProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TiMapFeatureAnnotationProxy.h; path = Classes/TiMapFeatureAnnotationProxy.h; sourceTree = "<group>"; };
3A155BE72A9B35C000247646 /* TiMapFeatureAnnotationProxy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = TiMapFeatureAnnotationProxy.m; path = Classes/TiMapFeatureAnnotationProxy.m; sourceTree = "<group>"; };
815136F11D355BF5009E3E2C /* TiMapSnapshotterProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiMapSnapshotterProxy.h; path = Classes/TiMapSnapshotterProxy.h; sourceTree = "<group>"; };
815136F21D355BF5009E3E2C /* TiMapSnapshotterProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiMapSnapshotterProxy.m; path = Classes/TiMapSnapshotterProxy.m; sourceTree = "<group>"; };
AA747D9E0F9514B9006C5449 /* TiMap_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiMap_Prefix.pch; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -236,6 +240,8 @@
CED651C117D7AA21007C2954 /* TiMapPinAnnotationView.m */,
DB0CC9FF2010840900597F24 /* TiMapMarkerAnnotationView.h */,
DB0CC9FE2010840900597F24 /* TiMapMarkerAnnotationView.m */,
3A155BE62A9B35C000247646 /* TiMapFeatureAnnotationProxy.h */,
3A155BE72A9B35C000247646 /* TiMapFeatureAnnotationProxy.m */,
);
name = Annotation;
sourceTree = "<group>";
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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 */,
Expand Down

0 comments on commit ed944dc

Please sign in to comment.