Skip to content

Commit 08cc68c

Browse files
committed
adds more detailed examples
1 parent 6ca9346 commit 08cc68c

File tree

1 file changed

+48
-3
lines changed

1 file changed

+48
-3
lines changed

readme.markdown

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,64 @@ EPMapExtension is an extension library built on the top of [MKMapKit](http://dev
66

77
## Overview
88

9-
The library architecture is based on the
9+
The library architecture is built on the the top of `MKMapKit Framework`.
1010

1111
## MapViewDecorator
1212

1313
MapViewDecorator is an attempt to deal with a considerable amount of customized annotationView spanning over the map without incurring in typical problems relevant to the trivial **switch-case, if-else if** control structures. In other words, it is a way to treat a good number of annotations and views in a more manageable and maintainable way.
1414

1515
### Registration of Annotations into MapDecorator
1616

17-
#### Example 1
17+
In the following way is possible to register the annotationView associated to the annotation
18+
1819
EPMapViewDecorator *decorator = [[EPMapViewDecorator alloc] init];
1920
[decorator registerAnnotationViewForClass:[AnnotationClass class] annotationView:@"MKPinAnnotationView"];
2021

21-
### Advanced Configurations
22+
### Configuration and Registration of Annotations through the MapDecorator
23+
24+
EPMapViewDecorator *decorator = [[EPMapViewDecorator alloc] init];
25+
[_mapDecorator registerAnnotationViewForClass:[AnnotationClass class] annotationView:@"MKPinAnnotationView"
26+
configBlock:^(MKAnnotationView *av, id<MKAnnotation> annotation){
27+
[av setCanShowCallout:YES];
28+
}];
29+
30+
31+
### Registration & Configuration of Multiple AnnotationViews Relevant to an AnnotationClass
32+
33+
34+
[_mapDecorator registerAnnotationViewForClass:[AnnotationClass class]
35+
translationBlock:^NSString * (id<MKAnnotation> annotation) {
36+
if (![[(AnnotationClass *)annotation name] isEqualToString:@"I'm old"])
37+
return @"YAAnnotationView";
38+
else
39+
return @"YAAAnnotationView";
40+
}];
41+
[_mapDecorator setConfigBlockForClass:[AnnotationClass class]
42+
block:^(MKAnnotationView *av, id<MKAnnotation> annotation){
43+
if([av class] == [YAAnnotationView class]) {
44+
[av setCanShowCallout:YES];
45+
} else {
46+
[av setCanShowCallout:NO];
47+
}
48+
}];
49+
50+
### Registration & Configuration of AnnotationViews for All Annotation Classes
51+
52+
[_mapDecorator setTranslationBlockForAllClasses:^NSString * (id<MKAnnotation> annotation) {
53+
if (![annotation respondsToSelector:@selector(title)])
54+
return @"YAAnnotationView";
55+
else
56+
return @"YAJesusAnnotationView";
57+
}];
58+
59+
[_mapDecorator setConfigBlockForAllClasses: ^(MKAnnotationView *annotationView, id<MKAnnotation> annotation) {
60+
if([annotationView class] == [YAAnnotationView class]) {
61+
[annotationView setCanShowCallout:YES];
62+
} else {
63+
[annotationView setCanShowCallout:NO];
64+
}
65+
}];
66+
2267

2368
## Customized MapView
2469

0 commit comments

Comments
 (0)