ios - Pins not being shown using Parse.com -
i trying add together pins couple of locations created in 1 of classes, called "places".
the key these locations defined "places_coordinates".
i tried place pins follows:
view controller.h #import <uikit/uikit.h> #import <mapkit/mapkit.h> #import <corelocation/corelocation.h> #import <parse/parse.h> @interface viewcontroller : uiviewcontroller<cllocationmanagerdelegate, mkmapviewdelegate> @property (nonatomic, retain) cllocationmanager *locationmanager; @property(nonatomic, strong) mkpinannotationview *geopointannotation; @property(nonatomic, strong)mkpointannotation *annotation; @property(nonatomic, strong)cllocation *location; @property (nonatomic, strong) pfobject *detailitem; @property (weak, nonatomic) iboutlet mkmapview *applemap; @end viewcontroller.m - (void)viewdidload { [super viewdidload]; if (nil == self.locationmanager){ self.locationmanager = [[cllocationmanager alloc] init]; self.locationmanager.delegate = self; //configure accuracy depending on needs, default kcllocationaccuracybest self.locationmanager.desiredaccuracy = kcllocationaccuracykilometer; // set motion threshold new events. self.locationmanager.distancefilter = 500; // meters [self.locationmanager startupdatinglocation]; [self.locationmanager requestwheninuseauthorization]; [self.locationmanager requestalwaysauthorization]; } self.applemap.delegate = self; // map show current location self.applemap.showsuserlocation = yes; // maps' opening spot self.location = [self.locationmanager location]; cllocationcoordinate2d coordinateactual = [self.location coordinate]; // map's zoom mkcoordinatespan zoom = mkcoordinatespanmake(0.010, 0.010); // create part mkcoordinateregion part = mkcoordinateregionmake(coordinateactual, zoom); // method sets exibition method [self.applemap setregion:region animated:yes]; //map's type self.applemap.maptype = mkmaptypestandard; } #pragma mark - location manager callbacks -(void)locationmanager:(cllocationmanager *)manager didupdatelocations:(nsarray *)locations{ [pfgeopoint geopointforcurrentlocationinbackground:^(pfgeopoint *geopoint, nserror *error) { if (!error) { // create object pfobject *offerslocation = [pfobject objectwithclassname:@"places"]; //create point markers pfgeopoint *offerspoint = offerslocation[@"places_coordinate"]; // check current location nslog(@"%@", offerspoint); // create query places of involvement near current location pfquery *query = [pfquery querywithclassname:@"places"]; [query wherekey:@"places_coordinate" neargeopoint:geopoint withinkilometers:5.0]; nslog(@"query: %@",query); // limit query query.limit = 10; // store objects in array nsarray *offersarray = [query findobjects]; nslog(@"array: %@",offersarray); if (!error) { (query in offersarray) { self.annotation = [[mkpointannotation alloc] init]; cllocationcoordinate2d coord = {offerspoint.latitude, offerspoint.longitude}; self.annotation.coordinate = coord ; [self.applemap addannotation:self.annotation]; nslog(@"annotation: %@",self.annotation); } } } }]; } #pragma mark - mkmapviewdelegate -(mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id<mkannotation>)annotation{ static nsstring *mapviewannotationidentifier = @"places_coordinate"; mkpinannotationview *pinoffers = [[mkpinannotationview alloc] initwithannotation:self.annotation reuseidentifier:mapviewannotationidentifier]; pinoffers.pincolor = mkpinannotationcolorred; pinoffers.canshowcallout = yes; pinoffers.animatesdrop = yes; homecoming pinoffers; }
my log showing offers within offersarray, not finding way of putting markers in it.
i tried couple of other topics, did not it:
how add together multiple pin @ same lat/long
adding mapview annotations within parse query returns null randomly
best regards,
what happening loop not built correctly.
it should this:
... if (!error) { (pfobject *offerobject in offersarray) { pfgeopoint *offerpoint = [offerobject objectforkey:@"coordenadas"]; mkpointannotation *geopointannotation = [[mkpointannotation alloc] init]; geopointannotation.coordinate = cllocationcoordinate2dmake(offerpoint.latitude, offerpoint.longitude); [self.applemap addannotation:geopointannotation]; nslog(@"annotation: %@",geopointannotation); } } ...
ios annotations parse.com
No comments:
Post a Comment