mkoverlay

setNeedsDisplayInMapRect doesn't trigger new drawMapRect: call

北战南征 提交于 2019-12-03 18:00:29
问题 I'm using a custom MKOverlay/MKOverlayView to completely cover the Google basemap with my own tiles, which are loaded asynchronously. I follow the pattern of requesting unloaded tiles when I receive a canDrawMapRect:zoomScale: call to my overlay view (and returning FALSE in that case), then calling setNeedsDisplayInMapRect:zoomScale: once the tile is available. This all generally works, and appears to work perfectly in the simulator. However, on the device I sometimes get a 'hole' in the

Change coordinate of MKOverlay for an MKOverlayView

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 13:42:52
I have an overlay on the map, and I would like to change its coordinates. To do this seamlessly I'm going to call the setNeedsDisplayInMapRect: method after the change has been made to the view. I've tested this out by just changing the fillColor and it works fine: overlayView.fillColor = [[UIColor greenColor] colorWithAlphaComponent:0.3]; [overlayView setNeedsDisplayInMapRect:mapView.visibleMapRect]; However I've seemingly hit a brick wall trying to also change the center coordinates of my overlay view (which is an MKCircleView with an MKCircle ). There is a method in MKAnnotation , which

MKPolyline strange rendering related with zooming in MapKit

99封情书 提交于 2019-12-03 13:17:22
问题 I have very simple View Controller to demonstrate this strange rendering behavior of MKPolyline. Nothing special just normal api calls. import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet weak var map: MKMapView! override func viewDidLoad() { super.viewDidLoad() map.delegate = self } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) let p1 = CLLocationCoordinate2D(latitude: 51, longitude: 13) var coords = [ p1,

MKPolyline strange rendering related with zooming in MapKit

送分小仙女□ 提交于 2019-12-03 03:32:30
I have very simple View Controller to demonstrate this strange rendering behavior of MKPolyline. Nothing special just normal api calls. import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet weak var map: MKMapView! override func viewDidLoad() { super.viewDidLoad() map.delegate = self } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) let p1 = CLLocationCoordinate2D(latitude: 51, longitude: 13) var coords = [ p1, CLLocationCoordinate2D(latitude: 51.1, longitude: 13), CLLocationCoordinate2D(latitude: 51.2, longitude: 13),

Custom MKOverlayRenderer drawMapRect function not drawing polygons

穿精又带淫゛_ 提交于 2019-12-01 23:17:18
问题 I have built a custom MKOverlayRenderer in order to build polygons, apply a blend mode, then add them to the map view. In my drawMapRect function, I use an array of CGPoints to build the polygon, and create a path. However, during runtime nothing shows on my map view. My best guess would be the order of which I create the polygon in my drawMapRect function. Any help or guidance would be greatly appreciated, thanks! override func drawMapRect(mapRect: MKMapRect, zoomScale: MKZoomScale,

MKMapView - Limit map scroll to a square overlay

a 夏天 提交于 2019-12-01 23:15:19
问题 I have a MKMapView with a square overlay described as: CLLocationCoordinate2D coordsBg[5]={ CLLocationCoordinate2DMake(31.750865,35.180882), CLLocationCoordinate2DMake(31.740331,35.180882), CLLocationCoordinate2DMake(31.740331,35.165452), CLLocationCoordinate2DMake(31.750865,35.165452), CLLocationCoordinate2DMake(31.750865,35.180882) }; MKPolygon *bg=[MKPolygon polygonWithCoordinates:coordsBg count:5]; [map addOverlay:bg]; I wish to limit the user from scrolling outside of the overlay. Can I

Hiding mapview when mapoverlay is visible ios7

白昼怎懂夜的黑 提交于 2019-12-01 11:59:27
How do I hide the mapview when I have an overlay on top of the mapview in iOS7? This snippet of code used to work in iOS6 but when i upgrade my app to iOS7 it cease to work. NSArray *views = [[[self.mapView subviews] objectAtIndex:0] subviews]; [[views objectAtIndex:0] setHidden:YES]; Any suggestions or feedback? huggie With what incanus said with MKTileOverlay , it is like this in the view controller: - (void)viewDidLoad { [super viewDidLoad]; NSString *tileTemplate = @"http://tile.stamen.com/watercolor/{z}/{x}/{y}.jpg"; MKTileOverlay *overlay = [[MKTileOverlay alloc] initWithURLTemplate

How to fill outside overlay circle in iOS 7 on map

你。 提交于 2019-11-30 15:53:29
I need the same filled space around circle on the map as in Reminders app in iOS7. I think need to use the method applyFillPropertiesToContext:atZoomScale or fillPath:inContext: . I solved my problem: - (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context { // Fill full map rect with some color. CGRect rect = [self rectForMapRect:mapRect]; CGContextSaveGState(context); CGContextAddRect(context, rect); CGContextSetFillColorWithColor(context, [UIColor colorWithWhite:0.0 alpha:0.4f].CGColor); CGContextFillRect(context, rect); CGContextRestoreGState

Animating an MKOverlayView

房东的猫 提交于 2019-11-30 12:50:43
问题 I have an MKOverlayView that displays animated radar data as a series of images. The issue I have is that the radar images are chopped into tiles by MapKit. To swap images I have a timer that calls an update function which sets the current image in my overlay and then calls the following [myRadarOverlayView setNeedsDisplayInMapRect:self.mapView.visibleMapRect]; The overlay updates, but does so one tile at a time so I get a choppy animation. Any ideas about how make all the tiles animate (i.e.

MKMapView with multiple overlays memory-issue

元气小坏坏 提交于 2019-11-30 05:46:29
There seems to be an "issue" with overlays and the MapKit . Unlike annotations, overlays aren't reused and therefore when adding multiple overlays would cause memory-problems on a real device. I've had this problem multiple times. So my question is, how can I reuse the MKOverlay and so improve the performance of overlays on MapKit ? The Answer to this is not "reusing" but to draw them all in to one MKOverlayView and then draw that on the map. Multiple MKPolygons , MKOverlays etc. cause heavy memory-usage when drawing on the map. This is due the NOT reusing of overlays by MapKit . As