mkmapview

How do I load different custom pins or identifiers based off of their property values?

荒凉一梦 提交于 2019-12-13 05:17:51
问题 I have an array of objects that conform to <MKAnnotation> . I load this array into my annotations using addAnnotations:. In the method: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation: (id<MKAnnotation>)annotation I have every pin load a custom image using: annotationView.image = [UIImage imageNamed:@"purp_pin.png"]; However, I don't want all the pins to load with this image. I want it to load a different custom image/identifier depending on the properties the object that

Parse objects as AnnonationPoints

此生再无相见时 提交于 2019-12-13 05:16:05
问题 I'm trying to show a set of parse objects in a MKMapView as Annonations. This seem to work, the problem is that the objects images are swapped, which is kind of random? i've started creating a subclass of the MKPointAnnotation in order to save the image. How come the images are swapped around? Custom MKPointAnnonation class class AnnonationClass: MKPointAnnotation { var itemId: NSString? var itemImage: PFFile? var itemdescription: NSString? } getting the parse objects and adding them using

With what coordinates do i use to manually draw a custom path with an MKMapView?

心不动则不痛 提交于 2019-12-13 04:58:55
问题 There are CLLocation2D points, MKMapPoints , MKCoordinates , and convertCoordinate:toPointInView: which all give you points in one form or another. I am drawing a custom route in: - (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context { Whats the proper point to use for drawing? 回答1: routeView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, mapView.frame.size.width, mapView.frame.size.height)]; routeView.userInteractionEnabled = NO;

pins not showing up in mapView. Swift 5

ⅰ亾dé卋堺 提交于 2019-12-13 04:26:05
问题 I need to display pins ( annotations ) on a map. Then draw polygon lines from pin to pin ( annotation to annotation ) I receive an array of Doubles that I convert to CLLocationCoordiante2D. the first lat and long values are always 0.0 so I remove those from the array because I don't want any issues there. I map the doubles to the coordinates, and add them to the mapView I also included a viewFor function with I thought I don't really need? the map doesn't zoom to any location and NO pins are

iPhone Development - Is Pin Annotation in a viewable Map Region

大兔子大兔子 提交于 2019-12-13 03:05:04
问题 How can i check if a pin is in viewable region of the map (MKMapView)? 回答1: A pin is a MKPinAnnotationView , it extends from MKAnnotationView and has a property annotation (that conforms to the protocol MKAnnotation ). Such annotation has itself another property coordinate . Just compare the latitude / longitude of such coordinate to the region of your map. something like this should do it : double minLong = myMap.region.center.longitude - myMap.region.span.longitudeDelta/2.0; double maxLong

MKMapView Not Loading When Called on an NSThread?

一个人想着一个人 提交于 2019-12-13 03:04:03
问题 I am creating a MKMapView in a method named "generateMap". From inside viewDidLoad, this works: [self generateMap]; but this causes the map to quickly load and then disappear, leaving only the blank grey grid: [NSThread detachNewThreadSelector:@selector(generateMap) toTarget:self withObject:nil]; Any ideas why this might be happening when I call the method through a thread? I ended up doing this: -(void)viewDidLoad { [NSThread detachNewThreadSelector:@selector(spinTheSpinner) toTarget:self

Load only five annotations to MKMapVIew

半城伤御伤魂 提交于 2019-12-13 02:33:12
问题 I have a MKMapView, and I would like to know how I can find the nearest 5 annotations to the user, and only display them on the MKMapView. My code currently is: - (void)loadFiveAnnotations { NSString *string = [[NSString alloc] initWithContentsOfURL:url]; string = [string stringByReplacingOccurrencesOfString:@"\n" withString:@""]; NSArray *chunks = [string componentsSeparatedByString:@";"]; NSArray *keys = [NSArray arrayWithObjects:@"type", @"name", @"street", @"address1", @"address2", @"town

why CLLocationManager always returns true?

北战南征 提交于 2019-12-13 00:33:18
问题 I am using [CLLocationManager locationServicesEnabled] function to get the status whether location service is enabled or not. I kept code in viewDidLoad method. if(![CLLocationManager locationServicesEnabled]) { NSLog(@"No"); } else { NSLog(@"Yes"); } When I am running this app first time it returns Yes . Why? It should return me No . This is the case when I did not select "Allow" or "Don't allow" options. Means I neither allow nor don't allow but in viewDidLoad I got Yes . Now I select "Don

How to display and connect multiple locations with a route with annotations in an MKMapView inside an iPhone App?

一世执手 提交于 2019-12-12 20:58:42
问题 I need to display a MKMapView with more than 4 locations with different Annotations and a route connecting the locations. I have tried to display the multiple locations inside a MKMapView but i still not able to find out on how to connect the locations with a route. I am also trying to get this checked if i have implemented it in a right way. I have created a "CLLocationCoordinate2D" and then added a lat and long similarly for 4 points. I have created a custom object which implements

Sometimes strange artifact appears when [mapView selectAnnotation];

不问归期 提交于 2019-12-12 17:22:37
问题 [_mapView selectAnnotation:sannotation animated:YES]; It appears not always, so I don't understand what's the reason for it. How to fix it? 回答1: Before selecting any annotation deselect all annotations on mapView. for (id<MKAnnotation> annotation in mapView.annotations) [mymap deselectAnnotation:annotation animated:NO]; I had same issue when along with default callout, I had implemented custom callouts. Though it is not a perfect solution it served the purpose. 来源: https://stackoverflow.com