GithubHelp home page GithubHelp logo

iosmapextension's Introduction

EPMapExtension is an extension library built on the top of MKMapKit framework.

How To Get Started

Overview

The library architecture is built on the the top of MKMapKit Framework.

MapViewDecorator

MapViewDecorator is an attempt to deal with a considerable amount of customized MKAnnotationViews, 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.

Registration of Annotations into MapDecorator

In the following way is possible to register the annotationView associated to the annotation

EPMapViewDecorator *decorator = [[EPMapViewDecorator alloc] init];
[decorator registerAnnotationViewForClass:[AnnotationClass class] annotationView:@"MKPinAnnotationView"];

Configuration and Registration of Annotations through the MapDecorator

EPMapViewDecorator *decorator = [[EPMapViewDecorator alloc] init];
[_mapDecorator registerAnnotationViewForClass:[AnnotationClass class] annotationView:@"MKPinAnnotationView"
                                  configBlock:^(MKAnnotationView *av, id<MKAnnotation> annotation){
                                      [av setCanShowCallout:YES];
                                  }];

Registration & Configuration of Multiple AnnotationViews Relevant to an AnnotationClass

[_mapDecorator registerAnnotationViewForClass:[AnnotationClass class]
                             translationBlock:^NSString * (id<MKAnnotation> annotation) {
                                 if (![[(AnnotationClass *)annotation name] isEqualToString:@"I'm old"])
                                     return @"YAAnnotationView";
                                 else
                                     return @"YAAAnnotationView";
                             }];
[_mapDecorator setConfigBlockForClass:[AnnotationClass class]
                                block:^(MKAnnotationView *av, id<MKAnnotation> annotation){
                                    if([av class] == [YAAnnotationView class]) {
                                        [av setCanShowCallout:YES];
                                    } else {
                                        [av setCanShowCallout:NO];
                                    }
                                }];

Registration & Configuration of AnnotationViews for All Annotation Classes

[_mapDecorator setTranslationBlockForAllClasses:^NSString * (id<MKAnnotation> annotation) {
        if (![annotation respondsToSelector:@selector(title)])
            return @"YAAnnotationView";
        else
            return @"YAJesusAnnotationView";
    }];

[_mapDecorator setConfigBlockForAllClasses: ^(MKAnnotationView *annotationView, id<MKAnnotation> annotation) {
    if([annotationView class] == [YAAnnotationView class]) {
        [annotationView setCanShowCallout:YES];
    } else {
        [annotationView setCanShowCallout:NO];
    }
}];

Customized MapView

This customized MapView adds some useful features on top of the MKMapView class.

In fact, it enables

  • to get centered regions relative to a set to annotations conforming to a protocol or a set of protocols, belonging to a certain class or set of classes

  • to get the number of visible annotation conforming to a protocol or a set of protocols or belonging to a certain class or set of classes, within the current visible Map Region.

User Position

This class is a helper class to update the user position only within a certain range (it's the minThresholdToUpdatePosition property). It also checks if a valid position has been given.

Annotation Array

This is an annotation array data structure built on top of the NSArray class. It adds some useful features to get, remove, add annotations responding to a particular protocol or class.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.