Skip to content

Instantly share code, notes, and snippets.

@eito
Created May 28, 2014 18:26
Show Gist options
  • Save eito/485a14ffbfc08ea3d58e to your computer and use it in GitHub Desktop.
Save eito/485a14ffbfc08ea3d58e to your computer and use it in GitHub Desktop.
Test Custom Callout
@interface CalloutTest ()<AGSMapViewTouchDelegate>
@property (nonatomic, strong) AGSMapView *mapView;
@property (nonatomic, strong) UIView *customCalloutView;
@end
@implementation CalloutTest
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.mapView = [TestUtility addMapViewToView:self.view];
self.mapView.touchDelegate = self;
[TestUtility addOSMLayerToMap:self.mapView];
self.customCalloutView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 50)];
self.customCalloutView.backgroundColor = [UIColor blueColor];
self.mapView.callout.leaderPositionFlags = AGSCalloutLeaderPositionBottom;
self.mapView.callout.customView = self.customCalloutView;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)mapView:(AGSMapView *)mapView didClickAtPoint:(CGPoint)screen mapPoint:(AGSPoint *)mappoint graphics:(NSDictionary *)graphics {
[self.mapView.callout showCalloutAt:mappoint pixelOffset:CGPointZero animated:YES];
}
- (void)mapView:(AGSMapView *)mapView didEndTapAndHoldAtPoint:(CGPoint)screen mapPoint:(AGSPoint *)mappoint graphics:(NSDictionary *)graphics {
}
- (void)mapView:(AGSMapView *)mapView didTapAndHoldAtPoint:(CGPoint)screen mapPoint:(AGSPoint *)mappoint graphics:(NSDictionary *)graphics {
[self.mapView.callout moveCalloutTo:mappoint pixelOffset:CGPointZero animated:NO];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment