Skip to content

Commit

Permalink
Cherry pick main changes to release/10.7 (#1463)
Browse files Browse the repository at this point in the history
* Add style toggle to location example (#1413)

* [XCParty] Add tag name if HEAD has any (#1424)

* [XCParty] Export crash reports for XCResult (#1434)

* Expose a way to initialise TilesetDescriptorOptionsForTilesets (#1431)

* Add cast shadow option to 3d puck config (#1435)

* Mark camera functions as unsupported for globe projection, invocation results in a no-op (#1440)

* Rotation gesture threshold and simultaneousRotateAndPinchToZoomEnabled option (#1429)

* Add option to support measurements from the only last run (#1445)

* Update examples (#1443)

* Fix flaky test (#1450)

* Fix view annotation losing its feature association after update (#1446)

* Enable `modelCastsShadow` option for custom location puck config (#1447)

* enabled model casts shadows option for custom location puck configuration

* Provide default value for list of last-run metrics (#1453)

* Update CoreMaps to `10.7.0-rc.1` (#1456)

* Update CoreMaps to 10.7.0-rc.1

* Update changelog

* Update changelog header (#1459)

* Update 10.7.0 versions (#1460)

Co-authored-by: ZiZi <44972592+ZiZasaurus@users.noreply.github.com>
Co-authored-by: Roman Laitarenko <roman.laitarenko@mapbox.com>
Co-authored-by: Tobrun <tobrun.van.nuland@gmail.com>
  • Loading branch information
4 people committed Jul 14, 2022
1 parent ae1bf02 commit da8254b
Show file tree
Hide file tree
Showing 64 changed files with 1,172 additions and 767 deletions.
8 changes: 4 additions & 4 deletions Apps/Apps.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
"repositoryURL": "https://github.com/mapbox/mapbox-common-ios.git",
"state": {
"branch": null,
"revision": "6ef396057d185404359537926f1b0fcd083dac95",
"version": "22.1.0-beta.1"
"revision": "25794d3d3a0dab1763b7973ca217feb5e073806c",
"version": "22.1.0-rc.1"
}
},
{
"package": "MapboxCoreMaps",
"repositoryURL": "https://github.com/mapbox/mapbox-core-maps-ios.git",
"state": {
"branch": null,
"revision": "678b333c26b81b38ccd7b3998eb19d3fca13e7b3",
"version": "10.7.0-beta.1"
"revision": "6640d6d46a6ceee6b50c451f38975d66ff5ba291",
"version": "10.7.0-rc.1"
}
},
{
Expand Down
64 changes: 56 additions & 8 deletions Apps/Examples/Examples/All Examples/Custom3DPuckExample.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UIKit
import MapboxMaps
@_spi(Experimental) import MapboxMaps

@objc(Custom3DPuckExample)
final class Custom3DPuckExample: UIViewController, ExampleProtocol, LocationConsumer {
Expand All @@ -18,14 +18,30 @@ final class Custom3DPuckExample: UIViewController, ExampleProtocol, LocationCons
}
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// The below line is used for internal testing purposes only.
finish()
}

private func setupExample() {
addBuildingExtrusions()

// set light configuration for shadow visibility
var light = Light()
light.anchor = .map
light.color = StyleColor(.yellow)
light.position = [10.0, 40.0, 50.0]
light.castShadows = .constant(true)
light.shadowIntensity = .constant(0.7)
try! mapView.mapboxMap.style.setLight(light)

let cameraOptions = CameraOptions(center: CLLocationCoordinate2D(latitude: 40.7135, longitude: -74.0066),
zoom: 15.5,
bearing: -17.6,
pitch: 45)
mapView.mapboxMap.setCamera(to: cameraOptions)

// The below lines are used for internal testing purposes only.
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
self.finish()
}

// add the 3D model to the map to represent the user's location
// Fetch the `gltf` asset
let uri = Bundle.main.url(forResource: "sportcar",
withExtension: "glb")
Expand Down Expand Up @@ -63,13 +79,45 @@ final class Custom3DPuckExample: UIViewController, ExampleProtocol, LocationCons
}
}

let configuration = Puck3DConfiguration(model: myModel, modelScale: .expression(scalingExpression))
let configuration = Puck3DConfiguration(model: myModel, modelScale: .expression(scalingExpression), modelRotation: .constant([0.0, 0.0, 180.0]), modelCastShadows: .constant(false))
mapView.location.options.puckType = .puck3D(configuration)
mapView.location.options.puckBearingSource = .course

mapView.location.addLocationConsumer(newConsumer: self)
}

// See https://docs.mapbox.com/mapbox-gl-js/example/3d-buildings/ for equivalent gl-js example
private func addBuildingExtrusions() {
var layer = FillExtrusionLayer(id: "3d-buildings")

layer.source = "composite"
layer.minZoom = 15
layer.sourceLayer = "building"
layer.fillExtrusionColor = .constant(StyleColor(.lightGray))
layer.fillExtrusionOpacity = .constant(0.6)

layer.filter = Exp(.eq) {
Exp(.get) {
"extrude"
}
"true"
}

layer.fillExtrusionHeight = .expression(
Exp(.get) { "height" }
)

layer.fillExtrusionBase = .expression(
Exp(.get) { "min_height"}
)

layer.fillExtrusionAmbientOcclusionIntensity = .constant(0.3)

layer.fillExtrusionAmbientOcclusionRadius = .constant(3.0)

try! mapView.mapboxMap.style.addLayer(layer)
}

internal func locationUpdate(newLocation: Location) {
mapView.camera.ease(
to: CameraOptions(
Expand Down
20 changes: 10 additions & 10 deletions Apps/Examples/Examples/All Examples/DebugMapExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,27 @@ private struct MapDebugOptionSetting {
}

final class DebugMapExample: UIViewController, ExampleProtocol, DebugOptionSettingsDelegate {

private var mapView: MapView!

override func viewDidLoad() {
super.viewDidLoad()

mapView = MapView(frame: view.bounds)
view.addSubview(mapView)

view.backgroundColor = .skyBlue
mapView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
mapView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
mapView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor),
mapView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
mapView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor),
mapView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
mapView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
mapView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
])

let debugOptionsBarItem = UIBarButtonItem(
barButtonSystemItem: .edit,
target: self,
action: #selector(openDebugOptionsMenu(_:)))
navigationItem.rightBarButtonItems?.insert(debugOptionsBarItem, at: 0)
navigationItem.rightBarButtonItem = debugOptionsBarItem
}

override func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -87,6 +86,7 @@ private final class SettingsViewController: UIViewController, UITableViewDataSou
override func viewDidLoad() {
super.viewDidLoad()

title = "Debug options"
listView = UITableView()
listView.dataSource = self
listView.register(DebugOptionCell.self, forCellReuseIdentifier: String(describing: DebugOptionCell.self))
Expand All @@ -95,10 +95,10 @@ private final class SettingsViewController: UIViewController, UITableViewDataSou

listView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
listView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
listView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor),
listView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
listView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor),
listView.topAnchor.constraint(equalTo: view.topAnchor),
listView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
listView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
listView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
])

navigationItem.largeTitleDisplayMode = .never
Expand Down
80 changes: 49 additions & 31 deletions Apps/Examples/Examples/All Examples/SwitchStylesExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,82 @@ import MapboxMaps
public class SwitchStylesExample: UIViewController, ExampleProtocol {

internal var mapView: MapView!
internal var styleToggle: UISegmentedControl!
internal var style: Style = .satelliteStreets {
didSet {
mapView.mapboxMap.style.uri = style.uri
}
}

enum Style: Int, CaseIterable {

var name: String {
switch self {
case .light:
return "light".capitalized
case .satelliteStreets:
return "s. streets".capitalized
case .customUri:
return "custom".capitalized
}
}

var uri: StyleURI {
switch self {
case .light:
return .light
case .satelliteStreets:
return .satelliteStreets
case .customUri:
let localStyleURL = Bundle.main.url(forResource: "blueprint_style", withExtension: "json")!
return .init(url: localStyleURL)!
}
}

case light
case satelliteStreets
case customUri
}

override public func viewDidLoad() {
super.viewDidLoad()

// Initialize a map centered near El Ejido, Spain and with a zoom level of 13.
let cameraOptions = CameraOptions(center: CLLocationCoordinate2D(latitude: 36.77271, longitude: -2.81361), zoom: 13)
let mapInitOptions = MapInitOptions(cameraOptions: cameraOptions, styleURI: .satelliteStreets)
let mapInitOptions = MapInitOptions(cameraOptions: cameraOptions, styleURI: style.uri)

mapView = MapView(frame: view.bounds, mapInitOptions: mapInitOptions)
mapView.mapboxMap.style.uri = .satelliteStreets
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

view.addSubview(mapView)

// Add a `UISegmentedControl` to toggle between Mapbox Streets, Mapbox Satellite Streets, and a custom style.
addStyleToggle()
installConstraints()
}

@objc func switchStyle(sender: UISegmentedControl) {
switch sender.selectedSegmentIndex {
case 0:
// Set the map's style to the default Mapbox Streets style.
// The map's `StyleURI` can be set to default Mapbox styles: `.light`, `.dark`, `.satellite`, `.satelliteStreets`, and `.outdoors`.
mapView.mapboxMap.style.uri = .streets
case 1:
// Set the map's style to Mapbox Satellite Streets.
mapView.mapboxMap.style.uri = .satelliteStreets
case 2:
// Blueprint, a custom style designed by Amy Lee Walton. https://www.mapbox.com/gallery/#blueprint
// Load the local style JSON. It conforms to the Mapbox Style Specification <https://docs.mapbox.com/mapbox-gl-js/style-spec/>
let localStyleURL = Bundle.main.url(forResource: "blueprint_style", withExtension: "json")!

// Set the map's style URI to a custom style URL.
mapView.mapboxMap.style.uri = StyleURI(url: localStyleURL)

// A Mapbox Studio style can also be loaded as a `StyleURI`.
// let studioStyleURL = URL(string: "mapbox://styles/examples/ckox18pjy140u17pdvmpgut4i")!
default:
mapView.mapboxMap.style.uri = .satelliteStreets
}
style = Style(rawValue: sender.selectedSegmentIndex) ?? . satelliteStreets
}

func addStyleToggle() {
// Create a UISegmentedControl to toggle between map styles
let styleToggle = UISegmentedControl(items: ["Streets", "Satellite Streets", "Local Style JSON"])
styleToggle.translatesAutoresizingMaskIntoConstraints = false
styleToggle = UISegmentedControl(items: Style.allCases.map(\.name))
styleToggle.tintColor = UIColor(red: 0.976, green: 0.843, blue: 0.831, alpha: 1)
styleToggle.backgroundColor = UIColor(red: 0.973, green: 0.329, blue: 0.294, alpha: 1)
styleToggle.layer.cornerRadius = 4
styleToggle.clipsToBounds = true
styleToggle.selectedSegmentIndex = 1
styleToggle.backgroundColor = .white
styleToggle.selectedSegmentIndex = style.rawValue
view.insertSubview(styleToggle, aboveSubview: mapView)
styleToggle.addTarget(self, action: #selector(switchStyle(sender:)), for: .valueChanged)
styleToggle.translatesAutoresizingMaskIntoConstraints = false
}

func installConstraints() {
// Configure autolayout constraints for the UISegmentedControl to align
// at the bottom of the map view.
NSLayoutConstraint(item: styleToggle, attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, toItem: mapView, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1.0, constant: 0.0).isActive = true
styleToggle.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: -60).isActive = true
NSLayoutConstraint.activate([
styleToggle.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: -60),
styleToggle.centerXAnchor.constraint(equalTo: mapView.centerXAnchor),
])
}

override public func viewDidAppear(_ animated: Bool) {
Expand Down
72 changes: 64 additions & 8 deletions Apps/Examples/Examples/All Examples/TrackingModeExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,64 @@ import UIKit
import MapboxMaps

@objc(TrackingModeExample)

public class TrackingModeExample: UIViewController, ExampleProtocol {

internal var mapView: MapView!
internal var cameraLocationConsumer: CameraLocationConsumer!
internal let toggleBearingImageButton: UIButton = UIButton(frame: .zero)
internal var showsBearingImage: Bool = false {
private var mapView: MapView!
private var cameraLocationConsumer: CameraLocationConsumer!
private lazy var toggleBearingImageButton = UIButton(frame: .zero)
private lazy var styleToggle = UISegmentedControl(items: Style.allCases.map(\.name))
private var style: Style = .satelliteStreets {
didSet {
mapView.mapboxMap.style.uri = style.uri
}
}
private var showsBearingImage: Bool = false {
didSet {
syncPuckAndButton()
}
}

private enum Style: Int, CaseIterable {
var name: String {
switch self {
case .light:
return "Light"
case .satelliteStreets:
return "Satelite"
case .customUri:
return "Custom"
}
}

var uri: StyleURI {
switch self {
case .light:
return .light
case .satelliteStreets:
return .satelliteStreets
case .customUri:
let localStyleURL = Bundle.main.url(forResource: "blueprint_style", withExtension: "json")!
return .init(url: localStyleURL)!
}
}

case light
case satelliteStreets
case customUri
}

override public func viewDidLoad() {
super.viewDidLoad()

// Set initial camera settings
let options = MapInitOptions(cameraOptions: CameraOptions(zoom: 15.0))
let options = MapInitOptions(styleURI: style.uri)

mapView = MapView(frame: view.bounds, mapInitOptions: options)
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(mapView)

addStyleToggle()

// Setup and create button for toggling show bearing image
setupToggleShowBearingImageButton()

Expand Down Expand Up @@ -66,14 +103,33 @@ public class TrackingModeExample: UIViewController, ExampleProtocol {
toggleBearingImageButton.backgroundColor = .systemBlue
toggleBearingImageButton.addTarget(self, action: #selector(showHideBearingImage), for: .touchUpInside)
toggleBearingImageButton.setTitleColor(.white, for: .normal)
syncPuckAndButton()
toggleBearingImageButton.layer.cornerRadius = 4
toggleBearingImageButton.clipsToBounds = true
toggleBearingImageButton.contentEdgeInsets = UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 16)

toggleBearingImageButton.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(toggleBearingImageButton)

// Constraints
toggleBearingImageButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20.0).isActive = true
toggleBearingImageButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20.0).isActive = true
toggleBearingImageButton.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -100.0).isActive = true
toggleBearingImageButton.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -70.0).isActive = true

syncPuckAndButton()
}

@objc func switchStyle(sender: UISegmentedControl) {
style = Style(rawValue: sender.selectedSegmentIndex) ?? . satelliteStreets
}

func addStyleToggle() {
// Create a UISegmentedControl to toggle between map styles
styleToggle.selectedSegmentIndex = style.rawValue
styleToggle.addTarget(self, action: #selector(switchStyle(sender:)), for: .valueChanged)
styleToggle.translatesAutoresizingMaskIntoConstraints = false

// set the segmented control as the title view
navigationItem.titleView = styleToggle
}
}

Expand Down
Loading

0 comments on commit da8254b

Please sign in to comment.