Skip to content

Commit 1f0c8a5

Browse files
RD-1007: Update README.md (#74)
1 parent acb8e87 commit 1f0c8a5

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,19 @@ mapView.pinToSuperviewEdges()
5858
```swift
5959
import MapTilerSDK
6060

61-
@State private var referenceStyle: MTMapReferenceStyle = .streets
62-
@State private var styleVariant: MTMapStyleVariant? = .defaultVariant
63-
6461
@State private var mapView = MTMapView(options: MTMapOptions(zoom: 2.0))
6562

6663
var body: some View {
6764
MTMapViewContainer(map: mapView) {}
68-
.referenceStyle(referenceStyle)
69-
.styleVariant(styleVariant)
65+
.referenceStyle(.streets)
7066
}
7167
```
7268

7369
For detailed functionality overview refer to the API Reference documentation or build local docs in Xcode: Product -> Build Documentation.
7470

7571
## Sources and Layers
7672

77-
Sources and layers can be added to the map view style object as soon as map is initialized.
73+
Sources and layers can be added to the map view style object as soon as map is initialized. Setting the style after adding layers resets them to default, so make sure style is finished loading first.
7874

7975
### UIKit
8076

@@ -83,8 +79,8 @@ guard let style = mapView.style else {
8379
return
8480
}
8581

86-
if let contoursTilesURL = URL(string: "https://api.maptiler.com/tiles/contours-v2/{z}/{x}/{y}.pbf?key=YOUR_API_KEY") {
87-
let contoursDataSource = MTVectorTileSource(identifier: "contoursSource", tiles: [contoursTilesURL])
82+
if let contoursTilesURL = URL(string: "https://api.maptiler.com/tiles/contours-v2/tiles.json?key=YOUR_API_KEY") {
83+
let contoursDataSource = MTVectorTileSource(identifier: "contoursSource", url: contoursTilesURL)
8884
style.addSource(contoursDataSource)
8985

9086
let contoursLayer = MTLineLayer(identifier: "contoursLayer", sourceIdentifier: contoursDataSource.identifier, sourceLayer: "contour_ft")
@@ -102,7 +98,7 @@ if let contoursTilesURL = URL(string: "https://api.maptiler.com/tiles/contours-v
10298

10399
var body: some View {
104100
MTMapViewContainer(map: mapView) {
105-
MTVectorTileSource(identifier: "countoursSource", tiles: [URL(string: "https://api.maptiler.com/tiles/contours-v2/{z}/{x}/{y}.pbf?key=YOUR_API_KEY")])
101+
MTVectorTileSource(identifier: "countoursSource", url: URL(string: "https://api.maptiler.com/tiles/contours-v2/tiles.json?key=YOUR_API_KEY"))
106102

107103
MTLineLayer(identifier: "contoursLayer", sourceIdentifier: "countoursSource", sourceLayer: "contour_ft")
108104
.color(.brown)

0 commit comments

Comments
 (0)