objective c - MKPolylines-routeLines not showing in my MKMapView, but everything is correct? -
objective c - MKPolylines-routeLines not showing in my MKMapView, but everything is correct? -
i new may i'm missing simple or whatever else.
basically want draw straight line point point, in case have of points in each line should drawn in array of coordinates. , utilize overlay method draw line. , of in mkmapview defined , configured (correctly).
so here code utilize fill array of coordinates , create overlay/polyline:
cllocationcoordinate2d coordinatearray[arrayoflatitudes.count]; (int = 0; < arrayoflatitudes.count; i++) { double templatitude = [[arrayoflatitudes objectatindex:(i)] doublevalue]; double templongitude = [[arrayoflongitudes objectatindex:(i)] doublevalue]; coordinatearray[i] = cllocationcoordinate2dmake(templatitude, templongitude); } self.routeline = [mkpolyline polylinewithcoordinates:coordinatearray count:arrayoflatitudes.count]; [self.mapview setvisiblemaprect:[self.routeline boundingmaprect]]; //if want route visible [self.mapview addoverlay:self.routeline];
and viewforoverlay method asume configures routeline:
(mkoverlayview *)mapview:(mkmapview *)mapview viewforoverlay:(id <mkoverlay>)overlay { if ([overlay iskindofclass:[mkpolyline class]]) { mkpolylineview *mapoverlayview = [[mkpolylineview alloc] initwithpolyline:overlay]; //add autorelease if not using arc mapoverlayview.strokecolor = [uicolor redcolor]; mapoverlayview.linewidth = 3; homecoming mapoverlayview; } homecoming nil;
}
i have these declarations in .h well:
@property (nonatomic, retain) mkpolyline *routeline; @property (nonatomic, retain) mkpolylineview *routelineview;
i don't know why can't see routeline drawn in mapview, because have used exact logic(order of things) in class , lines appear no problem.
what missing here? please help me
thanks in advance
i forgot mention,the first block of code within method called "waitforme" (void). im calling waitforme viewdidload method.
objective-c xcode polyline mkoverlay mkpolyline
Comments
Post a Comment