mkannotation

iOS 6 maps- not animating PIN drop

拟墨画扇 提交于 2019-12-06 04:42:05
I have created a custom MKAnnotation class and it has been working - until iOS 6 came out. Since then my pins get added to the apple map but now without a drop animation! Is this how it is set or there maybe an an issue with the way I'm doing things. I have set a delay of 1 sec until the method that adds the annotations to the map is called, so I can see if the drop animations are actually occurring before the view appears - still, the pins just appear out of nowhere without dropping. Here's the code I'm using: -(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(Annotation*

How to Show Multiple Annotation in MKMapView iOS?

三世轮回 提交于 2019-12-06 01:24:54
i am newbie in iOS Development i want to Show multiple Annotation in MKMapViewController in iOS for that i write a code as in my viewDidLoad method - (void)viewDidLoad { [super viewDidLoad]; self.mapView.delegate=self; NSArray *name=[[NSArray alloc]initWithObjects: @"VelaCherry", @"Perungudi", @"Tharamani", nil]; self.annotation=[[NSMutableArray alloc]initWithCapacity:[name count]]; MKPointAnnotation *mappin=[[MKPointAnnotation alloc]init]; CLLocationCoordinate2D location; location.latitude=(double)12.970760345459; location.longitude=(double)80.2190093994141; mappin.coordinate=location; mappin

Change MKMapType in MKMapView and keep custom pinImage for annotations

别来无恙 提交于 2019-12-06 00:19:37
I have set a custom pinImage for my annotations and when I change the type to MKMapTypeHybrid it reverts the pinImage setting to the standard pins. I'm setting the mapType in my viewWillAppear method of the map view controller. I'm setting my pinImage for the annotations like so (shortened for clarity): - (MKAnnotationView *) mapView:(MKMapView *) mapView viewForAnnotation:(id ) annotation { MKPinAnnotationView *customAnnotationView=[[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"markerAnnotationView"] autorelease]; UIImage *pinImage = [UIImage imageNamed:@"/pin

Swift - Changing Annotation Image Not Working

天涯浪子 提交于 2019-12-05 19:31:03
I have followed other stack posts and tutorials in changing my annotations image to a custom one, but it does not seem to work. No errors or runtime errors appear, it's just that the annotation image does not change. Just by the way I set a break point on the line annotationView!.image = UIImage(named: "RaceCarMan2png.png") and it shows that the line is being called, but yet nothing happens. I would really appreciate your help. Thanks. func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { if annotation is MKUserLocation { return nil } let

How to make custom MKAnnotation draggable

六月ゝ 毕业季﹏ 提交于 2019-12-05 15:04:29
I need MKAnnotation with different pin image. So I created following: @interface NavigationAnnotation : NSObject <MKAnnotation> - (id)initWithName:(NSString*)name address:(NSString*)address coordinate:(CLLocationCoordinate2D)coordinate; ... @interface NavigationAnnotation () @property (nonatomic, copy) NSString *name; @property (nonatomic, copy) NSString *address; @property (nonatomic, assign) CLLocationCoordinate2D theCoordinate; @end @implementation NavigationAnnotation - (id)initWithName:(NSString*)name address:(NSString*)address coordinate:(CLLocationCoordinate2D)coordinate { if ((self =

Prevent touch events on MKMapView being detected when a MKAnnotation is tapped

感情迁移 提交于 2019-12-05 13:23:41
I have a UITapGestureRecognizer that will hide and show a toolbar over my MKMap when the user taps the Map - simple. However, when the user taps on an MKMapAnnotation, I do not want the map to respond to a tap in the normal way (above). Additionally, when the user taps elsewhere on the map to de-select an MKAnnotation callout, I also don't want the toolbar to respond. So, the toolbar should only respond when there are no MKAnnotations currently in selected state. Nor should it respond when the user clicks on an annotation directly. So far, I have being trying the following action that reacts

Protocol can only be used as a generic constraint

守給你的承諾、 提交于 2019-12-05 13:21:30
I have a MapViewController for presenting annotations on map. It contains an object of type MapPresentable. protocol MapPresentable { associatedtype AnnotationElement: MKAnnotation var annotations: [AnnotationElement] { get } } class MapViewController<M: MapPresentable>: UIViewController { var mapPresentable: M! } MapViewController can also present route on map in case mapPresentable conforms to RoutePresentable protocol. protocol RoutePresentable: MapPresentable { var getRouteLocations: [CLLocation] { get } } But when checking made inside MapViewController if let routePresentable =

Custom MKAnnotation Image goes back to default when I attempt to drag

左心房为你撑大大i 提交于 2019-12-05 03:59:07
I've got a bunch of MKAnnotations that don't need dragging. I set this by [pin setDraggable:NO] . I'm having an issue when I touch the annotation and (accidentally) drag off an annotation, it instantly looses it's custom image and changes back to the default red pin. How do I prevent this from happening? In the viewForAnnotation delegate method, make sure the view is created as an MKAnnotationView and not an MKPinAnnotationView (which is a subclass of MKAnnotationView that automatically provides a pin image). 来源: https://stackoverflow.com/questions/5373265/custom-mkannotation-image-goes-back

Show address in annotation when pin is dropped on map

▼魔方 西西 提交于 2019-12-05 02:32:57
问题 Currently I can drop pins around the map. Now I want the annotation title to display the address of where the pin is dropped. I've had a look at this but cant get mine to work: Set annotation's title as current address Code in my ViewController.m Updated. - (void)addPinToMap:(UIGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state != UIGestureRecognizerStateBegan) return; CGPoint touchPoint = [gestureRecognizer locationInView:self.map]; CLLocationCoordinate2D touchMapCoordinate

Change pin design

混江龙づ霸主 提交于 2019-12-05 02:27:03
问题 Is it possible to change the MKAnnotation pin to a png of my own design? 回答1: override this and be a delegate of MKMapViewDelegate to implement override the method. - (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation; Create an annotation, MKAnnotationView *annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];// get a dequeued view for the annotation like a tableview if (annotationView == nil) {