简体   繁体   English

如何在iOS中使用MApkit在地图上的注释上创建圆圈叠加层?

[英]How to create a circle overlay over my annotation in Maps using MApkit in iOS?

I want to create a circle overlay over the annotation. 我想在注释上创建一个圆圈叠加。 I'm using swift 3.0. 我正在使用Swift 3.0。 Any help is appreciated !! 任何帮助表示赞赏!

Try a custom overlay. 尝试自定义叠加层。 Add this in viewDidLoad : viewDidLoad添加它:

MKCircle *circle = [MKCircle circleWithCenterCoordinate:userLocation.coordinate radius:1000];
[map addOverlay:circle];

userLocation can be obtained by storing the MKUserLocationAnnotation as a property. userLocation可以通过存储获得MKUserLocationAnnotation作为属性。 Then, to actually draw the circle, put this in the map view's delegate: 然后,要实际绘制圆形,请将其放入地图视图的委托中:

- (MKOverlayRenderer *)mapView:(MKMapView *)map viewForOverlay:(id <MKOverlay>)overlay
{
    MKCircleRenderer *circleView = [[MKCircleRenderer alloc] initWithOverlay:overlay];
    circleView.strokeColor = [UIColor redColor];
    circleView.fillColor = [[UIColor redColor] colorWithAlphaComponent:0.4];
    return circleView;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM