ios - MKMapView customized pin image lose its accuracy when zoom in/out the map -
i have mapview in app, , i'm using own image mkannotationview, the pin image. here code setting it.
-(rmannotationview *)mapview:(mkmapview *)mapview viewforannotation:(rentpin *)annotation{ static nsstring *identifier = @"mylocation"; if ([annotation iskindofclass:[rentpin class]]) { rmannotationview *annotationview = (rmannotationview *)[self.mapview dequeuereusableannotationviewwithidentifier:identifier]; if(annotationview == nil){ annotationview = [[rmannotationview alloc] initwithannotation:annotation reuseidentifier:identifier]; annotationview.enabled = yes; annotationview.canshowcallout = no; annotationview.image = [uiimage imagenamed:@"home44.png"]; annotationview.centeroffset = cgpointmake(-10, -10); }else{ annotationview.annotation = annotation; } homecoming annotationview; } homecoming nil; }
it working fine , customized image showing properly, when pinch mapview zooming in/out map, noticed customized image loses accuracy on map. please have images following.
https://www.dropbox.com/s/irrgmohppf08fzr/image1.png image shows pin @ position, quite accurate.
https://www.dropbox.com/s/vvlr4ckk6molqd7/image2.png after zoomed out mapview, pin crossed street , showing address in lake....
(sorry links, since can't post images because of insufficient reputation.)
anyone help me regarding this? pin image 44x44 , tried setting centeroffset of pin, cannot dynamically solved problem in zoom levels.
it's wrong center offset. aware center offset depends on type of annotation view using. don't know rmannotationview
is. if it's subclass of mkannotationview
, centeroffset
should cgpointmake(0, -imageheight / 2)
.
ios cocoa-touch mkmapview
No comments:
Post a Comment