// // SismaAnnotation.m // Earthquake Network // // Created by Luca Beretta on 08/11/18. // Copyright © 2018 Luca Beretta. All rights reserved. // #import "SismaAnnotation.h" @implementation SismaAnnotation -(id)initWithTitle:(NSString *)title location:(CLLocationCoordinate2D )coordinate intensita:(double)magnitude{ self = [super init]; if (self) { _title = title; _coordinate = coordinate; _magnitude = magnitude; } return self; } -(MKAnnotationView *)annotationView{ MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:self reuseIdentifier:IDENTIFIER_ANNOTATION_SISMI]; annotationView.enabled = YES; annotationView.canShowCallout = YES; NSString *imageString; NSLog(@"magnitudo %f", self.magnitude); if(self.magnitude > 4.0){ imageString = @"dyamond_red"; }else if (self.magnitude < 3.0){ imageString = @"dyamond_green"; }else{ imageString = @"dyamond_yellow"; } annotationView.image = [UIImage imageNamed:imageString]; annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; return annotationView; } @end