mkannotation

Hide MKUserLocation when MKMapView showsUserLocation == YES

前提是你 提交于 2019-11-30 14:08:04
After setting mapView.showsUserLocation to true, is it possible to receive location updates without showing the MKUserLocation bubble? Returning nil in mapView:viewForAnnotation: simply shows the bubble, and returning any other kind of annotation shows an annotation, which I don't want. You can hide the user location's view in the didAddAnnotationViews delegate method: -(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { MKAnnotationView *ulv = [mapView viewForAnnotation:mapView.userLocation]; ulv.hidden = YES; } Swift 3: func mapView(_ mapView: MKMapView, didAdd views:

How do I drop a pin with MapKit?

℡╲_俬逩灬. 提交于 2019-11-30 10:40:04
问题 I would like to allow the user of my app to pick a location in the map. The native map has a "drop pin" feature where you can locate something by dropping a pin. How can I do this in MapKit? 回答1: You need to create an object that implements the MKAnnotation protocol and then add that object to the MKMapView : @interface AnnotationDelegate : NSObject <MKAnnotation> { CLLocationCoordinate2D coordinate; NSString * title; NSString * subtitle; } Instantiate your delegate object and add it to the

Swift - Custom MKAnnotationView, set label title

守給你的承諾、 提交于 2019-11-30 06:59:33
问题 I am trying to customise the MKAnnotationView for my mapView callout bubbles. I am fine with setting the annotation title when the annotation is created, and also customising the MKAnnotationView to add labels or images e.t.c (in the viewForAnnotation delegate), but how do I change the label created in the viewForAnnotation delegate, so that the title of it is different for each pin? The other issue I have is that if I don't add a title or subtitle to the annotation when it is created in the

Grouped/Ungroup MKAnnotation depending on the zoom level (And keep it fast)

情到浓时终转凉″ 提交于 2019-11-30 00:44:50
I have a mapview that has a lot of annotations, most of them are very close to each other. What I want to do is similar to the Photo app on iOS where annotations are grouped when they are too close to each other and whenever you zoom out, they un grouped if they are too far apart. I have seen this question already but the answer given isn't really what I was looking for. I'm looking for either a library or a algorithm that I could implement myself. Aurelien Porte Have a look here in order to see the full answer. It contains both implementations for MapKit and Google Maps. The code is inspired

Zoom to fit region for all annotations - ending up zooming in between annotations

僤鯓⒐⒋嵵緔 提交于 2019-11-29 22:02:46
问题 I have a problem with fitting all my annotations to the screen... sometimes it shows all annotations, but some other times the app is zooming in between the two annotations so that none of them are visible... I want the app to always fit the region to the annotations and not to zoom in between them... what do I do wrong? if ([mapView.annotations count] == 2) { CLLocationCoordinate2D SouthWest = location; CLLocationCoordinate2D NorthEast = savedPosition; NorthEast.latitude = MAX(NorthEast

How do I drop a pin with MapKit?

走远了吗. 提交于 2019-11-29 21:48:20
I would like to allow the user of my app to pick a location in the map. The native map has a "drop pin" feature where you can locate something by dropping a pin. How can I do this in MapKit? RedBlueThing You need to create an object that implements the MKAnnotation protocol and then add that object to the MKMapView : @interface AnnotationDelegate : NSObject <MKAnnotation> { CLLocationCoordinate2D coordinate; NSString * title; NSString * subtitle; } Instantiate your delegate object and add it to the map: AnnotationDelegate * annotationDelegate = [[[AnnotationDelegate alloc] initWithCoordinate

iOS refresh annotations on mapview

心不动则不痛 提交于 2019-11-29 19:17:07
问题 I have a mapview where the annotation's coordinates are constantly being updated but when I use setCoordinate, the annotation does not move. How do I refresh the annotations to reflect their coordinates? - (void)updateUnits { PFQuery *query = [PFQuery queryWithClassName:@"devices"]; [query whereKeyExists:@"location"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { for (PFObject *row in objects) { PFGeoPoint *geoPoint = [row objectForKey:@"location"

How to go to second view controller after click on disclosure indicator button

爷,独闯天下 提交于 2019-11-29 17:24:43
I would like to remove existing annotation from mapview. Scenerio is to click on existing annotation callout part (disclosureindicator button) and it would lead user to another viewcontroller and shows a button you could remove the selected annotation. Actually, I am working on to create exactly same google map application, that is part I am struggling now. Any help would be appreciated! abellina The MKMapView class has two methods you need to add/remove annotations: addAnnotation: id <MKAnnotation> removeAnnotation: id <MKAnnotation> You'd create a class that implements the protocol

custom annotation apple mapkit

青春壹個敷衍的年華 提交于 2019-11-29 17:08:44
I am trying to assign two custom annotations, one called "arsenal.png" and one called "chelsea.png" Using apple mapkit framework, xcode 7. Need assistance with code to achieve the customized markers. here is my implementation file: // TrucksViewController.m #import "TrucksViewController.h" #import "Annotation.h" @interface TrucksViewController () @end //Wimbledon Coordinates #define WIMB_LATITUDE 51.434783; #define WIMB_LONGITUDE -0.213428; //Stadium Coordinates #define ARSENAL_LATITUDE 51.556899; #define ARSENAL_LONGITUDE -0.106483; #define CHELSEA_LATITUDE 51.481314; #define CHELSEA

MKAnnotationView always shows infoButton instead of detailDisclosure btn

久未见 提交于 2019-11-29 15:03:19
has somebody an idea why i can't force the mapView callout to use a detailDisclosureBtn instead of infoButton? - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { static NSString *identifier = @"HPIPAnnotation"; if ([annotation isKindOfClass:[CoreCityAnnotation class]]) { MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [_mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; if (annotationView == nil) { annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; } else {