Размер маркеров MapBox (swift) изменяется при увеличении (как отключить? Изменить размер маркера) - PullRequest
0 голосов
/ 07 мая 2020

Вот мой код для рисования линии на карте и установки маркера. Моя проблема в том, что маркер становится больше при уменьшении масштаба. Можно ли установить размер маркера или отключить изменение размера при увеличении? (iOS SDK MapBox, Xcode 11, Swift 5)

func drawOnMap()
{
    let cord = checkForShortestDirection()
    if cord[0] != 123456789.987654321
    {
        let coordinates = greatCircle(xlat1: cord[0], xlong1: cord[1], xlat2: cord[2], xlong2: cord[3])
        polyline = MGLPolylineFeature(coordinates: coordinates, count: UInt(coordinates.count))
        //if let annotations = map.annotations { map.removeAnnotations(annotations) } map.addAnnotation(polyline)
        if let source = map.style?.source(withIdentifier: "line") as? MGLShapeSource
        {
            source.shape = polyline
        }
        else
        {
            let source = MGLShapeSource(identifier: "line", features: [polyline], options: nil)
            let lineStyle = MGLLineStyleLayer(identifier: "line-layer", source: source)
            let magenta = hexStringToUIColor(hex: "#c73fba")
            lineStyle.lineColor = NSExpression(forConstantValue: magenta)
            lineStyle.lineWidth = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'exponential', 1.5, %@)",
            [14: 2,
             18: 20])
            map.style?.addSource(source)
            map.style?.addLayer(lineStyle)

        }

        let point = MGLPointAnnotation()
        let pointCoordinates = CLLocationCoordinate2D(latitude: cord[0], longitude: cord[1])
        point.coordinate = pointCoordinates

        if let source = map.style?.source(withIdentifier: "marker-source") as? MGLShapeSource
        {
            source.shape = point
        }
        else
        {
            let source = MGLShapeSource(identifier: "marker-source", shape: point, options: nil)
            let shapeLayer = MGLSymbolStyleLayer(identifier: "marker-style", source: source)
            if let image = UIImage(named: "plane-icon") {
                map.style?.setImage(image, forName: "home-symbol")
            }
            shapeLayer.iconImageName = NSExpression(forConstantValue: "home-symbol")

            map.style?.addSource(source)
            map.style?.addLayer(shapeLayer)
        }
    }
    else
    {
        print("DrawOnMap ERROR: \(cord[0])")
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...