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

Add a property for getting/setting the map's debug option #648

Merged
merged 7 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Mapbox welcomes participation and contributions from everyone.
* Added a public, failable, component-wise initializer to `StyleColor` ([#650](https://github.com/mapbox/mapbox-maps-ios/pull/650))
* Updated `StyleColor`'s `Decodable` support to be able to handle rgba color strings as well as rgba expressions ([#650](https://github.com/mapbox/mapbox-maps-ios/pull/650))
* Made generated enums conform to `CaseIterable` ([#650](https://github.com/mapbox/mapbox-maps-ios/pull/650))
* Allow users to set the map's `MapDebugOptions`. ([#648](https://github.com/mapbox/mapbox-maps-ios/pull/648))

### Bug fixes 🐞

Expand Down Expand Up @@ -86,7 +87,7 @@ Mapbox welcomes participation and contributions from everyone.

## 10.0.0-rc.5 - July 28, 2021

* Fixed an issue where `MapView` positioning wasn't correct when used in containers such as UIStackView. ([#533](https://github.com/mapbox/mapbox-maps-ios/pull/533))
* Fixed an issue where `MapView` positioning wasn't correct when used in containers such as UIStackView. ([#533](https://github.com/mapbox/mapbox-maps-ios/pull/533))

### Features ✨ and improvements 🏁
* Added new options to `MapSnapshotOptions`
Expand Down
20 changes: 19 additions & 1 deletion Sources/MapboxMaps/Foundation/MapboxMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,24 @@ public final class MapboxMap {

return rect
}

// MARK: Debug options
/// The array of `MapDebugOptions`. Setting this property to an empty array
/// disables previously enabled `MapDebugOptions`.
/// The default value is an empty array.
public var debugOptions: [MapDebugOptions] {
get {
return __map.getDebug().compactMap { MapDebugOptions(rawValue: $0.intValue) }
}
set {
// Remove the previously visible options, then update the debug options to the new array.
let oldOptions = debugOptions.map { NSNumber(value: $0.rawValue) }
__map.setDebugForDebugOptions(oldOptions, value: false)

let options = newValue.map { NSNumber(value: $0.rawValue) }
__map.setDebugForDebugOptions(options, value: true)
}
}
}

extension MapboxMap: MapTransformDelegate {
Expand Down Expand Up @@ -530,7 +548,7 @@ extension MapboxMap {
}

/// Get the state map of a feature within a style source.
///
///
/// - Parameters:
/// - sourceId: Style source identifier.
/// - sourceLayerId: Style source layer identifier (for multi-layer sources such as vector sources).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,24 @@ class MapboxMapsFoundationTests: XCTestCase {
// amount of byte difference that can't be accounted for.
// XCTAssertEqual(original.pngData(), roundtripped.pngData())
}

// MARK: Debug options
func testDebugOptions() {
let initialOptions = mapView.mapboxMap.debugOptions
XCTAssertEqual(initialOptions, [], "The initial debug options should be an empty array.")

let setOptions1: [MapDebugOptions] = [.tileBorders, .timestamps]
mapView.mapboxMap.debugOptions = setOptions1
let getOptions1 = mapView.mapboxMap.debugOptions
XCTAssertEqual(setOptions1, getOptions1, "Tile borders and timestamp should be enabled.")

let setOptions2: [MapDebugOptions] = [.tileBorders]
mapView.mapboxMap.debugOptions = setOptions2
let getOptions2 = mapView.mapboxMap.debugOptions
XCTAssertEqual(setOptions2, getOptions2, "Tile borders should be enabled.")

mapView.mapboxMap.debugOptions = []
let getOptions3 = mapView.mapboxMap.debugOptions
XCTAssert(getOptions3.isEmpty, "The array of debug options should be empty.")
}
}