Skip to content

setSourceProperty clusterMaxZoom for GeoJSONSource #1641

Open

Description

@mfazekas

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

      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

      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:

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
                                               ))
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto-triagedAutomatically triaged by AIbug 🪲Something is broken!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions