ios - How to prevent rotation of all UIImage overlays with MapKit -


i placing overlays mapoverlayrenderer. first use uiimage in view on map , can rotate in view , convert points (define boundingmaprect, coordinate, etc.) , place (renderer/addoverlay) onto map correct inserted image (cgcontextdrawimage) , correct rotation. each time create new overlay [uiimage in view, rotate, convert points, addoverlay) works fine. but, on each successive overlay added map, code rotates of other overlays on map. seems though rotation code (below) being applied of overlays.

should making array includes boundingmaprect , coordinates each overlay - if so, should these in viewcontroller? should naming each overlay [overlay.title? - how set , call it?]

appreciate guidance - thanks.

mapoverlayview.h @interface mapoverlayview () @property (nonatomic, strong) uiimage *overlayimage; @end @implementation mapoverlayview - (instancetype)initwithoverlay:(id<mkoverlay>)overlay overlayimage: (uiimage *)overlayimage { self = [super initwithoverlay:overlay]; if (self) {     _overlayimage = overlayimage;      } return self;  } - (void)drawmaprect:(mkmaprect)maprect zoomscale: (mkzoomscale)zoomscale incontext:(cgcontextref)context {     cgimageref imagereference = self.overlayimage.cgimage;     mkmaprect themaprect = self.overlay.boundingmaprect;     cgrect therect = [self rectformaprect:themaprect];     ionquestsingleton *tmp = [ionquestsingleton sharedsingleton];     float new_angle = tmp.image_angle;     nslog(@"%s%f","new angle ",new_angle);      {     if (new_angle<90) {              cgcontextrotatectm(context,new_angle*m_pi/180);             cgcontextscalectm(context, 1.0, -1.0);             cgcontexttranslatectm(context, 0.0, -therect.size.height);             cgcontextdrawimage(context, therect, imagereference);             nslog(@"%s%f","new angle 90 ",new_angle);//tick          }         else if (new_angle >90 && new_angle <=180)         {             cgcontextrotatectm(context,new_angle*m_pi/180);             cgcontextscalectm(context, 1.0, -1.0);             cgcontexttranslatectm(context, 0.0, 0.0);             cgcontextdrawimage(context, therect, imagereference);             nslog(@"%s%f","new angle 180 ",new_angle);//tick          }         else if (new_angle >180 && new_angle <=270)         {             cgcontextrotatectm(context,new_angle*m_pi/180);             cgcontextscalectm(context, 1.0, -1.0);             cgcontexttranslatectm(context, -therect.size.width, 0.0);             cgcontextdrawimage(context, therect, imagereference);             nslog(@"%s%f","new angle 270 ",new_angle);//tick          }         else if (new_angle >270) {             cgcontextrotatectm(context,new_angle*m_pi/180);             cgcontextscalectm(context, 1.0, -1.0);             cgcontexttranslatectm(context, -therect.size.width,  -therect.size.height);             cgcontextdrawimage(context, therect, imagereference);//tick             nslog(@"%s%f","new angle 360 ",new_angle);     } } } @end    mapoverlay.h #import "mapoverlay.h" #import "ionquestsingleton.h"  @implementation mapoverlay #define debug 1  @synthesize boundingmaprect; @synthesize coordinate;  -(cllocationcoordinate2d)coordinate { //image center point ionquestsingleton *tmp = [ionquestsingleton sharedsingleton]; return cllocationcoordinate2dmake(tmp.image_ctr_lat,   tmp.image_ctr_long); }   - (instancetype)init { self = [super init]; if (self) {      ionquestsingleton *tmp = [ionquestsingleton sharedsingleton];      mkmappoint upperleft   =   mkmappointforcoordinate(cllocationcoordinate2dmake(tmp.image_tl_lat,   tmp.image_tl_long));      mkmappoint boundsleft =  ```mkmappointforcoordinate(cllocationcoordinate2dmake(tmp.image_tl_bounds_lat,    tmp.image_tl_bounds_long));  boundingmaprect = mkmaprectmake(upperleft.x, upperleft.y,   fabs(upperleft.x - boundsleft.x), fabs(upperleft.x - boundsleft.x)); }  return self; } @end  viewcontroller.h  -(void) loadoverlay { mapoverlay *overlay = [[mapoverlay alloc] init]; [self.mapview addoverlay:overlay level:mkoverlaylevelabovelabels]; }  - (mkoverlayrenderer *)mapview:(mkmapview *)mapview rendererforoverlay: (id<mkoverlay>)overlay {   nsstring *mapnamefrommvcpos = [nsstring   stringwithformat:@"%@%s",self.mapnamefrommvc,"pos"];//not working  {     if ([overlay iskindofclass:[mapoverlay class]]) {          uiimage *magicmountainimage = [uiimage  imagenamed:mapnamefrommvcpos];          mkoverlayrenderer *overlayview = [[mapoverlayview alloc]  initwithoverlay:overlay overlayimage:magicmountainimage];          return overlayview; } etc [evaluate other overlaytypes] 


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -