2016-11-29 61 views
19

在极少数情况下,我的地图上的覆盖图(小蓝点)会产生一个奇怪的眩光(右边的蓝色大区域)(如图所示)。有时放大或缩小可以修复它,但并非总是如此。找不到为什么会发生这种情况。它是如何呈现的?Swift MKMapView多边形覆盖毛刺

enter image description here

func drawLocations(_ loc: CLLocation) 
    { 
     let center = CLLocationCoordinate2D(latitude: loc.coordinate.latitude, longitude: loc.coordinate.longitude) 
     let lat: CLLocationDegrees = center.latitude 
     let long: CLLocationDegrees = center.longitude 
     var points = [CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long)] 
     let polygon = MKPolygon(coordinates: &points, count: points.count) 
     DispatchQueue.main.async(execute: { 
      self.mapView.add(polygon) 
     }) 
    } 
func mapView(_ mapView: MKMapView!, rendererFor overlay: MKOverlay!) -> MKOverlayRenderer! 
    { 
     if overlay is MKPolygon 
     { 
      let polygonView = MKPolygonRenderer(overlay: overlay) 
      polygonView.lineWidth = 4 
      polygonView.strokeColor = UIColor(red: 30/255.0, green: 12/255.0, blue: 242/255.0, alpha: 0.4) 
      return polygonView 
     } 
     return nil 
    } 
+1

在我的情况下,我越来越好了。你确定没有在两者之间执行的绘图代码? – Ramis

+1

这是我绘制代码的唯一方法。这似乎是随机的。大多数时间没问题,但是当我在屏幕上放置更多点时会发生更多打开@ramis – Steve

+1

这是否只发生在模拟器上? –

回答