Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setSourceProperty clusterMaxZoom for GeoJSONSource #1641

Open
mfazekas opened this issue Oct 12, 2022 · 0 comments
Open

setSourceProperty clusterMaxZoom for GeoJSONSource #1641

mfazekas opened this issue Oct 12, 2022 · 0 comments
Labels
bug 🪲 Something is broken!

Comments

@mfazekas
Copy link
Contributor

mfazekas commented Oct 12, 2022

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
Labels
bug 🪲 Something is broken!
Projects
None yet
Development

No branches or pull requests

1 participant