Skip to content

Commit 34d1b20

Browse files
authored
Merge pull request #524 from Esri/Caleb/New-AddTiledLayer
[New] Add tiled layer
2 parents 2f34ab4 + c3f26f5 commit 34d1b20

File tree

5 files changed

+137
-0
lines changed

5 files changed

+137
-0
lines changed

Samples.xcodeproj/project.pbxproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@
419419
D7BA8C442B2A4DAA00018633 /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7BA8C432B2A4DAA00018633 /* Array.swift */; };
420420
D7BA8C462B2A8ACA00018633 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7BA8C452B2A8ACA00018633 /* String.swift */; };
421421
D7BB3DD22C5D781800FFCD56 /* SaveTheBay.geodatabase in Resources */ = {isa = PBXBuildFile; fileRef = D7BB3DD02C5D781800FFCD56 /* SaveTheBay.geodatabase */; settings = {ASSET_TAGS = (EditGeodatabaseWithTransactions, ); }; };
422+
D7BE7E6F2CC19CC3006DDB0C /* AddTiledLayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7BE7E6B2CC19CC3006DDB0C /* AddTiledLayerView.swift */; };
423+
D7BE7E722CC19CE5006DDB0C /* AddTiledLayerView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7BE7E6B2CC19CC3006DDB0C /* AddTiledLayerView.swift */; };
422424
D7BEBAA02CBD9CCA00F882E7 /* MontereyElevation.dt2 in Resources */ = {isa = PBXBuildFile; fileRef = D7BEBA9E2CBD9CCA00F882E7 /* MontereyElevation.dt2 */; settings = {ASSET_TAGS = (AddElevationSourceFromRaster, ); }; };
423425
D7BEBAC52CBDC0F800F882E7 /* AddElevationSourceFromTilePackageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7BEBABF2CBDC0F800F882E7 /* AddElevationSourceFromTilePackageView.swift */; };
424426
D7BEBAC62CBDC11600F882E7 /* AddElevationSourceFromTilePackageView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7BEBABF2CBDC0F800F882E7 /* AddElevationSourceFromTilePackageView.swift */; };
@@ -560,6 +562,7 @@
560562
dstPath = "";
561563
dstSubfolderSpec = 7;
562564
files = (
565+
D7BE7E722CC19CE5006DDB0C /* AddTiledLayerView.swift in Copy Source Code Files */,
563566
D7BEBAD52CBDFE3900F882E7 /* DisplayAlternateSymbolsAtDifferentScalesView.swift in Copy Source Code Files */,
564567
D7BEBAC62CBDC11600F882E7 /* AddElevationSourceFromTilePackageView.swift in Copy Source Code Files */,
565568
D7848F012CBD987B00F6F546 /* AddElevationSourceFromRasterView.swift in Copy Source Code Files */,
@@ -1009,6 +1012,7 @@
10091012
D7BA8C432B2A4DAA00018633 /* Array.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Array.swift; sourceTree = "<group>"; };
10101013
D7BA8C452B2A8ACA00018633 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
10111014
D7BB3DD02C5D781800FFCD56 /* SaveTheBay.geodatabase */ = {isa = PBXFileReference; lastKnownFileType = file; path = SaveTheBay.geodatabase; sourceTree = "<group>"; };
1015+
D7BE7E6B2CC19CC3006DDB0C /* AddTiledLayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTiledLayerView.swift; sourceTree = "<group>"; };
10121016
D7BEBA9E2CBD9CCA00F882E7 /* MontereyElevation.dt2 */ = {isa = PBXFileReference; lastKnownFileType = text; path = MontereyElevation.dt2; sourceTree = "<group>"; };
10131017
D7BEBABF2CBDC0F800F882E7 /* AddElevationSourceFromTilePackageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddElevationSourceFromTilePackageView.swift; sourceTree = "<group>"; };
10141018
D7BEBAC72CBDC81200F882E7 /* MontereyElevation.tpkx */ = {isa = PBXFileReference; lastKnownFileType = file; path = MontereyElevation.tpkx; sourceTree = "<group>"; };
@@ -1206,6 +1210,7 @@
12061210
F19A316128906F0D003B7EF9 /* Add raster from file */,
12071211
955271622C0E6750009B1ED4 /* Add raster from service */,
12081212
E066DD3E28610F3F004D3D5B /* Add scene layer from service */,
1213+
D7BE7E6E2CC19CC3006DDB0C /* Add tiled layer */,
12091214
3E54CF202C66AFA400DD2F18 /* Add web tiled layer */,
12101215
D7E557602A1D743100B9FB09 /* Add WMS layer */,
12111216
1C3B7DC22A5F64FC00907443 /* Analyze network with subnetwork trace */,
@@ -2573,6 +2578,14 @@
25732578
path = 43809fd639f242fd8045ecbafd61a579;
25742579
sourceTree = "<group>";
25752580
};
2581+
D7BE7E6E2CC19CC3006DDB0C /* Add tiled layer */ = {
2582+
isa = PBXGroup;
2583+
children = (
2584+
D7BE7E6B2CC19CC3006DDB0C /* AddTiledLayerView.swift */,
2585+
);
2586+
path = "Add tiled layer";
2587+
sourceTree = "<group>";
2588+
};
25762589
D7BEBA9F2CBD9CCA00F882E7 /* 98092369c4ae4d549bbbd45dba993ebc */ = {
25772590
isa = PBXGroup;
25782591
children = (
@@ -3294,6 +3307,7 @@
32943307
D73723792AF5ADD800846884 /* FindRouteInMobileMapPackageView.MobileMapView.swift in Sources */,
32953308
E004A6E028466279002A1FE6 /* ShowCalloutView.swift in Sources */,
32963309
E000E763286A0B18005D87C5 /* CutGeometryView.swift in Sources */,
3310+
D7BE7E6F2CC19CC3006DDB0C /* AddTiledLayerView.swift in Sources */,
32973311
D7705D582AFC244E00CC0335 /* FindClosestFacilityToMultiplePointsView.swift in Sources */,
32983312
D73FCFFF2B02C7630006360D /* FindRouteAroundBarriersView.Views.swift in Sources */,
32993313
3EEDE7CE2C5D73F700510104 /* SetSpatialReferenceView.swift in Sources */,
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2024 Esri
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import ArcGIS
16+
import SwiftUI
17+
18+
struct AddTiledLayerView: View {
19+
/// A map with a "World Topographic Map" tiled layer.
20+
@State private var map: Map = {
21+
// A web URL to the "World_Topo_Map" map server on ArcGIS Online.
22+
let worldTopographicMap = URL(
23+
string: "https://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer"
24+
)!
25+
26+
// Creates a tiled layer using the URL.
27+
let tiledLayer = ArcGISTiledLayer(url: worldTopographicMap)
28+
29+
// Creates a basemap using the layer.
30+
let basemap = Basemap(baseLayer: tiledLayer)
31+
32+
// Creates a map using the basemap.
33+
let map = Map(basemap: basemap)
34+
35+
// Sets the initial viewpoint on the map to zoom in on the layer.
36+
let extent = Envelope(
37+
xRange: -18546390...(-1833410),
38+
yRange: -10740120...18985720,
39+
spatialReference: .webMercator
40+
)
41+
map.initialViewpoint = Viewpoint(boundingGeometry: extent)
42+
43+
return map
44+
}()
45+
46+
var body: some View {
47+
// Displays the map using a map view.
48+
MapView(map: map)
49+
}
50+
}
51+
52+
#Preview {
53+
AddTiledLayerView()
54+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Add tiled layer
2+
3+
Load an ArcGIS tiled layer from a URL.
4+
5+
![Screenshot of Add tiled layer sample](add-tiled-layer.png)
6+
7+
## Use case
8+
9+
An `ArcGISTiledLayer` consumes raster tiles provided by an ArcGIS service or a tile package (.tpk & .tpkx). Dividing a raster into tiles provides the user with relevant tiles and level of detail while panning and zooming, allowing for rapid map visualization and navigation. For example, say you wanted an application with a map containing all museums in your city so that you could share this with tourists. Since only the museums would need to support being identifiable or queryable within the app, all other contextual information required to orient and direct the tourists could be sourced from a single ArcGIS tiled layer, leading to faster performance and minimizing the time to load the map.
10+
11+
## How to use the sample
12+
13+
Open the sample to view the "World Topographic Map" tile layer as the basemap.
14+
15+
## How it works
16+
17+
1. Create an `ArcGISTiledLayer` object from a URL.
18+
2. Create a `Basemap`, passing in the tiled layer.
19+
3. Create a `Map` with the basemap.
20+
4. Set the map on the `MapView`.
21+
22+
## Relevant API
23+
24+
* ArcGISTiledLayer
25+
* Basemap
26+
* Map
27+
* MapView
28+
29+
## About the data
30+
31+
The application utilizes the "World Topographic Map" tile layer. This presents a simple yet powerful illustration of adding visualization context to a basemap through the use of an ArcGIS tiled layer.
32+
33+
## Additional information
34+
35+
An ArcGIS tiled layer can also be added to a map as a layer, but it's best practice to use it as a basemap since its purpose is to provide geographical context. ArcGIS tiled layers do not support reprojection, query, select, identify, or editing.
36+
37+
## Tags
38+
39+
basemap, layers, raster tiles, tiled layer, visualization
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"category": "Layers",
3+
"description": "Load an ArcGIS tiled layer from a URL.",
4+
"ignore": false,
5+
"images": [
6+
"add-tiled-layer.png"
7+
],
8+
"keywords": [
9+
"basemap",
10+
"layers",
11+
"raster tiles",
12+
"tiled layer",
13+
"visualization",
14+
"ArcGISTiledLayer",
15+
"Basemap",
16+
"Map",
17+
"MapView"
18+
],
19+
"redirect_from": [],
20+
"relevant_apis": [
21+
"ArcGISTiledLayer",
22+
"Basemap",
23+
"Map",
24+
"MapView"
25+
],
26+
"snippets": [
27+
"AddTiledLayerView.swift"
28+
],
29+
"title": "Add tiled layer"
30+
}
198 KB
Loading

0 commit comments

Comments
 (0)