mapkit

Swift- MKMapkit view only one city?

心不动则不痛 提交于 2020-01-03 05:42:27
问题 I'm trying to make an app viewing the college I'm going to but I'm having trouble only viewing the one city. I'm trying to make sure that the user cannot scroll past the city. I'm then trying to overlay that region. I thought the setRegion method would help fix that issue but apparently not. Any suggestions on how to set the region in which the user cannot surpass? super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. // sets maps to univeristy var

How to pass data from one View Controller to another in a Storyboard when going back?

…衆ロ難τιáo~ 提交于 2020-01-03 05:08:11
问题 Scenario: Storyboard with UINavigationController as initial controller. MainVC (navigation controller's root vc) needs the user to choose a location on a map. MainVC pushes a VC containing a MapKit map and adds itself as listener for a notification the MapVC sends out when the user chooses a location. MapKit is a memory hog, we all know that. iOS gives me a memory warning, I do all the things that need to be done, then iOS deallocates all it can deallocate, including the MainVC. MapVC sends

How to delete the last annotation on a mapView

萝らか妹 提交于 2020-01-03 03:41:09
问题 I have added a button on my .xib file with which I want to delete the last annotation that has been added. So on the Touch-Down action I have implemented this: -(IBAction)DeleteAnnotation:(id)sender { [mapview removeAnnotation:[mapview.annotations lastObject]]; } and I have even tried it this way: -(IBAction)DeleteAnnotation:(id)sender { [self.mapview removeAnnotation:self.mapview.annotations.lastObject]]; } where mapview is my MKMapView Outlet. The problem I encounter with both ways is that

How to draw UIBezierPath overlay on MKMapView?

为君一笑 提交于 2020-01-02 21:54:31
问题 I try to subclass from MKOverlayPathRenderer and implement -createPath - (void)createPath { MKPolyline *line = (id)self.overlay; MKMapPoint *points = line.points; NSUInteger pointCount = line.pointCount; CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, points[0].x, points[0].y); for (int i = 1; i < pointCount; i++) { CGPathAddLineToPoint(path, NULL, points[i].x, points[i].y); } [self setPath:path]; } I create overlay here: CLLocationCoordinate2D coordinates[events

iPhone MapKit problems: viewForAnnotation inconsistently setting pinColor?

て烟熏妆下的殇ゞ 提交于 2020-01-02 07:59:09
问题 I'm trying setup a map that displays different pin colors depending on the type/class of the location in question. I know this is a pretty common thing to do, but I'm having trouble getting the viewForAnnotation delegate to consistently update/set the pin color. I have a showThisLocation function that basically cycles through a list of AddressAnnotations and then based on the annotation class (bus stop, hospital, etc.) I set an if( myClass == 1){ [defaults setObject:@"1" forKey:@"currPinColor

Swift: Reduce Function with a closure

南笙酒味 提交于 2020-01-02 07:52:56
问题 Below is the code that I'm struggling to understand: let rectToDisplay = self.treasures.reduce(MKMapRectNull) { //1 (mapRect: MKMapRect, treasure: Treasure) -> MKMapRect in //2 let treasurePointRect = MKMapRect(origin: treasure.location.mapPoint, size: MKMapSize(width: 0, height: 0)) //3 return MKMapRectUnion(mapRect, treasurePointRect) } My understanding of reduce function is: var people [] // an array of objects var ageSum = 0 ageSum = people.reduce(0) { $0 + $1.age} //(0) = initial value /

How to Open Google Map Navigation Url with Direction and Voice in iOS?

百般思念 提交于 2020-01-02 07:05:31
问题 i am newbie in iOS I want to make an app that contain map kit navigation.i want to open navigation url of google map if user device have Google map application. if it is not contain then i want to open Apple map Here i write a code for like as -(IBAction)navigationButtonPressed:(id)sender { if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps://"]]) { NSString *urlString=[NSString stringWithFormat:@"comgooglemaps://?center=%f,%f&zoom=14&views=traffic",self

Detecting panning + decelerate of MKMapView

狂风中的少年 提交于 2020-01-02 06:16:13
问题 I'm trying to capture panning and the 'end of scrolling' on an MKMapView. Panning is easy to do with a gesture recognizer. However, MKMapView doesn't seem to implement a UIScrollViewDelegate in iOS 6. That makes the solution in Is there way to limit MKMapView maximum zoom level? not work. Thoughts? Ideally I would have just leveraged the UIScrollViewDelegate as such: -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { if ([super respondsToSelector:@selector

Compiler error: Invalid library file - CoreLocation

那年仲夏 提交于 2020-01-02 01:08:09
问题 I have one of my application, that is created in Xcode 8. I have used CoreLocation and MapKit in that app. I have update app with latest iOS till now. and it was working fine. Now I am updating application with iOS 1 . So I hvae opened app with Xcode 11.0 and updated all the required code. Also updated setting that is suggested by Xcode "Perform Changes" and all that. Now I run application, but I am getting error like : Compiler error: Invalid library file . I have searched lot, but can't

iOS SDK: MapKit MKPolyLine not showing

喜你入骨 提交于 2020-01-01 18:51:11
问题 I'm trying to display a polyline on my map, but the line doesn't show up. I tried a lot of things, but noting seems to work. I checked the Core Data functions, and it is returning data, so that is not the problem. It must me somewhere in the mappoint creation or the dwawing on the map (I guess). I'm sure it must be a little mistake somewhere, but I can't find it. My code: - (void)viewDidLoad { [super viewDidLoad]; AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];