Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. @interface MyAnnotationPins : NSObject < MKAnnotation>
  2. @property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
  3. @property (nonatomic, readonly, copy) NSString *title;
  4. @property (nonatomic, readonly, copy) NSString *subtitle;
  5. -(id)initWithCoordinate:(CLLocationCoordinate2D)annotCoordinate title:(NSString*)annotTitle subtitle:(NSString*)annotSubtitle;
  6.  
  7. @synthesize coordinate;
  8. @synthesize subtitle;
  9. @synthesize title;
  10. -(id)initWithCoordinate:(CLLocationCoordinate2D)annotCoordinate title:(NSString*)annotTitle subtitle:(NSString*)annotSubtitle
  11. {
  12. self = [super init];
  13. if (self)
  14. {
  15. coordinate = annotCoordinate;
  16. subtitle = [[NSString alloc] initWithString:annotSubtitle];
  17. title = [[NSString alloc] initWithString:annotTitle];
  18. }
  19.  
  20. return self;
  21. }
  22.  
  23. import "MyAnnotationPins.h"
  24.  
  25.  
  26. @interface SecondViewController : UIViewController < MKMapViewDelegate >
  27.  
  28. @property (weak, nonatomic) IBOutlet MKMapView *mapView;
  29. @property (strong, nonatomic) MyAnnotationPins* biblioAnnotation;
  30.  
  31. - (void)viewDidLoad
  32. {
  33.  
  34. [super viewDidLoad];
  35.  
  36. mapView.delegate = self;
  37.  
  38. MKCoordinateRegion mapRegion;
  39. mapRegion.center.latitude=-18.924129;
  40. mapRegion.center.longitude=-48.283963;
  41. mapRegion.span.latitudeDelta=0.2;
  42. mapRegion.span.longitudeDelta=0.2;
  43.  
  44. [mapView setRegion:mapRegion animated:YES];
  45.  
  46. ///// This is just for One annotaion/Pin on Map /////
  47. CLLocationCoordinate2D parliamentLocation = CLLocationCoordinate2DMake(-18.924129, -48.283963);
  48. biblioAnnotation = [[MyAnnotationPins alloc]
  49. initWithCoordinate:parliamentLocation
  50. title:@"Ponto Biblioteca"
  51. subtitle:@"Taxi proximo"];
  52. [mapView addAnnotation:biblioAnnotation];
  53.  
  54. CLLocationCoordinate2D secondLocation = CLLocationCoordinate2DMake(another latitude, another longitude);
  55. secondAnnotation = [[MyAnnotationPins alloc]
  56. initWithCoordinate:secondLocation
  57. title:@"Second Title"
  58. subtitle:@"Second subtitle"];
  59. [mapView addAnnotation:secondAnnotation]; <code>
  60.  
  61. @property (strong, nonatomic) MyAnnotationPins* secondAnnotation;
  62.  
  63. for(X in Y)
  64. {
  65. CLLocationCoordinate2D parliamentLocation = CLLocationCoordinate2DMake(-18.924129, -48.283963);
  66. MyAnnotationPins* biblioAnnotation = [[MyAnnotationPins alloc]
  67. initWithCoordinate:parliamentLocation
  68. title:@"Ponto Biblioteca"
  69. subtitle:@"Taxi proximo"];
  70. [mapView addAnnotation:biblioAnnotation];
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement