Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, what's <code>foo</code> used in the first function? And I'm assuming <code>radiusView</code>'s parent is the annotation view, right?</p> <h3>The "Jittering"</h3> <p>Also, the center point of <code>radiusView</code> should coincide with that of the annotationView. This should solve your problem:</p> <pre><code>-(void) setRadiusFrame:(CGRect)rect{ rect.origin.x -= 0.5*(self.frame.size.width - rect.size.width); rect.origin.y -= 0.5*(self.frame.size.height - rect.size.height); [self.radiusView setFrame:rect] } </code></pre> <h3>Unnecessary method</h3> <p>You could set the frame directly on the <code>radiusView</code> and avoid the above calculation:</p> <pre><code> UIView * radiusView = [[[self mapView] viewForAnnotation: annotation] radiusView]; rect = [[self mapView] convertRegion:foo toRectToView: radiusView.superView]; [radiusView setFrame:rect]; </code></pre> <ol start="3"> <li>When drawing the ellipse, don't use the <code>rect</code> passed to <code>drawRect:</code>, it doesn't have to be the same as the frame. It's safer to directly use <code>self.frame</code></li> </ol> <h3>Unnecessary view</h3> <p>Now I gave the above points if you need to use the above hierarchy, but I don't see why don't you just draw your ellipses directly in the <code>LocationAnnotationView</code>? It's there for this purpose after all. This is how you do this:</p> <ol> <li><p>when scaling, change the annotationView's rect directly:</p> <pre><code>rect = [[self mapView] convertRegion:foo toRectToView: self.mapView]; [[[self mapView] viewForAnnotation: annotation] setFrame:rect]; </code></pre></li> <li><p>Move the implementation of <code>drawRect:</code> to <code>LocationAnnotationView</code>.</p></li> </ol> <p>This is easier to implement, and should address your problem as the center point of the annotation view moves with your pin and you shouldn't see this problem.</p> <h3>Fixes</h3> <p>There are two other issues in the code:</p> <ol> <li><p>Set longitudeDelta like this:</p> <pre><code>region.span.longitudeDelta = 0.002*cos(region.center.latitude*pi/180.0); </code></pre> <p>as the longitude delta converted to meters changes with the latitude. Alternatively, you could only set latitude delta, then modify the rect so it becomes rectangular (<code>width==height</code>).</p></li> <li><p>in <code>drawRect:</code>, don't use the passed <code>rect</code>; instead use <code>self.frame</code>. There's no guarantee that these are the same, and <code>rect</code> could have any value.</p></li> </ol> <p>Let me know if these work ;-)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload