neilang / namapkit Goto Github PK
View Code? Open in Web Editor NEWAllows you to use custom maps in iphone applications and attempts to mimics some of the behaviour of the MapKit framework
License: MIT License
Allows you to use custom maps in iphone applications and attempts to mimics some of the behaviour of the MapKit framework
License: MIT License
How to include this NAMapkit to another ios project
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:
NAPinAnnotationView
, but we should extract the annotations into something that supports a protocol so that ours can be its own thing.@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?
Add support for a leftCalloutAccessoryView
to NAPinAnnotation
.
This is something that ARTiledImageView handles, thus it's the responsibility of it to define the deps.
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.
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]
@neilang Claim ownership of NAMapKit on https://trunk.cocoapods.org/claims and add the rest of the crew to the maintainers list, please.
I suspect the snapshot tests are now failing because of iOS version mismatch. We probably need facebookarchive/ios-snapshot-test-case#19.
From #52, add a demo project that uses a completely custom pin annotation image.
*** 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
This is generic image zooming functionality. Likely useful as a standalone thing.
cc: @orta
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)
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.
Allow a custom image instead of the pin.
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.
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.
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.
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;
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
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:
Anyway it's a already a really handy component so thanks guys for releasing it!
Cheers,
Nick
Feature request.
how to minimize the map view .i want to make the minimize the zoom level of map when the view was loaded
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). :)
In #46 snapshot tests were removed because YOLO.
Allow NAAnnotations to be created from MKAnnotations. Even better, make it a sub-protocol of MKAnnotation so I can use my existing map points.
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
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.
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];
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.
Hi ,
I want to use NAMApkit include into my swift project by creating bridge header file(not with pod).can u please help me with it
Hi,
i want to implement NAMapkit in swift project using bridge header.can you please help me
Image files are inconsistently named (camelCase vs. _underscore):
callout_anchor.png
[email protected]
callout_bg.png
[email protected]
callout_left.png
[email protected]
callout_right.png
[email protected]
pinGreen.png
[email protected]
pinGreenFloating.png
[email protected]
pinPurple.png
[email protected]
pinPurpleFloating.png
[email protected]
pinRed.png
[email protected]
pinRedFloating.png
[email protected]
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.
Pop out the call-out manually. The equivalent of [MKMapView selectAnnotation]
Hi ,
i really need help to include this library into swift project using bridge header i.e without pod installation
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.