mapbox / mapbox/mapbox-maps-ios
setSourceProperty clusterMaxZoom for GeoJSONSource
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Xcode version: 14.0.1
- iOS version: 16.0
- Devices affected: Simulator/iPhone 14 Pro
- Maps SDK Version: 10.8.1, 10.9.0-beta.2
## Observed behavior and steps to reproduce
I cannot change GeoJSONSource's clusterMaxZoom property on the fly
```swift
style.setSourceProperty(for: "people", property: "clusterMaxZoom", value: 12.0)
```
Getting the following error:
```
MapboxMaps.StyleError(rawValue: "Cannot set property clusterMaxZoom for the source people")
```
## Expected behavior
Update clusterMaxZoom on the fly.
## Notes / preliminary analysis
Tried setting the value with NSNumber or just
```swift
style.setSourceProperty(for: "people", property: "clusterMaxZoom", value: style.getStyleSourceProperty(forSourceId: "people", property: "clusterMaxZoom").value)
```
got same error
## Additional links and references
Complete controller to reproduce:
```swift
class ViewController: UIViewController {
internal var mapView: MapView!
func buildView(_ color: UIColor = UIColor.red) -> UIView {
let view = UIView(frame: CGRect(x:0,y:0,width:40,height:40))
view.backgroundColor = color
return view;
}
override func viewDidLoad() {
super.viewDidLoad()
let myResourceOptions = ResourceOptions(accessToken:accessTokenSch)
let myMapInitOptions = MapInitOptions(resourceOptions: myResourceOptions, styleURI: StyleURI.streets)
mapView = MapView(frame: view.bounds, mapInitOptions: myMapInitOptions)
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.view.addSubview(mapView)
mapView.mapboxMap.onNext(.styleLoaded) { _ in
var source = GeoJSONSource()
let center = LocationCoordinate2D(latitude: 59.879647222152855, longitude: 30.319378097536216)
source.data = .geometry(Geometry.point(Point.init(center)))
source.clusterRadius = 20.0
let mapboxMap = self.mapView.mapboxMap!
try! mapboxMap.style.addSource(source, id: "people")
try! mapboxMap.style.setSourceProperty(for: "people", property: "clusterMaxZoom", value: 12.0)
var layer = CircleLayer(id: "accuracy")
layer.source = "people"
let radius = 20.0
layer.circleRadius = .constant(radius)
layer.circleRadiusTransition = .init(duration: 2.0, delay: 0.0)
layer.circleOpacity = .constant(0.5)
try! mapboxMap.style.addLayer(layer)
self.mapView.camera.fly(to: CameraOptions(center:
CLLocationCoordinate2D(latitude: 59.879647222152855, longitude: 30.319378097536216),
zoom: 10.0
))
}
}
}
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided ViewController reproduction and the call to Style.setSourceProperty(for:property:value:) on the GeoJSONSource. Run it with the stated Xcode, iOS, and Maps SDK versions, then trace how the clusterMaxZoom property is handled. Done means the property can be updated on the fly without the reported StyleError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100