2017-05-30 6 views
0

MapKitに関する問題で苦労しています。MKOverlayRenderer拡大縮小によるぼかしとぼかし

サーバからの私のジオフェンスのデータに基づいてMKPolygonのリストを作成します。

+ (MKPolygon *)polygonFromPoints:(NSArray *)points interiorPolygons:(NSArray *)polygons{ 

    NSInteger numberOfCoordinates = [points count]; 
    CLLocationCoordinate2D *polygonPoints = malloc(numberOfCoordinates * sizeof(CLLocationCoordinate2D)); 

    NSInteger index = 0; 
    for (NSArray *pointArray in points) { 
      polygonPoints[index] = CLLocationCoordinate2DMake([pointArray[1] floatValue], [pointArray[0] floatValue]); 
      index++; 
    } 

    MKPolygon *polygon; 
    if (polygons) { 
     polygon = [MKPolygon polygonWithCoordinates:polygonPoints count:numberOfCoordinates interiorPolygons:polygons]; 
    } else { 
     polygon = [MKPolygon polygonWithCoordinates:polygonPoints count:numberOfCoordinates]; 
    } 

    free(polygonPoints); 
    return polygon; } 

と私はオーバーレイがをカットし、ぼかし効果のいくつかの種類を持っているマップの位置をズームインまたは変更MKOverlayRender

しかし
- (MKOverlayRenderer *) mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay{ 

    if([overlay isKindOfClass: [MKCircle class]]){ 
     MKCircleRenderer *circleRender = [[MKCircleRenderer alloc] initWithCircle:(MKCircle *)overlay]; 
     circleRender.fillColor = [ [Common colorWithHexString:BlueGeoFence] colorWithAlphaComponent:0.3]; 

     return circleRender; 
    }else if([overlay isKindOfClass: [MKPolygon class]]){ 

     MKPolygonRenderer *polygonRenderer = [[MKPolygonRenderer alloc] initWithPolygon:(MKPolygon *)overlay]; 
     polygonRenderer.fillColor = [ [Common colorWithHexString:BlueGeoFence] colorWithAlphaComponent:0.3]; 

     return polygonRenderer; 
    } 

    return nil; 
} 

、としてマップに追加します。

enter image description here

enter image description here

これを解決する方法任意のアイデア?

ありがとうございます。

答えて

0

私は同じ問題を抱えていました。問題の原因は、MKPolygonが、実際には内部ポリゴンではない内部ポリゴンで作成されていたことでした。データをチェックして、内部ポリゴンの座標が実際に大きなポリゴンの範囲内にあることを確認します。

関連する問題