1

Is it possible to display dynamic text instead of a standard pin drop in MapKit?

For instance, the Trulia app shows house prices instead of a drop pin on their app, I'm wondering if they just have 10,000 pin images and are calling them like 4000.png or 5000.png or if they are somehow using dynamic pins and setting the text when the annotation is called.

See image:

enter image description here

rodney
  • 61
  • 1
  • 9

1 Answers1

1

Yes this is totally possible. In viewForAnnotation just make your image, or use a cached one, according to the data you are trying to display at that point. Then set that as the annotation's image property.

Craig
  • 8,093
  • 8
  • 42
  • 74
  • 1
    here's a more complete answer you'd have found with a little more searching http://stackoverflow.com/questions/9814988/mkmapview-instead-of-annotation-pin-a-custom-view – Craig Aug 14 '13 at 10:01
  • I know I can display an image, what I'm hoping to do is display dynamic text in place of the pin image. – rodney Aug 14 '13 at 13:44
  • My point is to make an image dynamically in `viewForAnnotation` that contains the text you want to display. An image of text. You can't just float a UILabel on the map if that's what you're expecting. – Craig Aug 14 '13 at 19:33
  • In my question I asked if it was possible to display 'dynamic' text instead of a standard pin drop in MapKit, I'm sorry if it was confusing. – rodney Aug 15 '13 at 00:40
  • 1
    So render your dynamic text into a dynamic image. e.g. calculate your text, turn it into a string. Draw that string into an image, use that image. – Craig Aug 15 '13 at 01:21
  • Oh! I can render a dynamic image on the fly?! I missunderstood what you were saying, thanks for the info. – rodney Aug 15 '13 at 17:19