Skip to content

Commit

Permalink
Do nothing and correcly return if layer and source to remove are not …
Browse files Browse the repository at this point in the history
…there (#961)
  • Loading branch information
AAverin committed Mar 24, 2022
1 parent c646973 commit 21a81ee
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ios/Classes/MapboxMapController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,10 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
case "style#removeSource":
guard let arguments = methodCall.arguments as? [String: Any] else { return }
guard let sourceId = arguments["sourceId"] as? String else { return }
guard let source = mapView.style?.source(withIdentifier: sourceId) else { return }
guard let source = mapView.style?.source(withIdentifier: sourceId) else {
result(nil)
return
}
mapView.style?.removeSource(source)
result(nil)
case "style#addLayer":
Expand Down Expand Up @@ -709,7 +712,10 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
case "style#removeLayer":
guard let arguments = methodCall.arguments as? [String: Any] else { return }
guard let layerId = arguments["layerId"] as? String else { return }
guard let layer = mapView.style?.layer(withIdentifier: layerId) else { return }
guard let layer = mapView.style?.layer(withIdentifier: layerId) else {
result(nil)
return
}
interactiveFeatureLayerIds.remove(layerId)
mapView.style?.removeLayer(layer)
result(nil)
Expand Down

0 comments on commit 21a81ee

Please sign in to comment.