Coder Social home page Coder Social logo

neilang / namapkit Goto Github PK

View Code? Open in Web Editor NEW
264.0 264.0 52.0 18.09 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 People

Contributors

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

namapkit's Issues

Add map tiling support (merge orta/NAMapKit)

We've been working off a fork of NAMapKit for the Artsy iPhone app (http://iphone.artsy.net, try the Armory Show). That code diff is orta/NAMapKit@neilang:master...master. It will take a bit of effort to merge. Most importantly it supports image tiling.

I think there're really two things:

  • Generalize annotations, we hacked NAPinAnnotationView, but we should extract the annotations into something that supports a protocol so that ours can be its own thing.
  • Rebuild tiling on top with a working example.

@orta who wrote a lot of this code will comment here

@neilang There hasn't been much development here for a bit, can we count on you to be looking at PRs?

Convert lat/long to image coordinates

Automatically translate from real lat/long co-ordinates to the map image. I've got the MKCoordinateRegion that my image represents, so by using that it should be able to convert the points for me. Again, this will let me use my existing MKAnnotations.

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]

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

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)

Fail to drop a pin in Swift project

This is how I use the project

target 'UIExamples' do
  pod 'NAMapKit', '~> 3.2.0'
end

code:

 let pin = NAPinAnnotation(point: location!)
 pin.color = NAPinColorRed
 pin.title = "Hi"
 mapView.addAnnotations([pin], animated: true)

If I change to NADotAnnotation, it can successfully drop a pin. But NAPinAnnotation cannot.

I placed a break point at line 60 in NAPinAnnotationView.m, the pinImage object is null.

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.

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.

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.

Replace fabsf with ABS macro to avoid warnings

There's currently 3 warnings in this library. 2 are because of the use of fabsf which is only correct when CGFloat is an alias for floats. Because this isn't always the case (64bit/32bit) it's giving 2 warnings.

If you replace the fabsf with the ABS macro, 2 warnings go away:

BOOL hasContentSize = fabsf(self.originalSize.width) > 0 && fabsf(self.originalSize.height) > 0;

BOOL hasContentSize = ABS(self.originalSize.width) > 0 && ABS(self.originalSize.height) > 0;

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

Some feature suggestions

Hey Neil,

I'm using this in conjunction with a live MKMapView to show an offline view of the same area (so I have a map image on the device which the user can flip to if they aren't online).

Anyway, there are a few things that would make this a perfect replacement for my current solution. I'll probably work on some of these myself, but will list them here as well:

  1. Allow NAAnnotations to be created from MKAnnotations. Even better, make it a sub-protocol of MKAnnotation so I can use my existing map points.
  2. Automatically translate from real lat/long co-ordinates to the map image. I've got the MKCoordinateRegion that my image represents, so by using that it should be able to convert the points for me. Again, this will let me use my existing MKAnnotations.
  3. Pop out the call-out manually. The equivalent of [MKMapView selectAnnotation]
  4. Add a leftCalloutAccessoryView to the annotation.
  5. Allow a custom image instead of the pin.
  6. 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.

Anyway it's a already a really handy component so thanks guys for releasing it!

Cheers,
Nick

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). :)

Handle MKAnnotations

Allow NAAnnotations to be created from MKAnnotations. Even better, make it a sub-protocol of MKAnnotation so I can use my existing map points.

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.

Dropping pins on zoomed maps

There is an issue with adding a pin after the zoom scale has been changed.

Simple workaround is to reset the zoom scale to 1.0 before adding the pin.

e.g.

// Calculate zoomed out position
CGPoint point = CGPointMake(location.x / self.mapView.zoomScale, location.y / self.mapView.zoomScale);

// Zoom to default level
[self.mapView setZoomScale:1.0 animated:YES];

// Focus on correct position
[self.mapView centreOnPoint:point animated:YES];

// Add annotation at new point
... = [NAAnnotation annotationWithPoint:point];

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.

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.