iphone - Obtaining MKAnnotation's coordinate while dragging -


i'm creating path (mkpolyline) based on position of annotations added user. want allow users change path dragging pins. can that, mkpolyline doesn't update until pin dropped.

i implemented - (void)mapview:(mkmapview *)mapview annotationview:(mkannotationview *)annotationview didchangedragstate:(mkannotationviewdragstate)newstate fromoldstate:(mkannotationviewdragstate)oldstate mkannotationviewdragstatedragging alerts me user dragging pin , not notifing new position.

how can obtain current position of annotation being dragg, every time changes? want notified change in position while dragging able update mkpolyline follow pin moves, better reflect how path changing.

any ideas? thanks!

create subclass of mkannotationview , use subclass annotation dragging. within subclass:

- (void)touchesmoved:(nsset *)touches withevent:(uievent *)event {     cllocationcoordinate2d location = [_mapview convertpoint:self.center tocoordinatefromview:self.superview]; } 

unfortunately, mkannotation object associated mkannotationview not update coordinate until mkannotationview dropped. have use position of mkannotationview itself, , convert valid coordinate.

this requires reference mkmapview annotation has been added (_mapview here), pass view when created.

if have set centeroffset property of annotation view, need account that:

cllocationcoordinate2d location = [_mapview convertpoint:cgpointmake(self.center.x - self.centeroffset.x, self.center.y - self.centeroffset.y) tocoordinatefromview:self.superview]; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -