Добавить штрих к MGLMapView

Вот что мне нужно иметь:

и вот что у меня есть:

Используя код:

override func viewDidLoad() {
    super.viewDidLoad()

    let mapView = MGLMapView(frame: view.bounds)
    mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
    mapView.setCenter(CLLocationCoordinate2D(latitude: 50.08442, longitude: 19.95825), zoomLevel: 9, animated: false)
    mapView.setZoomLevel(16, animated: false)
    mapView.delegate = self
    view.addSubview(mapView)

    var coordinates = [
        CLLocationCoordinate2D(latitude: 50.08510, longitude: 19.95899),
        CLLocationCoordinate2D(latitude: 50.08463, longitude: 19.96017),
        CLLocationCoordinate2D(latitude: 50.08369, longitude: 19.95964),
        CLLocationCoordinate2D(latitude: 50.08360, longitude: 19.95955),
        CLLocationCoordinate2D(latitude: 50.08397, longitude: 19.95893),
        CLLocationCoordinate2D(latitude: 50.08442, longitude: 19.95840),
        CLLocationCoordinate2D(latitude: 50.08367, longitude: 19.95716),
        CLLocationCoordinate2D(latitude: 50.08380, longitude: 19.95678),
        CLLocationCoordinate2D(latitude: 50.08419, longitude: 19.95723),
        CLLocationCoordinate2D(latitude: 50.08461, longitude: 19.95652),
        CLLocationCoordinate2D(latitude: 50.08510, longitude: 19.95697)
    ]

    let shape = MGLPolygon(coordinates: &coordinates, count: UInt(coordinates.count))
    mapView.addAnnotation(shape)
}

func mapView(_ mapView: MGLMapView, alphaForShapeAnnotation annotation: MGLShape) -> CGFloat {
    return 0.3
}

func mapView(_ mapView: MGLMapView, fillColorForPolygonAnnotation annotation: MGLPolygon) -> UIColor {
    return UIColor(red: 255/255, green: 104/255, blue: 104/255, alpha: 1)

0 ответов

Другие вопросы по тегам