Skip to content

Commit d5352ac

Browse files
committed
Merge branch 'v.next' into Caleb/New-AddVectorTiledLayerFromCustomStyle
2 parents 61d2d58 + 83e4a2b commit d5352ac

File tree

5 files changed

+136
-1
lines changed

5 files changed

+136
-1
lines changed

Samples.xcodeproj/project.pbxproj

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@
264264
D7201D042CC6D3B5004BDB7D /* AddVectorTiledLayerFromCustomStyleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7201D002CC6D3B5004BDB7D /* AddVectorTiledLayerFromCustomStyleView.swift */; };
265265
D7201D072CC6D3D3004BDB7D /* AddVectorTiledLayerFromCustomStyleView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7201D002CC6D3B5004BDB7D /* AddVectorTiledLayerFromCustomStyleView.swift */; };
266266
D7201D2B2CC6D829004BDB7D /* dodge_city.vtpk in Resources */ = {isa = PBXBuildFile; fileRef = D7201D292CC6D829004BDB7D /* dodge_city.vtpk */; settings = {ASSET_TAGS = (AddVectorTiledLayerFromCustomStyle, ); }; };
267+
D7201CDA2CC6B710004BDB7D /* AddTiledLayerAsBasemapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7201CD42CC6B710004BDB7D /* AddTiledLayerAsBasemapView.swift */; };
268+
D7201CDB2CC6B72A004BDB7D /* AddTiledLayerAsBasemapView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7201CD42CC6B710004BDB7D /* AddTiledLayerAsBasemapView.swift */; };
267269
D721EEA82ABDFF550040BE46 /* LothianRiversAnno.mmpk in Resources */ = {isa = PBXBuildFile; fileRef = D721EEA72ABDFF550040BE46 /* LothianRiversAnno.mmpk */; settings = {ASSET_TAGS = (ShowMobileMapPackageExpirationDate, ); }; };
268270
D722BD222A420DAD002C2087 /* ShowExtrudedFeaturesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D722BD212A420DAD002C2087 /* ShowExtrudedFeaturesView.swift */; };
269271
D722BD232A420DEC002C2087 /* ShowExtrudedFeaturesView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D722BD212A420DAD002C2087 /* ShowExtrudedFeaturesView.swift */; };
@@ -438,7 +440,7 @@
438440
D7C16D282AC5FEB700689E89 /* Hawaii.csv in Resources */ = {isa = PBXBuildFile; fileRef = D7C16D272AC5FEB600689E89 /* Hawaii.csv */; settings = {ASSET_TAGS = (Animate3DGraphic, ); }; };
439441
D7C3AB4A2B683291008909B9 /* SetFeatureRequestModeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7C3AB472B683291008909B9 /* SetFeatureRequestModeView.swift */; };
440442
D7C3AB4D2B6832B7008909B9 /* SetFeatureRequestModeView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7C3AB472B683291008909B9 /* SetFeatureRequestModeView.swift */; };
441-
D7C523402BED9BBF00E8221A /* SanFrancisco.tpkx in Resources */ = {isa = PBXBuildFile; fileRef = D7C5233E2BED9BBF00E8221A /* SanFrancisco.tpkx */; settings = {ASSET_TAGS = (EditAndSyncFeaturesWithFeatureService, ); }; };
443+
D7C523402BED9BBF00E8221A /* SanFrancisco.tpkx in Resources */ = {isa = PBXBuildFile; fileRef = D7C5233E2BED9BBF00E8221A /* SanFrancisco.tpkx */; settings = {ASSET_TAGS = (AddTiledLayerAsBasemap, EditAndSyncFeaturesWithFeatureService, ); }; };
442444
D7C6420C2B4F47E10042B8F7 /* SearchForWebMapView.Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7C6420B2B4F47E10042B8F7 /* SearchForWebMapView.Model.swift */; };
443445
D7C6420D2B4F5DDB0042B8F7 /* SearchForWebMapView.Model.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7C6420B2B4F47E10042B8F7 /* SearchForWebMapView.Model.swift */; };
444446
D7C97B562B75C10C0097CDA1 /* ValidateUtilityNetworkTopologyView.Views.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7C97B552B75C10C0097CDA1 /* ValidateUtilityNetworkTopologyView.Views.swift */; };
@@ -566,6 +568,7 @@
566568
dstSubfolderSpec = 7;
567569
files = (
568570
D7201D072CC6D3D3004BDB7D /* AddVectorTiledLayerFromCustomStyleView.swift in Copy Source Code Files */,
571+
D7201CDB2CC6B72A004BDB7D /* AddTiledLayerAsBasemapView.swift in Copy Source Code Files */,
569572
D7BE7E722CC19CE5006DDB0C /* AddTiledLayerView.swift in Copy Source Code Files */,
570573
D7BEBAD52CBDFE3900F882E7 /* DisplayAlternateSymbolsAtDifferentScalesView.swift in Copy Source Code Files */,
571574
D7BEBAC62CBDC11600F882E7 /* AddElevationSourceFromTilePackageView.swift in Copy Source Code Files */,
@@ -932,6 +935,7 @@
932935
D71FCB892AD6277E000E517C /* CreateMobileGeodatabaseView.Model.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreateMobileGeodatabaseView.Model.swift; sourceTree = "<group>"; };
933936
D7201D002CC6D3B5004BDB7D /* AddVectorTiledLayerFromCustomStyleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddVectorTiledLayerFromCustomStyleView.swift; sourceTree = "<group>"; };
934937
D7201D292CC6D829004BDB7D /* dodge_city.vtpk */ = {isa = PBXFileReference; lastKnownFileType = file; path = dodge_city.vtpk; sourceTree = "<group>"; };
938+
D7201CD42CC6B710004BDB7D /* AddTiledLayerAsBasemapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTiledLayerAsBasemapView.swift; sourceTree = "<group>"; };
935939
D721EEA72ABDFF550040BE46 /* LothianRiversAnno.mmpk */ = {isa = PBXFileReference; lastKnownFileType = file; path = LothianRiversAnno.mmpk; sourceTree = "<group>"; };
936940
D722BD212A420DAD002C2087 /* ShowExtrudedFeaturesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShowExtrudedFeaturesView.swift; sourceTree = "<group>"; };
937941
D7232EE02AC1E5AA0079ABFF /* PlayKMLTourView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayKMLTourView.swift; sourceTree = "<group>"; };
@@ -1218,6 +1222,7 @@
12181222
E066DD3E28610F3F004D3D5B /* Add scene layer from service */,
12191223
D7BE7E6E2CC19CC3006DDB0C /* Add tiled layer */,
12201224
D7201D032CC6D3B5004BDB7D /* Add vector tiled layer from custom style */,
1225+
D7201CD72CC6B710004BDB7D /* Add tiled layer as basemap */,
12211226
3E54CF202C66AFA400DD2F18 /* Add web tiled layer */,
12221227
D7E557602A1D743100B9FB09 /* Add WMS layer */,
12231228
1C3B7DC22A5F64FC00907443 /* Analyze network with subnetwork trace */,
@@ -2076,6 +2081,14 @@
20762081
path = f4b742a57af344988b02227e2824ca5f;
20772082
sourceTree = "<group>";
20782083
};
2084+
D7201CD72CC6B710004BDB7D /* Add tiled layer as basemap */ = {
2085+
isa = PBXGroup;
2086+
children = (
2087+
D7201CD42CC6B710004BDB7D /* AddTiledLayerAsBasemapView.swift */,
2088+
);
2089+
path = "Add tiled layer as basemap";
2090+
sourceTree = "<group>";
2091+
};
20792092
D721EEA62ABDFF550040BE46 /* 174150279af74a2ba6f8b87a567f480b */ = {
20802093
isa = PBXGroup;
20812094
children = (
@@ -3102,6 +3115,7 @@
31023115
AddPointCloudLayerFromFile,
31033116
AddRasterFromFile,
31043117
AddVectorTiledLayerFromCustomStyle,
3118+
AddTiledLayerAsBasemap,
31053119
Animate3DGraphic,
31063120
AnimateImagesWithImageOverlay,
31073121
ApplyScheduledUpdatesToPreplannedMapArea,
@@ -3330,6 +3344,7 @@
33303344
D7CDD38B2CB86F0A00DE9766 /* AddPointCloudLayerFromFileView.swift in Sources */,
33313345
D7BA38912BFBC476009954F5 /* EditFeaturesWithFeatureLinkedAnnotationView.Model.swift in Sources */,
33323346
10D321962BDB1CB500B39B1B /* GenerateOfflineMapWithLocalBasemapView.swift in Sources */,
3347+
D7201CDA2CC6B710004BDB7D /* AddTiledLayerAsBasemapView.swift in Sources */,
33333348
D73723792AF5ADD800846884 /* FindRouteInMobileMapPackageView.MobileMapView.swift in Sources */,
33343349
E004A6E028466279002A1FE6 /* ShowCalloutView.swift in Sources */,
33353350
E000E763286A0B18005D87C5 /* CutGeometryView.swift in Sources */,
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 AddTiledLayerAsBasemapView: View {
19+
/// A map of the streets in San Francisco.
20+
@State private var map: Map = {
21+
// Creates a tile cache using a URL to a local tile package file.
22+
let tileCache = TileCache(fileURL: .sanFranciscoStreetsTilePackage)
23+
24+
// Creates a tiled layer using the tile cache.
25+
let tiledLayer = ArcGISTiledLayer(tileCache: tileCache)
26+
27+
// Creates a basemap using the layer.
28+
let basemap = Basemap(baseLayer: tiledLayer)
29+
30+
// Creates a map using the basemap.
31+
return Map(basemap: basemap)
32+
}()
33+
34+
var body: some View {
35+
// Displays the map using a map view.
36+
MapView(map: map)
37+
}
38+
}
39+
40+
private extension URL {
41+
/// The URL to the local tile package file with street data for San Francisco, CA, USA.
42+
static var sanFranciscoStreetsTilePackage: URL {
43+
Bundle.main.url(forResource: "SanFrancisco", withExtension: "tpkx")!
44+
}
45+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Add tiled layer as basemap
2+
3+
Load an offline copy of a tiled map service as a basemap.
4+
5+
![Screenshot of Add tiled layer as basemap sample](add-tiled-layer-as-basemap.png)
6+
7+
## Use case
8+
9+
Constructing a tiled layer from a local tile package (.tpk & .tpkx) allows you to use that basemap tiled service when the application is offline. Dividing a raster into tiles allows the map to provide relevant tiles and level of detail to the user when panning and zooming. For example, when working in an environment that has no connectivity, this could provide access to a map for navigating your surroundings.
10+
11+
## How to use the sample
12+
13+
Launch the app to view the "San Francisco offline tile package" as the basemap.
14+
15+
## How it works
16+
17+
1. Create a `TileCache`, specifying the path to the local tile package.
18+
2. Create an `ArcGISTiledLayer` with the tile cache.
19+
3. Create a `Basemap` with the tiled layer.
20+
4. Create a `Map` with the basemap and pass it to a MapView.
21+
22+
## Relevant API
23+
24+
* ArcGISTiledLayer
25+
* Basemap
26+
* Map
27+
* TileCache
28+
29+
## Offline data
30+
31+
This sample uses the [San Francisco offline tile package](https://www.arcgis.com/home/item.html?id=e4a398afe9a945f3b0f4dca1e4faccb5). It is downloaded from ArcGIS Online automatically.
32+
33+
## About the data
34+
35+
The map opens to a view of the city of San Francisco, CA. In a disconnected environment, this basemap tile service would be fully accessible to zoom and pan as if you were connected to an online service.
36+
37+
## Additional information
38+
39+
`ArcGISTiledLayer` and `TileCache` supports both .tpk and .tpkx file formats.
40+
41+
## Tags
42+
43+
cache, layers, offline, tile
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"category": "Edit and Manage Data",
3+
"description": "Load an offline copy of a tiled map service as a basemap.",
4+
"ignore": false,
5+
"images": [
6+
"add-tiled-layer-as-basemap.png"
7+
],
8+
"keywords": [
9+
"cache",
10+
"layers",
11+
"offline",
12+
"tile",
13+
"ArcGISTiledLayer",
14+
"Basemap",
15+
"Map",
16+
"TileCache"
17+
],
18+
"offline_data": [
19+
"e4a398afe9a945f3b0f4dca1e4faccb5"
20+
],
21+
"redirect_from": [],
22+
"relevant_apis": [
23+
"ArcGISTiledLayer",
24+
"Basemap",
25+
"Map",
26+
"TileCache"
27+
],
28+
"snippets": [
29+
"AddTiledLayerAsBasemapView.swift"
30+
],
31+
"title": "Add tiled layer as basemap"
32+
}
140 KB
Loading

0 commit comments

Comments
 (0)