mapbox / mapbox/mapbox-maps-ios

Inconsistent line width on line layer

Open
#2,201 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :beetle:
Dominant language
Swift
Stars
601
Forks
196
PR merge metrics
No merged PRs in 30d

Description

## Environment

- Xcode version: 14.5
- iOS version: 17.4
- Devices affected: 100..1000
- Maps SDK Version: 11.4

## Observed behavior and steps to reproduce

Line width is not constant while zoom level is changing

https://github.com/mapbox/mapbox-maps-ios/assets/514571/7aee36ae-1b47-4d20-bb14-87b99a9d75e5

https://github.com/mapbox/mapbox-maps-ios/assets/514571/256b62d6-bf40-43aa-b3e5-5775f16d5cde

## Expected behavior

Line width to be constant while zooming

code

```swift
final class LineWidthBug: UIViewController, ExampleProtocol {
private var mapView: MapView!
private var cancelables = Set()

override func viewDidLoad() {
super.viewDidLoad()

// Set the center coordinate and zoom level.
let centerCoordinate = CLLocationCoordinate2D(latitude: 0, longitude: 0)
let options = MapInitOptions(cameraOptions: CameraOptions(center: centerCoordinate, zoom: 11))

mapView = MapView(frame: view.bounds, mapInitOptions: options)
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(mapView)


var lines:[LineString] = [
LineString([
CLLocationCoordinate2DMake(35.6764, 139.6500),
CLLocationCoordinate2DMake(51.5072, 0.1276)
])
]


// Allow the view controller to receive information about map events.
mapView.mapboxMap.onMapLoaded.observeNext { [weak self] _ in
guard let self = self else { return }

let referenceCamera = CameraOptions()

let camera = (try? mapView.mapboxMap.camera(
for: [lines.first!.coordinates[0], lines.last!.coordinates[1]],
camera: CameraOptions(),
coordinatesPadding: .init(allEdges: 0),
maxZoom: nil,
offset: nil))!

mapView.camera.fly(to: camera, duration: 0.5)

var line = GeoJSONSource(id: "line")
line.data = .featureCollection(FeatureCollection(features: lines.compactMap({ Feature(geometry: $0) })))

var lineLayer = LineLayer(id: "line-layer", source: line.id)
lineLayer.lineColor = .constant(StyleColor(.red))
lineLayer.lineWidth = .constant(4)
lineLayer.lineCap = .constant(.round)
lineLayer.lineJoin = .constant(.round)

try! mapView.mapboxMap.addSource(line)
try! mapView.mapboxMap.addLayer(lineLayer)

self.finish()
}.store(in: &cancelables)
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// The below line is used for internal testing purposes only.
finish()
}
}
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the line-layer example from the issue on iOS 17.4 with Maps SDK 11.4, using the supplied Swift code and comparing line width while zooming. Done means the rendered line maintains a constant width across the reported zoom range.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
computer-graphics, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.