Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Crash when adding and removing the same StyleLayer at runtime #6460

Closed
rmnblm opened this issue Sep 26, 2016 · 2 comments
Closed

Crash when adding and removing the same StyleLayer at runtime #6460

rmnblm opened this issue Sep 26, 2016 · 2 comments

Comments

@rmnblm
Copy link

rmnblm commented Sep 26, 2016

Platform: iOS
Mapbox SDK version: 3.4.0-alpha.4

Steps to trigger behavior

  1. Add a style layer
// Note: StyleLayer is a class variable
styleLayer = MGLCircleStyleLayer(layerIdentifier: "test-layer", sourceIdentifier: "sv")!
styleLayer.circleColor = UIColor.green
mapView.style().add(styleLayer)
  1. Add a UISwitch which basically triggers the following
if (switch.isOn) {
    mapView.style().add(styleLayer)
} else {
    mapView.style().remove(styleLayer)
}
  1. Removing the layer works, re-adding the layer will crash the app with the following error message:
2016-09-26 16:19:19.548301 Mapbox-iOS-Examples[892:460381] Failed to set (latitude) user defined inspected property on (UIView): [<UIView 0x101d6e8a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key latitude.
2016-09-26 16:19:19.548388 Mapbox-iOS-Examples[892:460381] Failed to set (longitude) user defined inspected property on (UIView): [<UIView 0x101d6e8a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key longitude.
2016-09-26 16:19:19.548446 Mapbox-iOS-Examples[892:460381] Failed to set (zoomLevel) user defined inspected property on (UIView): [<UIView 0x101d6e8a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key zoomLevel.

Note: I also deleted the latitude, longitude and zoomLevel attributes from the MGLMapView control and also tried to programmatically add the mapView as proposed from @1ec5 in #1184, still doesn't work.

screen shot 2016-09-26 at 16 33 39

@1ec5
Copy link
Contributor

1ec5 commented Sep 26, 2016

This is due to a combination of #6254 and #6096. For now, you'll need to get a fresh reference to the layer after adding it, using layerWithIdentifier(_:).

@rmnblm
Copy link
Author

rmnblm commented Sep 26, 2016

Thank you, I wasn't sure if I'm doing something wrong or it isn't supported yet. I implemented an example in my Mapbox-iOS-Examples repo here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants