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

Related tags

Maps NAMapKit
Overview

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.

Comments
  • Create Pin annotation for my swift project using NAMapkit

    Create Pin annotation for my swift project using NAMapkit

    This was my code i have an image named floor_map as local image

    I am very new to IOS The pinannotation was not working but dotannotation was working perfect with same x and y co-ordinates.May be i dont know how to use this for pin annotation and also i want to show an image which replace the pin.can some one please help me.i am stuck

     let mapView: NAMapView = NAPinAnnotationMapView(frame: self.view.bounds)
        mapView.backgroundColor = UIColor.whiteColor()
        mapView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
        mapView.minimumZoomScale = 0.5
        mapView.maximumZoomScale = 1.5
        mapView.displayMap(UIImage(named: "floor_map"))
        self.view!.addSubview(mapView)
        let melbourne: NAPinAnnotation = NAPinAnnotation()
        melbourne.color = NAPinColorPurple
        melbourne.title = "Melbourne"
        melbourne.subtitle = "I have a subtitle"
        melbourne.point = CGPoint(x: 543.0, y: 450.0)
        mapView.addAnnotation(melbourne, animated: false)
    
    confirmed bug 
    opened by saravananNV 22
  • Release 3.0

    Release 3.0

    Opening a placeholder issue for the 3.0 release. I don't mean to rush anyone to cut a release with the changes for #13 that were put in. However, I'd like all that code not to sit idle either.

    Please comment with whatever you think you need to cut 3.0, I'm happy to do a bunch of work.

    opened by dblock 13
  • zoomRelativePoint: Can Lead to NaN Values

    zoomRelativePoint: Can Lead to NaN Values

    Consider the following code:

    - (CGPoint)zoomRelativePoint:(CGPoint)point
    {
        CGFloat x = (self.contentSize.width / self.originalSize.width) * point.x;
        CGFloat y = (self.contentSize.height / self.originalSize.height) * point.y;
        return CGPointMake(round(x), round(y));
    }
    

    If originalSize hasn't been set from CGPointZero, then the resulting x and y values can be NaN, so if you rely on the return value for this for some view geometry, it can lead to an app crash.

    bug? 
    opened by ashfurrow 9
  • Retain cycle bug

    Retain cycle bug

    When i run demo,i found a problem. When NAPinAnnotationsDemoViewController return to the NAMasterViewController, NAPinAnnotationsDemoViewController can't release. i check this demo with instruments tool,and found NAPinAnnotationsDemoViewController' count is always increase.

    bug? 
    opened by jinsongK 7
  • exposed imageView so that i can retrieve CGPoints using [gesture locationInView:mapView.imageView]

    exposed imageView so that i can retrieve CGPoints using [gesture locationInView:mapView.imageView]

    i was unable to accurately drop annotations when scale != 1. I’ve exposed the imageView so that when using gestures, you can get a more accurate CGPoint using something like [gesture locationInView:mapView.imageView]

    opened by multinerd 5
  • Updates travis' xcode to 7.2, re-adds tests

    Updates travis' xcode to 7.2, re-adds tests

    Didn't realise #46 basically removed all tests, sorry about that - really shouldn't have merged. We rely on NAMapKit a lot, I don't feel good about having it without any tests.

    Looks like the new snapshots were recording the new snapshots on a 9.0, but they were still being ran against 7.0. Apple will have made rendering changes between the two major versions. This fixes that.

    This should fix #47

    confirmed bug 
    opened by orta 5
  • CALayer position contains Nan

    CALayer position contains Nan

    *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x01f725e4 __exceptionPreprocess + 180
        1   libobjc.A.dylib                     0x01c818b6 objc_exception_throw + 44
        2   CoreFoundation                      0x01f723bb +[NSException raise:format:] + 139
        3   QuartzCore                          0x01a0bcaa _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 190
        4   QuartzCore                          0x01a0be69 -[CALayer setPosition:] + 68
        5   QuartzCore                          0x01a0c56f -[CALayer setFrame:] + 799
        6   UIKit                               0x00ae772c -[UIView(Geometry) setFrame:] + 302
        7   PeopleServer                        0x0007ee94 -[NACallOutView updatePosition] + 1524
        8   PeopleServer                        0x0007e83f -[NACallOutView observeValueForKeyPath:ofObject:change:context:] + 207
        9   Foundation                          0x0039b8c7 NSKeyValueNotifyObserver + 362
        10  Foundation                          0x0039d206 NSKeyValueDidChange + 458
        11  Foundation                          0x003598dd -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 120
        12  Foundation                          0x00323d1e _NSSetSizeValueAndNotify + 185
        13  PeopleServer                        0x0007ffbb -[NAMapView displayMap:] + 875
        14  PeopleServer                        0x00003fc8 -[ITYBeaconViewController selectionChangedForSegmentedControl:] + 1992
        15  PeopleServer                        0x00003473 __35-[ITYBeaconViewController loadMaps]_block_invoke + 803
        16  PeopleServer                        0x0000771e __47-[ITYPeopleManager getMapsWithSuccess:failure:]_block_invoke + 894
        17  PeopleServer                        0x00011f3e __47-[AFHTTPClient GET:parameters:success:failure:]_block_invoke + 126
        18  PeopleServer                        0x00036989 __59-[AFURLSessionManager dataTaskWithRequest:success:failure:]_block_invoke_3 + 121
        19  libdispatch.dylib                   0x023097f8 _dispatch_call_block_and_release + 15
        20  libdispatch.dylib                   0x0231e4b0 _dispatch_client_callout + 14
        21  libdispatch.dylib                   0x0230c75e _dispatch_main_queue_callback_4CF + 340
        22  CoreFoundation                      0x01fd7a5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
        23  CoreFoundation                      0x01f186bb __CFRunLoopRun + 1963
        24  CoreFoundation                      0x01f17ac3 CFRunLoopRunSpecific + 467
        25  CoreFoundation                      0x01f178db CFRunLoopRunInMode + 123
        26  GraphicsServices                    0x03afc9e2 GSEventRunModal + 192
        27  GraphicsServices                    0x03afc809 GSEventRun + 104
        28  UIKit                               0x00a90d3b UIApplicationMain + 1225
        29  PeopleServer                        0x0000811d main + 141
        30  libdyld.dylib                       0x025b070d start + 1
        31  ???                                 0x00000001 0x0 + 1
    )
    libc++abi.dylib: terminating with uncaught exception of type NSException
    
    opened by ravishanker 5
  • Add popup menu that like `City Guides by National Geographic`

    Add popup menu that like `City Guides by National Geographic`

    This is a popup menu that like City Guides by National Geographic, the document have updated, please reference the section Circle popup menu with NAPinAnnotation.

    Thanks!

    opened by troyz 4
  • "ImageIO_PNG_Data"'s count always increase after wake up from background

    step1.i jump to the "Pin Annotations Demo" view then exit to the home view. step2.click home button,demo will go to the background.then double-click home button,select demo app,and Repeat the previous operation

    opened by jinsongK 3
  • Tests for tiled image map view controller + bugs + docs + zoom.

    Tests for tiled image map view controller + bugs + docs + zoom.

    Fixed downloading of tiles that may happen multiple times. In a slow network tiles will take a long time to download, but you may get lots of repaint events. This will cause the queue to get more downloads for the same tiles already being downloaded. We now hold on to a map of URLs to downloads and make sure to only have a single download operation per url running.

    Added tests for the tiled image view controller. Notice a missing tile in the snapshot image, this seems to be a bug in iOS (@orta, can you comment with some links, please?).

    Zoom will now pan towards the point being tapped. This is really neat and works like any good map would :) All credit is @orta.

    opened by dblock 3
  • Fine tune gesture zoom behaviour

    Fine tune gesture zoom behaviour

    The double-tap and two-finger tap gestures don't seem to behave exactly like MKMapView... eg. if you keep double-tapping it will zoom back out. The gesture code for my current solution works nicely, I could probably copy that across.

    opened by nicked 3
  • Open callout when the map opens

    Open callout when the map opens

    I have my map zoom to a specific pin when they click a locate on map button from another view controller. I was curious if it is possible to open the callout for that specific annotation as well when I hit the locate on map button.

    question 
    opened by richbuddy 1
  • Fix warnings during pod trunk push

    Fix warnings during pod trunk push

    I pushed 3.2.1 and had to use --allow-warnings.

        - NOTE  | xcodebuild:  Headers/Private/SDWebImage/UIImageView+WebCache.h:198:1: note: 'setImageWithURL:' has been explicitly marked deprecated here
        - WARN  | xcodebuild:  ARTiledImageView/Classes/ARTiledImageView.m:162:54: warning: 'downloadWithURL:options:progress:completed:' is deprecated: Method deprecated. Use `downloadImageWithURL:options:progress:completed:` [-Wdeprecated-declarations]
        - NOTE  | xcodebuild:  Headers/Private/SDWebImage/SDWebImageManager.h:294:1: note: 'downloadWithURL:options:progress:completed:' has been explicitly marked deprecated here
        - WARN  | xcodebuild:  NAMapKit/NAMapKit/NAMapView.m:131:10: warning: unused variable 'hasContentSize' [-Wunused-variable]
        - WARN  | xcodebuild:  NAMapKit/NAMapKit/NAPinAnnotation.m:15:60: warning: auto property synthesis will not synthesize property 'view'; it will be implemented by its superclass, use @dynamic to acknowledge intention [-Wobjc-property-synthesis]
        - NOTE  | xcodebuild:  NAMapKit/NAMapKit/NAAnnotation.h:22:41: note: property declared here
        - NOTE  | xcodebuild:  NAMapKit/NAMapKit/NAPinAnnotation.m:18:17: note: detected while default synthesizing properties in class implementation
        - WARN  | xcodebuild:  NAMapKit/NAMapKit/NATiledImageMapView.m:100:26: warning: 'setImageWithURL:' is deprecated: Method deprecated. Use `sd_setImageWithURL:` [-Wdeprecated-declarations]
    
    chore 
    opened by dblock 0
  • Custom Pop on clicking pin annotation

    Custom Pop on clicking pin annotation

    can any one plz help me. i have worked with customizing with my own images .now i want to show my own customized popup while clicking pin. how to achieve this..

    Thanks

    question 
    opened by saravananNV 1
  • Add ability to remove all annotations from the map

    Add ability to remove all annotations from the map

    There's a removeAnnotation method, but no removeAnnotations. Would be cool to be able to just remove all the annotations with 1 command, especially since the annotations array is not exposed.

    new feature 
    opened by skela 1
  • Add LongPressGesture to NAPinAnnotationView

    Add LongPressGesture to NAPinAnnotationView

    With the long press gesture applied to the AnnotationView, to allow it to be draggable and re-position on the new drop point.

    (Sorry, if I put this suggestion at the wrong spot). :)

    new feature 
    opened by japanconman 1
Releases(v3.0)
Owner
Neil Ang
The coolest guy on GitHub
Neil Ang
Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL

Mapbox GL Native A C++ library that powers customizable vector maps in native applications on multiple platforms by taking stylesheets that conform to

Mapbox 4.2k Jan 9, 2023
JDSwiftMap is an IOS Native MapKit Library. You can easily make a highly customized HeatMap.

JDSwiftMap is an IOS Native MapKit Library. You can easily make a highly customized HeatMap. Installation Cocoapods pod 'JDSWiftHeatMap' Usage JDSwi

郭介騵 135 Dec 26, 2022
Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.

MapViewPlus About MapViewPlus gives you the missing methods of MapKit which are: imageForAnnotation and calloutViewForAnnotationView delegate methods.

Okhan Okbay 162 Nov 16, 2022
Example app using MessagesUI + CoreLocation + MapKit

iOS Example MapKit App Ejemplo de código de una aplicación de mapas usando MessagesUI, MapKit y CoreLocation Built using XCode 13.0 (Swift 5) ¿Cómo ej

Manu Martinez 0 Oct 19, 2021
MapKit, but for SwiftUI

MapKit, but for SwiftUI

Lawrence Bensaid 2 Jul 1, 2022
MKMapView wrapper for SwiftUI as drop-in to MapKit's SwiftUI view

