i want to my Desktop app could geocoding on different Layers - imagery and topographic, in offline of course. i used sample codes, but i got some errors, so i need help. thanks
Could you share which samples you have tried and what you need to do in more detail? Have you had a look into the Create Offline map documentation?
Here is a function I use to load the map from a config file.
This code assumes you have your .geodatabase and/or your tpk's already pulled to your machine. See Antti's comment above for the links to how to do that.
....
foreach (var layerConfig in AppConfig.Layers)
{
LayerConfigModel layerConfigModel = (LayerConfigModel)JsonConvert.DeserializeObject(layerConfig.SelectToken("config").ToString(),
typeof (LayerConfigModel), _jsonSerializerSettings);
Guid unkNum = new Guid();
layerConfigModel.Id = layerConfig["name"]?.ToString()??"UNK"+unkNum;
Layer layerToAdd;
if (!IsAppOnline)
{
layerToAdd = await LoadOfflineLayer(layerConfigModel);
}
else
{
layerToAdd = LoadOnlineLayer(layerConfigModel);
}
AppMapView.Map.Layers.Add(layerToAdd);
await layerToAdd.InitializeAsync();
TocLayerModel tocLayer = new TocLayerModel(layerConfigModel, layerToAdd, IsAppOnline, UserZone);
AppMapLayers.Add(tocLayer);
tocLayer.SetScaleVisiblity(AppMapView.Scale);
}
....
// Load offline layer - Inner loop of LoadOperationalLayers
private async Task<Layer> LoadOfflineLayer(LayerConfigModel layerConfigModel)
{
Layer layerToAdd = null;
try
{
var filePath = System.Configuration.ConfigurationSettings.AppSettings["AppDirectory"] +
AppConfig.MapConfig["mapConfig"]["user"]["userZone"] +
layerConfigModel.Id + "." +
((layerConfigModel.LayerType == "dynamic") ? "geodatabase" : "tpk");
switch (layerConfigModel.LayerType.ToLower())
{
case "image":
case "static":
ArcGISLocalTiledLayer localLayer = new ArcGISLocalTiledLayer(filePath);
await localLayer.InitializeAsync();
localLayer.ID = layerConfigModel.Id;
layerToAdd = localLayer;
break;
// ReSharper disable once RedundantCaseLabel
case "dynamic":
default:
var gdb = await Geodatabase.OpenAsync(filePath);
GroupLayer gLayer = new GroupLayer();
AddLocalGdbToMap(gdb, layerConfigModel, gLayer);
await gLayer.InitializeAsync();
layerToAdd = gLayer;
layerToAdd.DisplayName = layerConfigModel.Title;
break;
}
}
catch (Exception ex)
{
//TODO: Error handling
Console.WriteLine(ex.Message);
//MessageBox.Show("Error creating feature layer: " + ex.Message, "Samples");
}
return layerToAdd;
}
thanks for answer, this code valid for WPF or windows Form aplication? and how create tpk file?
>> thanks for answer,
No worries
>> this code valid for WPF or windows Form aplication?
WPF
>> and how create tpk file?
Create an offline map—ArcGIS Runtime SDK for .NET | ArcGIS for Developers
Export Tiles
URL: http://Map Service/exportTiles
Version Introduced: 10.2.1
Description
The exportTiles operation is performed as an asynchronous task and allows client applications to download map tiles from a server for offline use. This operation is performed on a Map Service that allows clients to export cache tiles. The result of this operation is Map Service Job. This job response contains a reference to the Map Service Result resource, which returns a URL to the resulting tile package (.tpk) or a cache raster dataset.
exportTiles can be enabled in a service by using ArcGIS for Desktop or the ArcGIS Server Administrator Directory. In ArcGIS for Desktop, make an admin or publisher connection to the server, go to service properties, and enable Allow Clients to Export Cache Tiles in the advanced caching page of the Service Editor. You can also specify the maximum tiles clients will be allowed to download. The default maximum allowed tile count is 100,000. To enable this capability using the Administrator Directory, edit the service, and set the properties exportTilesAllowed=true and maxExportTilesCount=100000.
At 10.2.2 and later versions, exportTiles is supported as an operation of the Map Server. The use of the http://Map Service/exportTiles/submitJob operation is deprecated.
You can provide arguments to the exportTiles operation as defined in the following parameters table:
...
From the help file.
sorry, but url is broken 😕
that was not a url sorry.
That is the url to Your map service.. http://[YOURSERVER]/arcgis/rest/services/[yourPublishedService]/MapService/exportTiles
If you don't have Export Tiles, you need to publish with the cache on.