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

Introduce MapboxMap #280

Merged
merged 4 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ public class ColorExpressionExample: UIViewController, ExampleProtocol {

if let data = try? JSONEncoder().encode(exp.self),
let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []) {
mapView.__map.setStyleLayerPropertyForLayerId("land",
property: "background-color",
value: jsonObject)
mapView.mapboxMap.__map.setStyleLayerPropertyForLayerId(
"land",
property: "background-color",
value: jsonObject)
}

// The below line is used for internal testing purposes only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ public class CustomLayerExample: UIViewController, ExampleProtocol {
// Position the custom layer above the water layer and below all other layers.
let layerPosition = LayerPosition(above: "water", below: nil, at: nil)

mapView.__map.addStyleCustomLayer(forLayerId: "Custom",
layerHost: self,
layerPosition: layerPosition)
mapView.mapboxMap.__map.addStyleCustomLayer(
forLayerId: "Custom",
layerHost: self,
layerPosition: layerPosition)
}
}

Expand Down
13 changes: 7 additions & 6 deletions Apps/Examples/Examples/All Examples/SceneKitExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ public class SceneKitExample: UIViewController, ExampleProtocol, CustomLayerHost
}

func addModelAndTerrain() {
mapView.__map.addStyleCustomLayer(forLayerId: "Custom",
layerHost: self,
layerPosition: LayerPosition(above: nil, below: "waterway-label", at: nil))
mapView.mapboxMap.__map.addStyleCustomLayer(
forLayerId: "Custom",
layerHost: self,
layerPosition: LayerPosition(above: nil, below: "waterway-label", at: nil))

var demSource = RasterDemSource()
demSource.url = "mapbox://mapbox.mapbox-terrain-dem-v1"
Expand All @@ -59,16 +60,16 @@ public class SceneKitExample: UIViewController, ExampleProtocol, CustomLayerHost
_ = self.mapView.style.addLayer(layer: skyLayer)

// Re-use terrain source for hillshade
let map = self.mapView.__map!
let properties = [
"id": "terrain_hillshade",
"type": "hillshade",
"source": "mapbox-dem",
"hillshade-illumination-anchor": "map"
] as [ String: Any ]

map.addStyleLayer(forProperties: properties,
layerPosition: LayerPosition(above: nil, below: "water", at: nil))
mapView.mapboxMap.__map.addStyleLayer(
forProperties: properties,
layerPosition: LayerPosition(above: nil, below: "water", at: nil))
}

public func renderingWillStart(_ metalDevice: MTLDevice, colorPixelFormat: UInt, depthStencilPixelFormat: UInt) {
Expand Down
23 changes: 11 additions & 12 deletions Apps/StressTest/StressTest/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class ViewController: UIViewController {
var color: StylePropertyValue?
var mapInitOptions: MapInitOptions!
var snapshotter: Snapshotter?
var peer: MBXPeerWrapper?
var logHandle: OSLog!

override func viewDidLoad() {
Expand Down Expand Up @@ -248,12 +247,15 @@ class ViewController: UIViewController {
do {
let data = try JSONEncoder().encode(exp.self)
let jsonObject = try JSONSerialization.jsonObject(with: data, options: [])
color = try mapView.__map.getStyleLayerProperty(forLayerId: land, property: "background-color")
color = mapView.mapboxMap.__map.getStyleLayerProperty(
forLayerId: land,
property: "background-color")

print("Setting background color expression")
try mapView.__map.setStyleLayerPropertyForLayerId(land,
property: "background-color",
value: jsonObject)
mapView.mapboxMap.__map.setStyleLayerPropertyForLayerId(
land,
property: "background-color",
value: jsonObject)
} catch let error {
print("Error setting background color: \(error)")
}
Expand All @@ -266,13 +268,10 @@ class ViewController: UIViewController {

if let color = color {
print("Re-setting background color expression")
do {
try mapView.__map.setStyleLayerPropertyForLayerId(land,
property: "background-color",
value: color.value)
} catch let error {
print("Failed to reset the background color: \(error)")
}
mapView.mapboxMap.__map.setStyleLayerPropertyForLayerId(
land,
property: "background-color",
value: color.value)
}
color = nil
}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Mapbox welcomes participation and contributions from everyone.
* `BaseMapView` no longer conforms to `MapClient` or `MBMMetalViewProvider`, and the methods they required are now internal.
* The setter for `BaseMapView.__map` is now private
* `Snapshotter` no longer conforms to `Observer`, and the method it required is now internal.
* The `BaseMapView.__map` property has been moved to `BaseMapView.mapboxMap.__map`. ([#280](https://github.com/mapbox/mapbox-maps-ios/pull/280))

## 10.0.0-beta.17 - April 13, 2021

Expand Down
20 changes: 20 additions & 0 deletions Mapbox/MapboxMaps.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@
B51DE65B25D7038900A80AC9 /* Comparable+Clamped.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51DE62125D7032C00A80AC9 /* Comparable+Clamped.swift */; };
B51DE68125D7039700A80AC9 /* Comparable+ClampedTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51DE64725D7038300A80AC9 /* Comparable+ClampedTests.swift */; };
B52050A8260538240003E5BB /* ModelLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52050A7260538240003E5BB /* ModelLayer.swift */; };
B521FC93262F626900B9A446 /* MapboxMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = B521FC92262F626900B9A446 /* MapboxMap.swift */; };
B521FC98262F627300B9A446 /* Size.swift in Sources */ = {isa = PBXBuildFile; fileRef = B521FC97262F627300B9A446 /* Size.swift */; };
B521FC9D262F665C00B9A446 /* SizeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B521FC9C262F665C00B9A446 /* SizeTests.swift */; };
B521FCA2262F67D000B9A446 /* MapboxMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B521FCA1262F67D000B9A446 /* MapboxMapTests.swift */; };
B521FCA7262F67DD00B9A446 /* MockMapClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = B521FCA6262F67DD00B9A446 /* MockMapClient.swift */; };
B529341C2624E9D6003B181C /* PreferredFPS.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52934192624E9D6003B181C /* PreferredFPS.swift */; };
B529341D2624E9D6003B181C /* DelegatingMapClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = B529341A2624E9D6003B181C /* DelegatingMapClient.swift */; };
B529341E2624E9D6003B181C /* DelegatingObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = B529341B2624E9D6003B181C /* DelegatingObserver.swift */; };
Expand Down Expand Up @@ -594,6 +599,11 @@
B51DE62125D7032C00A80AC9 /* Comparable+Clamped.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Comparable+Clamped.swift"; sourceTree = "<group>"; };
B51DE64725D7038300A80AC9 /* Comparable+ClampedTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Comparable+ClampedTests.swift"; sourceTree = "<group>"; };
B52050A7260538240003E5BB /* ModelLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModelLayer.swift; sourceTree = "<group>"; };
B521FC92262F626900B9A446 /* MapboxMap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapboxMap.swift; sourceTree = "<group>"; };
B521FC97262F627300B9A446 /* Size.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Size.swift; sourceTree = "<group>"; };
B521FC9C262F665C00B9A446 /* SizeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SizeTests.swift; sourceTree = "<group>"; };
B521FCA1262F67D000B9A446 /* MapboxMapTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapboxMapTests.swift; sourceTree = "<group>"; };
B521FCA6262F67DD00B9A446 /* MockMapClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockMapClient.swift; sourceTree = "<group>"; };
B52934192624E9D6003B181C /* PreferredFPS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferredFPS.swift; sourceTree = "<group>"; };
B529341A2624E9D6003B181C /* DelegatingMapClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DelegatingMapClient.swift; sourceTree = "<group>"; };
B529341B2624E9D6003B181C /* DelegatingObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DelegatingObserver.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -770,6 +780,7 @@
0782B1DB258C254400D5FCE5 /* Core */ = {
isa = PBXGroup;
children = (
B521FC97262F627300B9A446 /* Size.swift */,
CABCDF502620E0FF00D61635 /* MapOptions.swift */,
B5B55D4B260E4D2900EBB589 /* MBXEdgeInsets.swift */,
0782B075258C190C00D5FCE5 /* CoordinateBounds.swift */,
Expand Down Expand Up @@ -1145,6 +1156,7 @@
1F11C1102421B05600F8397B /* MapboxMapsFoundation */ = {
isa = PBXGroup;
children = (
B521FC92262F626900B9A446 /* MapboxMap.swift */,
B529341A2624E9D6003B181C /* DelegatingMapClient.swift */,
B529341B2624E9D6003B181C /* DelegatingObserver.swift */,
B52934192624E9D6003B181C /* PreferredFPS.swift */,
Expand Down Expand Up @@ -1179,6 +1191,8 @@
07182014256C1F6100F22489 /* Assets.xcassets */,
0CDFEAD725A77430008BC505 /* UtilsTests.swift */,
B51DE64725D7038300A80AC9 /* Comparable+ClampedTests.swift */,
B521FCA1262F67D000B9A446 /* MapboxMapTests.swift */,
B521FCA6262F67DD00B9A446 /* MockMapClient.swift */,
);
name = MapboxMapsFoundationTests;
path = ../Tests/MapboxMapsTests/Foundation;
Expand Down Expand Up @@ -1472,6 +1486,7 @@
children = (
CA03F0962624FDED00673961 /* ResourceOptionsTests.swift */,
CA0C42942602BF000054D9D0 /* LayerPositionTests.swift */,
B521FC9C262F665C00B9A446 /* SizeTests.swift */,
);
path = Core;
sourceTree = "<group>";
Expand Down Expand Up @@ -1901,6 +1916,7 @@
0C708F2524EB1EE2003CE791 /* HillshadeLayer.swift in Sources */,
CABCDF512620E0FF00D61635 /* MapOptions.swift in Sources */,
0C708F2124EB1EE2003CE791 /* FillExtrusionLayer.swift in Sources */,
B521FC98262F627300B9A446 /* Size.swift in Sources */,
0C26425524EECD14001FE2E3 /* AllExpressions.swift in Sources */,
0782B1A3258C250400D5FCE5 /* Geometry.swift in Sources */,
0CD62F1024588530006421D1 /* GestureManager.swift in Sources */,
Expand Down Expand Up @@ -1984,6 +2000,7 @@
1FECC9E02474519D00B63910 /* Expression.swift in Sources */,
B52050A8260538240003E5BB /* ModelLayer.swift in Sources */,
B529341C2624E9D6003B181C /* PreferredFPS.swift in Sources */,
B521FC93262F626900B9A446 /* MapboxMap.swift in Sources */,
0CD62F1124588532006421D1 /* GestureHandlerDelegate.swift in Sources */,
0782B061258C16B200D5FCE5 /* Utils.swift in Sources */,
0CD62F2C24588937006421D1 /* Style.swift in Sources */,
Expand Down Expand Up @@ -2038,6 +2055,7 @@
CA03F0872624FDB100673961 /* MapInitOptionsTests.swift in Sources */,
C69F015A254358C5001AB49B /* AnnotationManagerIntegrationTests.swift in Sources */,
0CC6EF1725C3263400BFB153 /* SymbolLayerIntegrationTests.swift in Sources */,
B521FCA2262F67D000B9A446 /* MapboxMapTests.swift in Sources */,
0C5CFCDF25BB951B0001E753 /* BackgroundLayerTests.swift in Sources */,
CA2E4A1C2538D3530096DEDE /* IntegrationTestCase.swift in Sources */,
CA4AE0DB252D655A00183075 /* AnnotationInteractionDelegateTests.swift in Sources */,
Expand Down Expand Up @@ -2112,6 +2130,7 @@
CA548FF1251C404B00F829A3 /* RotateGestureHandlerTests.swift in Sources */,
CA4AE033252D654800183075 /* LineAnnotationTests.swift in Sources */,
0C37B1E425CB05F000DCDD3D /* ColorTests.swift in Sources */,
B521FCA7262F67DD00B9A446 /* MockMapClient.swift in Sources */,
B5A6921D262754DF00A03412 /* MockDelegatingObserverDelegate.swift in Sources */,
CADC7AD3251C51070082BA0A /* MockAnnotationSupportableMap.swift in Sources */,
0C32CA2125F982300057ED31 /* RasterDemSourceTests.swift in Sources */,
Expand Down Expand Up @@ -2139,6 +2158,7 @@
CA548FFB251C404B00F829A3 /* StyleURITests.swift in Sources */,
CA2E4A1B2538D3530096DEDE /* MapViewIntegrationTestCase.swift in Sources */,
0C32CA2A25F982300057ED31 /* ImageSourceTests.swift in Sources */,
B521FC9D262F665C00B9A446 /* SizeTests.swift in Sources */,
0C5CFCD625BB951B0001E753 /* FillExtrusionLayerTests.swift in Sources */,
B54B7F2125DB1ABA003FD6CA /* Stub.swift in Sources */,
0C01C0B925486E7200E4AA46 /* ExpressionTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal protocol AnnotationSupportableMap: UIView {
extension BaseMapView: AnnotationSupportableMap {

public var observable: Observable? {
return __map
return mapboxMap.__map
}

public enum QueryRenderedFeaturesError: Error {
Expand Down Expand Up @@ -62,7 +62,7 @@ extension BaseMapView: AnnotationSupportableMap {
let screenBox = ScreenBox(min: ScreenCoordinate(x: Double(rect.minX), y: Double(rect.minY)),
max: ScreenCoordinate(x: Double(rect.maxX), y: Double(rect.maxY)))

__map.queryRenderedFeatures(for: screenBox, options: queryOptions, callback: { (expected: MBXExpected?) in
mapboxMap.__map.queryRenderedFeatures(for: screenBox, options: queryOptions, callback: { (expected: MBXExpected?) in

guard let validExpected = expected else {
completion(.failure(.unknown))
Expand Down Expand Up @@ -113,7 +113,7 @@ extension BaseMapView: AnnotationSupportableMap {
let screenPoint = ScreenCoordinate(x: Double(point.x),
y: Double(point.y))

__map.queryRenderedFeatures(forPixel: screenPoint, options: queryOptions, callback: { (expected: MBXExpected?) in
mapboxMap.__map.queryRenderedFeatures(forPixel: screenPoint, options: queryOptions, callback: { (expected: MBXExpected?) in

guard let validExpected = expected else {
completion(.failure(.unknown))
Expand Down
Loading