MKMapView wrapper for SwiftUI as drop-in to MapKit's SwiftUI view. Easily extensible annotations and overlays, iOS 13 support and backwards compatible with MKAnnotation and MKOverlay!

Paul 73 Dec 26, 2022
Use Swift in the macOS command line to build maps.

Use Swift in the macOS command line to build maps. imagefrom A Swift command line utility that gets an image from a URL. Saves the web image as JPEG o

Rob Labs 0 Dec 30, 2021
MSFlightMapView allows you to easily add and animate geodesic flights to Google map

MSFlightMapView Demo Requirements iOS 10.0+ Xcode 9.0+ Installation Just add the MSFlightMapView folder to your project. or use CocoaPods: pod 'MSFlig

Muhammad Abdul Subhan 48 Aug 13, 2022
A spatial analysis library written in Swift for native iOS, macOS, tvOS, watchOS, and Linux applications, ported from Turf.js.

Turf for Swift ?? ?? ?? ?? ⌚️ A spatial analysis library written in Swift for native iOS, macOS, tvOS, watchOS, and Linux applications, ported from Tu

Mapbox 187 Dec 19, 2022
Campus Atlas -- a Mapping & GIS solution which provides easy access to navigating the campus around you.

Campus Atlas Welcome to Campus Atlas -- a Mapping & GIS solution which provides easy access to navigating the campus around you. Technical Implementat

