Note that there are some explanatory texts on larger screens.

plurals
  1. POIOS: Adding image to custom MKAnnotationview
    primarykey
    data
    text
    <p>I want to add a custom image to my annotations in the map. And i have made the following custom MapAnnotationView:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import &lt;Foundation/Foundation.h&gt; #import &lt;MapKit/MapKit.h&gt; #import &lt;CoreLocation/CoreLocation.h&gt; @class POI; @interface MapAnnotation : MKAnnotationView &lt;MKAnnotation &gt; @property (nonatomic) CGFloat lat; @property (nonatomic) CGFloat lon; @property (nonatomic) CGFloat altitude; @property (nonatomic, copy) NSString * title; @property (nonatomic, copy) NSString * subtitle; @property (nonatomic,retain) NSString *source; @property (nonatomic,retain) UIImage *image; @end @implementation MapAnnotation @synthesize coordinate; @synthesize lat=_lat,lon=_lon,altitude= _altitude; @synthesize subtitle= _subtitle, title= _title, source=_source, image =_img; - (CLLocationCoordinate2D)coordinate;{ CLLocationCoordinate2D position; if (_lat != 0.0 &amp;&amp; _lon != 0.0) { position.latitude = _lat; position.longitude = _lon; }else { position.latitude=0.0; position.longitude=0.0; } return position; } @end -(void) mapDataToMapAnnotations{ NSMutableArray *toRemove = [NSMutableArray arrayWithCapacity:10]; for (id annotation in _map.annotations) if (annotation != _map.userLocation) [toRemove addObject:annotation]; [_map removeAnnotations:toRemove]; [_data removeAllObjects]; [_data addObjectsFromArray:[UDdelegate naturArray]]; if(_data != nil){ MapAnnotation * tmpPlace; //for(NSDictionary * poi in _data){ for(POI* poi in _data){ tmpPlace = [[MapAnnotation alloc]init]; tmpPlace.title = [poi title]; tmpPlace.lat = [poi lat]; tmpPlace.lon = [poi lon]; tmpPlace.subtitle = [poi dist]; tmpPlace.image = [poi poiIcon]; [self.map addAnnotation:tmpPlace]; [_map setNeedsLayout]; } } } </code></pre> <p>The problem is that the pins is the standard redPin.... I am sure that the icons isn't null, have checked for that.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload