本文整理汇总了C#中FeatureLayer.InitializeAsync方法的典型用法代码示例。如果您正苦于以下问题:C# FeatureLayer.InitializeAsync方法的具体用法?C# FeatureLayer.InitializeAsync怎么用?C# FeatureLayer.InitializeAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FeatureLayer
的用法示例。
在下文中一共展示了FeatureLayer.InitializeAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryLoadOnlineLayers
private async void TryLoadOnlineLayers()
{
try
{
// create an online tiled map service layer, an online feature layer
var basemapLayer = new ArcGISTiledMapServiceLayer(new Uri(basemapUrl));
var operationalLayer = new FeatureLayer(new Uri(operationalUrl));
// give the feature layer an ID so it can be found later
operationalLayer.ID = "Sightings";
// initialize the layers
await basemapLayer.InitializeAsync();
await operationalLayer.InitializeAsync();
// see if there was an exception when initializing the layers, if so throw an exception
if (basemapLayer.InitializationException != null || operationalLayer.InitializationException != null)
{
// unable to load one or more of the layers, throw an exception
throw new Exception("Could not initialize layers");
}
// add layers
MyMapView.Map.Layers.Add(basemapLayer);
MyMapView.Map.Layers.Add(operationalLayer);
}
catch (ArcGISWebException arcGisExp)
{
//token required?
MessageBox.Show("Unable to load online layers: credentials may be required", "Load Error");
}
catch (System.Net.Http.HttpRequestException httpExp)
{
// not connected? server down? wrong URI?
MessageBox.Show("Unable to load online layers: check your connection and verify service URLs", "Load Error");
}
catch (Exception exp)
{
// other problems ...
MessageBox.Show("Unable to load online layers: " + exp.Message, "Load Error");
}
}
示例2: TryLoadLocalLayers
private async void TryLoadLocalLayers()
{
try
{
if (string.IsNullOrEmpty(this.localGeodatabasePath))
{
throw new Exception("Local features do not yet exist. Please generate them first.");
}
if (string.IsNullOrEmpty(this.localTileCachePath))
{
throw new Exception("Local tiles do not yet exist. Please generate them first.");
}
// create a local tiled layer
var basemapLayer = new ArcGISLocalTiledLayer(this.localTileCachePath);
// open the local geodatabase, get the first (only) table, create a FeatureLayer to display it
var localGdb = await Geodatabase.OpenAsync(this.localGeodatabasePath);
var gdbTable = localGdb.FeatureTables.FirstOrDefault();
var operationalLayer = new FeatureLayer(gdbTable);
// give the feature layer an ID so it can be found later
operationalLayer.ID = "Sightings";
await basemapLayer.InitializeAsync();
await operationalLayer.InitializeAsync();
// see if there was an exception when initializing the layer
if (basemapLayer.InitializationException != null || operationalLayer.InitializationException != null)
{
// unable to load one or more of the layers, throw an exception
throw new Exception("Could not initialize local layers");
}
// add the local layers to the map
MyMapView.Map.Layers.Add(basemapLayer);
MyMapView.Map.Layers.Add(operationalLayer);
}
catch (Exception exp)
{
MessageBox.Show("Unable to load local layers: " + exp.Message, "Load Layers");
}
}
示例3: SearchArcgisOnline
private async void SearchArcgisOnline()
{
try
{
IsBusy = true;
//create Portal instance
try
{
_arcGisPortal = await ArcGISPortal.CreateAsync(_model.DefaultServerUri);
}
catch (ArcGISWebException agwex)
{
_model.SetMessageInfo(agwex.Message);
if ((int) agwex.Code == 498)
{
MessageBox.Show("Der Token ist abgelaufen");
}
return;
}
//define search creteria
var sb = new StringBuilder();
sb.Append(string.Format("{0} ", SearchText));
sb.Append("type:(\"web map\" NOT \"web mapping application\") ");
sb.Append("typekeywords:(\"offline\") ");
if (_arcGisPortal.CurrentUser != null &&
_arcGisPortal.ArcGISPortalInfo != null &&
!string.IsNullOrEmpty(_arcGisPortal.ArcGISPortalInfo.Id))
{
sb.Append(string.Format("orgid:(\"{0}\")", _arcGisPortal.ArcGISPortalInfo.Id));
}
var searchParams = new SearchParameters(sb.ToString())
{
Limit = 20,
SortField = "avgrating",
SortOrder = QuerySortOrder.Descending,
};
//search for items
var result = await _arcGisPortal.SearchItemsAsync(searchParams);
//rate the result items
foreach (var item in result.Results.Where(x => x.TypeKeywords.Contains("Offline")))
{
try
{
var webMap = await WebMap.FromPortalItemAsync(item);
bool isEditable = false;
bool isSyncable = false;
if (webMap.OperationalLayers.Count > 0)
{
foreach (var operationalLayer in webMap.OperationalLayers)
{
if (!operationalLayer.Url.Contains("FeatureServer")) continue;
var featureLayer = new FeatureLayer(new Uri(operationalLayer.Url));
await featureLayer.InitializeAsync();
var serviceFeatureTable = featureLayer.FeatureTable as ServiceFeatureTable;
var capabilities = serviceFeatureTable.ServiceInfo.Capabilities;
foreach (var capability in capabilities)
{
if (capability == "Editing")
{
isEditable = true;
}
if (capability == "Sync")
{
isSyncable = true;
}
}
if (isEditable)
{
var arcGisPortalWebMapItem = new ArcGisPortalWebMapItem(item, webMap, isEditable, isSyncable);
ArcGisPortalWebMapListBoxItems.Add(new ArcGisPortalWebMapListBoxItem(arcGisPortalWebMapItem, LoadWebMapCommand, CreateOfflineMapCommand));
break;
}
}
}
}
catch
{
}
}
}
finally
{
IsBusy = false;
}
}