Skip to content

Commit 76a8761

Browse files
committed
Add readme and source code.
1 parent b5070fa commit 76a8761

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

Samples.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
218F35B829C28F4A00502022 /* AuthenticateWithOAuthView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 218F35B329C28F4A00502022 /* AuthenticateWithOAuthView.swift */; };
140140
218F35C229C290BF00502022 /* AuthenticateWithOAuthView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 218F35B329C28F4A00502022 /* AuthenticateWithOAuthView.swift */; };
141141
3E26AFB62C627F0900BD2CBC /* AddWebTiledLayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E26AFB52C627F0900BD2CBC /* AddWebTiledLayerView.swift */; };
142+
3E7183942C643C9200154294 /* AddWebTiledLayerView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 3E26AFB52C627F0900BD2CBC /* AddWebTiledLayerView.swift */; };
142143
4D126D6D29CA1B6000CFB7A7 /* ShowDeviceLocationWithNMEADataSourcesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D126D6929CA1B6000CFB7A7 /* ShowDeviceLocationWithNMEADataSourcesView.swift */; };
143144
4D126D7229CA1E1800CFB7A7 /* FileNMEASentenceReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D126D7129CA1E1800CFB7A7 /* FileNMEASentenceReader.swift */; };
144145
4D126D7329CA1EFD00CFB7A7 /* ShowDeviceLocationWithNMEADataSourcesView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 4D126D6929CA1B6000CFB7A7 /* ShowDeviceLocationWithNMEADataSourcesView.swift */; };
@@ -528,6 +529,7 @@
528529
dstPath = "";
529530
dstSubfolderSpec = 7;
530531
files = (
532+
3E7183942C643C9200154294 /* AddWebTiledLayerView.swift in Copy Source Code Files */,
531533
D78FA4952C3C8E8A0079313E /* CreateDynamicBasemapGalleryView.Views.swift in Copy Source Code Files */,
532534
D79482D72C35D8A3006521CD /* CreateDynamicBasemapGalleryView.swift in Copy Source Code Files */,
533535
003B36F92C5042BA00A75F66 /* ShowServiceAreaView.swift in Copy Source Code Files */,

Shared/Samples/Add web tiled layer/AddWebTiledLayerView.swift

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,59 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import ArcGIS
1516
import SwiftUI
1617

1718
struct AddWebTiledLayerView: View {
19+
/// The view model for the sample.
20+
@StateObject private var model = Model()
21+
1822
var body: some View {
19-
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
23+
VStack {
24+
MapView(map: model.map)
25+
}
26+
}
27+
}
28+
29+
private extension AddWebTiledLayerView {
30+
// MARK: - Model
31+
32+
/// The view model for the sample.
33+
final class Model: ObservableObject {
34+
@Published var map: Map
35+
36+
init() {
37+
self.map = Model.createMap()
38+
}
39+
40+
/// A map with a web tiled layer as basemap.
41+
static func createMap() -> Map {
42+
let webTiledLayer = webTiledLayer()
43+
let basemap = Basemap(baseLayer: webTiledLayer)
44+
let map = Map(basemap: basemap)
45+
return map
46+
}
47+
48+
static func webTiledLayer() -> WebTiledLayer {
49+
let worldTileServiceURL = "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{level}/{row}/{col}.jpg"
50+
51+
let attribution = """
52+
Map tiles by <a href="https://livingatlas.arcgis.com">ArcGIS Living Atlas of the World</a>, under <a href="https://www.esri.com/en-us/legal/terms/full-master-agreement">Esri Master License Agreement</a>. Data by Esri, Garmin, GEBCO, NOAA NGDC, and other contributors.
53+
"""
54+
55+
// Build the web tiled layer from ArcGIS Living Atlas of the World tile service url.
56+
let webTiledLayer = WebTiledLayer(urlTemplate: worldTileServiceURL)
57+
// Set the attribution on the layer.
58+
webTiledLayer.setAttribution(attribution)
59+
60+
return webTiledLayer
61+
}
62+
}
63+
}
64+
65+
struct AddWebTiledLayerView_Previews: PreviewProvider {
66+
static var previews: some View {
67+
AddWebTiledLayerView()
2068
}
2169
}
2270

157 KB
Loading

0 commit comments

Comments
 (0)