Coder Social home page Coder Social logo

skela / namapkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from neilang/namapkit

0.0 2.0 0.0 11.23 MB

Allows you to use custom maps in iphone applications and attempts to mimics some of the behaviour of the MapKit framework

License: MIT License

Objective-C 98.87% Ruby 1.13%

namapkit's Introduction

NAMapKit

Build Status

Lets you drop pins or custom annotations onto a standard UIImage or a tiled NATiledImageView. Includes callouts, multi-colored pins, animation, zoom and gestures support.

Animated Demo

Get started by running pod try NAMapKit in your terminal.

Usage

Default Annotations

Create a NAMapView in a view controller.

NAMapView *mapView = [[NAMapView alloc] initWithFrame:self.view.bounds];

mapView.backgroundColor  = [UIColor colorWithRed:0.000f green:0.475f blue:0.761f alpha:1.000f];
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

mapView.minimumZoomScale = 0.5f;
mapView.maximumZoomScale = 1.5f;

[mapView displayMap:[UIImage imageNamed:@"australia"]];

[self.view addSubview:mapView];

Add NADotAnnotation annotations.

NADotAnnotation *dot = [NADotAnnotation annotationWithPoint:CGPointMake(543.0f, 489.0f)];
[mapView addAnnotation:dot animated:NO];

Custom Annotations

The implementation of NADotAnnotation places a red semi-transparent dot on the map. For custom annotations, subclass NAAnnotation and implement createViewOnMapView that returns a custom annotation view. You could also implement a custom animation to drop an annotation onto the map by implementing addToMapView, or center the annotation depending on your custom logic by overriding updatePosition.

You can find a complete custom annotation example of multi-colored pins in NAPinAnnotation.h/.m and a popup menu demo in NAPinAnnotationsPopupMenuDemoViewController.h/.m.

circular pop-up animated demo

Delegates

You can capture finger taps and zoom changes by registering a mapViewDelegate with the map. The delegate must implement the NAMapViewDelegate protocol.

@implementation DemoViewController

- (void)viewDidLoad
{
    // Register the view controller as the map's delegate
    self.mapView.mapViewDelegate = self;
}

- (void)mapView:(NAMapView *)mapView tappedOnAnnotation:(NAPinAnnotation *)annotation
{
    // Invoked when a user taps an annotation
}

- (void)mapView:(NAMapView *)mapView hasChangedZoomLevel:(CGFloat)level
{
    // Invoked when the map zoom level changes
}

@end

See NAAnnotationDemoViewController.m for a complete example.

Tiled Maps

NAMapKit comes with NATiledImageMapView, which supports tiled maps. A typical organization for deep zoom map tiles consists of a folder for each zoom level and individual JPG files for each tile. You can see an example of such files here. NAMapKit uses ARTiledImageView. You can generate tiles using dzt or any other tool listed with the OpenSeadragon project.

For a complete example of a tiled map, see NATiledImageDemoViewController.m.

Custom Gestures

NAMapKit exposes it's two double tap gestures so that you can use delaysTouchesBegan to prioritise the double tap over a map point tap. Or to just replace them entirely yourself.

Notes

If you are using Interface Builder, you can add a UIScrollView to your XIB and change the class to NAMapView to use the framework.

License

This project is licensed under the MIT license.

Attribution

When using this code please include the following attribution:

Includes NAMapKit code developed by Neil Ang, Tony Arnold, Daniel Doubrovkine and Orta Therox.

namapkit's People

Contributors

dblock avatar neilang avatar orta avatar ashfurrow avatar skela avatar donny avatar joeshi avatar tonyarnold avatar troyz avatar

Watchers

 avatar  avatar

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.