Larry Tseng 5 Nov 12, 2021
Location, motion, and activity recording framework for iOS

LocoKit A Machine Learning based location recording and activity detection framework for iOS. Location and Motion Recording Combined, simplified Core

Matt Greenfield 1.5k Jan 2, 2023
A Swift wrapper for forward and reverse geocoding of OpenStreetMap data

Nominatim NominatimKit is a Swift wrapper for forward and reverse geocoding of OpenStreetMap data. Why? Geocoding location data on iOS requires the us

Josef Moser 53 Feb 5, 2022
Demo in SwiftUI of Apple Map, Google Map, and Mapbox map

SNMapServices SNMapServices is a serices for iOS written in SwiftUI. It provides Map capability by subclassing Mapbox, Google map and Apple map. This

Softnoesis 3 Dec 16, 2022
An iOS map clustering framework targeting MapKit, Google Maps and Mapbox.

ClusterKit is an elegant and efficiant clustering controller for maps. Its flexible architecture make it very customizable, you can use your own algor

null 502 Dec 25, 2022
🗺️ MAPS.ME — Offline OpenStreetMap maps for iOS and Android

MAPS.ME MAPS.ME is an open source cross-platform offline maps application, built on top of crowd-sourced OpenStreetMap data. It was publicly released

MAPS.ME 4.5k Dec 23, 2022
Card-based view controller for apps that display content cards with accompanying maps, similar to Apple Maps.

TripGo Card View Controller This is a repo for providing the card-based design for TripGo as well as the TripKitUI SDK by SkedGo. Specs 1. Basic funct

SkedGo 6 Oct 15, 2022
A library that allows you to generate and update environment maps in real-time using the camera feed and ARKit's tracking capabilities.

ARKitEnvironmentMapper Example To run the example project, clone the repo, and run pod install from the Example directory first. Installation ARKitEnv

SV Hawks 91 Dec 4, 2022
A library that allows you to generate and update environment maps in real-time using the camera feed and ARKit's tracking capabilities.

ARKitEnvironmentMapper Example To run the example project, clone the repo, and run pod install from the Example directory first. Installation ARKitEnv

SV Hawks 91 Dec 4, 2022
This UI attempts to capture the Quibi Card Stack and the associated User Interaction.

RGStack This UI attempts to capture the Quibi Card Stack and the associated User Interaction. Required A View that conforms to the ConfigurableCard pr

RGeleta 96 Dec 18, 2022