Questions tagged [mkannotation]

An Apple protocol, for model object representing a point on a map view

An object that adopts this MKAnnotation protocol manages the data that you want to display on the map surface. It does not provide the visual representation displayed by the map. Instead, your map view either registers particular classes for annotations or the delegate provides the MKAnnotationView objects needed to display the content of your annotations. When you want to display content at a specific point on the map, add an annotation object to the map view. When the annotation’s coordinate is visible on the map, the map view asks its delegate to provide an appropriate view to display any content associated with the annotation.

There is basic MKPointAnnotation class that is useful if you do not need to add your own custom properties to an annotation.

If you do implement your own object to conform to MKAnnotation, there are a few considerations:

  1. If you want your map to respond to changes to the coordinate, title, or subtitle of the annotation object, make sure to make these conform to KVO (e.g., in Swift, declare them as dynamic).

  2. Probably obvious, but if the annotation views are configured to be draggable, you will want to make the coordinate mutable.

See also

1277 questions
-1
votes
1 answer

Port existing obj c code to swift - unexpectedly found nil while unwrapping an Optional value

I am trying to use obj c library in swift but I am having issue with the following error: fatal error: unexpectedly found nil while unwrapping an Optional value I think that I am missing something in var annotationView:MKPinAnnotationView!…
1110
  • 7,829
  • 55
  • 176
  • 334
-1
votes
1 answer

Show annotation like iPhone maps application when zoom MKMapview

I'm developing a iOS Map application. My concern is when user zoom In/ zoom out the map by default there are couple of places(like it will show some coffee shops,restaurants,etc... with respective icons for each) will be highlighting based on the…
AskIOS
  • 918
  • 7
  • 19
-1
votes
2 answers

How to find map annotations that fit my criteria

I have a MapView with user location, and a bunch of Map annotations. At first I want to show all the possible pins on the map. (succeeded in doing that) Then I want to zoom in the map to show only the annotations that are within 50 KMs away from the…
Lena Bru
  • 13,521
  • 11
  • 61
  • 126
-1
votes
1 answer

Only add pin when button is clicked

I have this code that I need altered slightly. The code I have below creates a pin on my current location (perfectly as I might add). The only problem is that I need the code only to be run when I click a button, not every time I move. Here is the…
Nicholas Gibson
  • 306
  • 1
  • 3
  • 11
-1
votes
1 answer

MKMapView switches between pin color annotations

I have a bunch of pins on my map, some red and some green. The initial coloring is ok. However, when I use the map view and tap on some green ones, some reds will change to green. That probably happens when they are outside of the current view area…
El Dude
  • 5,328
  • 11
  • 54
  • 101
-1
votes
1 answer

Can't find base class for Mapview

I am trying to inherit from MKPinAnnotation in this manner: MKPinAnnotationView -->MyPoint-->PhotoPoint but I get an error in Xcode saying PhotoPoint can't be defined without a base class. Here is my code in MyPoint.h: #import…
-1
votes
2 answers

How to implement %0.7f in annotation.coordinate?

I have two strings which hold values say for ex:35.5044752 97.3955550 Let me convert it : double f1=[la doubleValue]; double f2=[lo doubleValue]; (value of f1 and f2 is dynamic say for example f1= "35.5044752" f2="97.3955550" ) if i want to…
-1
votes
5 answers

MKPointAnnotation unable to coordinate

In my mapView application i am trying to make the annotation, Without adding annotation i am getting the mapView but when i try to add annotation, Only the annotation mark is visible the map becomes invisible. Before adding Annotation: Code: …
-1
votes
3 answers

Cannot access defined property of personnal class

The thing is that I have a main class : MyAnnotation, created to display annotations on my mapView. @interface lieuAnnotation : MyAnnotation @property(readonly, nonatomic) UIImage *uneImage; // I cannot access this property. @end I created a…
Lucien
  • 451
  • 4
  • 16
-1
votes
1 answer

How to display map callout on one of the annotation pin automatically?

I have a view which has couple of location locations listed in a table view. If user clicks on any cell the app needs to display the Mapview with the location clicked with callout. Till now i have been able to show all the locations on the map view…
Ashutosh
  • 5,614
  • 13
  • 52
  • 84
-1
votes
1 answer

Custom MKAnnotation

I have annotation with image on the left, title, desc, and button on right, and now I want to create annotation as below, how can I do this? I will appreciate any help http://postimage.org/image/4s61pnwcf/
Marks app
  • 13
  • 3
-1
votes
1 answer

Callouts for MKAnnotations randomly not appearing

I have a little issue with MKMapView and its annotations, and I can't find what's happening here. The issue is that sometimes, when I tap an annotation, its callout won't appear. If I tap it again, it still won't appear. If I tap another annotation…
ov1d1u
  • 958
  • 1
  • 17
  • 38
-2
votes
1 answer

viewForAnnotation not called in iPhone 4 but works in simulator

So I am having the strangest problem and I have gone to every where it seem. What I am having an issue with is that I create custom annotation views for my MKMapView.This MKMapView starts with no annotations and as you change the region then…
Tony
  • 4,609
  • 2
  • 22
  • 32
-2
votes
1 answer

How to get map annotation title in this method

i want to get annotation title & subtitle from this method. what the way go get that. -(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{ //NSString * title = [annotations title]; }
-2
votes
1 answer

Determining User Location - iOS

I am able to set annotations within some specified KM radius of the user current location (lets say for annotations are indicating pizza search points). But if the user drags the map left/right/top/bottom then is there any way to refresh the map and…
1 2 3
85
86