Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In <code>drawMapRect</code>, this line is probably the cause of the point rects not showing:</p> <pre><code>CGRect rect = CGRectMake(datpoint.x/zoomScale, datpoint.y/zoomScale, 1.0/zoomScale, 1.0/zoomScale); </code></pre> <p>You probably do not want to change the position of the point's rect based on the zoomScale.<br> The rect's <em>apparent</em> position based on the zoom will be done automatically by the map view. </p> <p>The current code is changing its <em>absolute</em> position and size on the map based on the zoom.<br> The resulting position is most likely not on the map.</p> <p>Instead, draw the point's rect without any scaling. </p> <p>However, to calculate the right width to use in CGPoints (from meters), you need to do some calculation:</p> <pre><code>for (NSValue *point in self.points) { MKMapPoint mapPoint; [point getValue:&amp;mapPoint]; CGPoint datpoint = [self pointForMapPoint:mapPoint]; CLLocationDistance rectWidthMeters = 100000.0; //above sets rect width to 100 km, adjust as needed CLLocationCoordinate2D mpc = MKCoordinateForMapPoint(mapPoint); double rectWidthMapPoints = MKMapPointsPerMeterAtLatitude(mpc.latitude); MKMapPoint mpRight = MKMapPointMake (mapPoint.x + (rectWidthMapPoints * rectWidthMeters), mapPoint.y); CGPoint datpointRight = [self pointForMapPoint:mpRight]; CGFloat rectWidth = datpointRight.x - datpoint.x; CGRect rect = CGRectMake(datpoint.x, datpoint.y, rectWidth, rectWidth); CGContextFillRect(context, rect); } </code></pre> <p>Make sure you are zoomed in enough at the right location to see the squares.</p> <p><br> You may be interested in looking at <a href="https://developer.apple.com/library/ios/samplecode/HazardMap/Introduction/Intro.html" rel="nofollow">Apple's sample app HazardMap</a> which demonstrates something similar showing color-coded earthquake hazard levels based on a grid of locations.</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.
 

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