summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2018-01-24 16:53:07 -0800
committerMinh Nguyễn <mxn@1ec5.org>2018-01-24 17:25:41 -0800
commit84cabd9aa70ef511ddd09f1f594cf8748c7bad6d (patch)
tree9126aa466d2c29c68e51e6083f4b0e80134c7efe
parent6538eb39bd040f283a7e8f2cbe15b536d5960972 (diff)
downloadqtlocation-mapboxgl-upstream/1ec5-hillshade-10991.tar.gz
[ios, macos] Simplified raster DEM source exampleupstream/1ec5-hillshade-10991
-rw-r--r--platform/darwin/src/MGLRasterDEMSource.h13
-rw-r--r--platform/darwin/test/MGLDocumentationExampleTests.swift22
2 files changed, 18 insertions, 17 deletions
diff --git a/platform/darwin/src/MGLRasterDEMSource.h b/platform/darwin/src/MGLRasterDEMSource.h
index 50896f4fc9..d00912ca79 100644
--- a/platform/darwin/src/MGLRasterDEMSource.h
+++ b/platform/darwin/src/MGLRasterDEMSource.h
@@ -19,18 +19,15 @@
`MGLRasterDEMSource` object that you can use to initialize new style layers.
You can also add and remove sources dynamically using methods such as
`-[MGLStyle addSource:]` and `-[MGLStyle sourceWithIdentifier:]`.
+
+ Currently, raster DEM sources only support the format used by
+ <a href="https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb">Mapbox Terrain-RGB</a>.
### Example
```swift
- let source = MGLRasterDEMSource(identifier: "hills", tileURLTemplates: ["https://example.com/raster-rgb/{z}/{x}/{y}.png"], options: [
- .minimumZoomLevel: 9,
- .maximumZoomLevel: 16,
- .tileSize: 512,
- .attributionInfos: [
- MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "http://mapbox.com"))
- ]
- ])
+ let terrainRGBURL = URL(string: "mapbox://mapbox.terrain-rgb")!
+ let source = MGLRasterDEMSource(identifier: "hills", configurationURL: terrainRGBURL)
mapView.style?.addSource(source)
```
*/
diff --git a/platform/darwin/test/MGLDocumentationExampleTests.swift b/platform/darwin/test/MGLDocumentationExampleTests.swift
index 37f04a718b..9bf9924869 100644
--- a/platform/darwin/test/MGLDocumentationExampleTests.swift
+++ b/platform/darwin/test/MGLDocumentationExampleTests.swift
@@ -90,15 +90,19 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate {
}
func testMGLRasterDEMSource() {
+ // We want to use mapbox.terrain-rgb in the example, but using a mapbox:
+ // URL requires setting an access token. So this identically named
+ // subclass of MGLRasterDEMSource swaps in a nonexistent URL.
+ class MGLRasterDEMSource: Mapbox.MGLRasterDEMSource {
+ override init(identifier: String, configurationURL: URL, tileSize: CGFloat = 256) {
+ let bogusURL = URL(string: "https://example.com/raster-rgb.json")!
+ super.init(identifier: identifier, configurationURL: bogusURL, tileSize: tileSize)
+ }
+ }
+
//#-example-code
- let source = MGLRasterDEMSource(identifier: "hills", tileURLTemplates: ["https://example.com/raster-rgb/{z}/{x}/{y}.png"], options: [
- .minimumZoomLevel: 9,
- .maximumZoomLevel: 16,
- .tileSize: 512,
- .attributionInfos: [
- MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "http://mapbox.com"))
- ]
- ])
+ let terrainRGBURL = URL(string: "mapbox://mapbox.terrain-rgb")!
+ let source = MGLRasterDEMSource(identifier: "hills", configurationURL: terrainRGBURL)
mapView.style?.addSource(source)
//#-end-example-code
@@ -276,7 +280,7 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate {
let source = MGLRasterDEMSource(identifier: "dem", tileURLTemplates: ["https://example.com/raster-rgb/{z}/{x}/{y}.png"], options: [
.minimumZoomLevel: 9,
.maximumZoomLevel: 16,
- .tileSize: 512,
+ .tileSize: 256,
.attributionInfos: [
MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "http://mapbox.com"))
]