当前位置: 首页>>代码示例>>C#>>正文


C# FeatureLayer.InitializeAsync方法代码示例

本文整理汇总了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");


            }
        }
开发者ID:gkelley-tngeo,项目名称:Test-Repo,代码行数:48,代码来源:MainWindow.xaml.cs

示例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");
            }
        }
开发者ID:mattkingit,项目名称:MyArcGIS_DotNet,代码行数:45,代码来源:MainWindow.xaml.cs

示例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;
			}
		}
开发者ID:renatewegener,项目名称:PTM-CollectorLight,代码行数:95,代码来源:ArcGisPortalWebMapItemsViewModel.cs


注:本文中的FeatureLayer.InitializeAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。