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


C# FeatureLayer.Initialize方法代码示例

本文整理汇总了C#中FeatureLayer.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# FeatureLayer.Initialize方法的具体用法?C# FeatureLayer.Initialize怎么用?C# FeatureLayer.Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FeatureLayer的用法示例。


在下文中一共展示了FeatureLayer.Initialize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SbAddClick

        private void SbAddClick(object sender, RoutedEventArgs e)
        {
            var l = ((FrameworkElement) sender).DataContext as StoredLayer;
            if (l == null) return;

            switch (l.Type)
            {
                case "Map Service":
                    var ml = new ArcGISImageServiceLayer();
                    

                    ml.Url = l.Id;
                    ml.ID = l.Title;
                    ml.Visible = true;
                    
                    var pts = AppStateSettings.Instance.ViewDef.FindOrCreateAcceleratedGroupLayer(l.Path);
                    pts.ChildLayers.Add(ml);
                    ml.Initialize();
                    
                    break;
                // FIXME TODO: Unreachable code
                    //break;
                case "Feature Service":
                    var fl = new FeatureLayer() {};

                    fl.Url = l.Id + @"/0";
                    fl.ID = l.Title;
                    fl.Visible = true;
                    fl.InitializationFailed += fl_InitializationFailed;
                    fl.Initialized += fl_Initialized;
                    fl.UpdateCompleted += fl_UpdateCompleted;
                    var pt = AppStateSettings.Instance.ViewDef.FindOrCreateAcceleratedGroupLayer(l.Path);
                    pt.ChildLayers.Add(fl);
                    fl.Initialize();
                    fl.Update();
                    break;
                case "wms":
                    var wl = new WmsLayer {
                                              SupportedSpatialReferenceIDs = new[] {102100},
                                              Visible = false
                                          };
                    wl.Visible = true;
                    wl.SkipGetCapabilities = false;
                    wl.Initialized += (st, es) => { wl.Layers = wl.LayerList.Select(k => k.Title).ToArray(); };
                    wl.Url = l.Id;
                    wl.ID = l.Title;
                    wl.Title = l.Title;

                    var p = AppStateSettings.Instance.ViewDef.FindOrCreateGroupLayer(l.Path);
                    p.ChildLayers.Add(wl);
                    wl.Initialize();

                    break;
            }
            AppStateSettings.Instance.ViewDef.StoredLayers.Add(l);
            AppStateSettings.Instance.ViewDef.StoredLayers.Save();
        }
开发者ID:TNOCS,项目名称:csTouch,代码行数:57,代码来源:NewLayerView.xaml.cs

示例2: QueryTask_ExecuteRelationshipQueryCompleted

        /// <summary>
        /// Handle successful query task and initializes the results layer
        /// </summary>
        private void QueryTask_ExecuteRelationshipQueryCompleted(object sender, RelationshipEventArgs e)
        {
            // Unhook the queryTask.ExecuteRelationshipQueryCompleted
            queryTask.ExecuteRelationshipQueryCompleted -= QueryTask_ExecuteRelationshipQueryCompleted;

            // queryResult used once the results layer is initialized
            queryResult = e.Result;

            if (queryResult.RelatedRecordsGroup.Count > 0)
            {

                string relatedTableID = SelectedRelationship.RelatedTableId.ToString();

                if (relatedTableID == null)
                {
                    relatedTableID = relatesLayer.LayerInfo.Relationships.First().RelatedTableId.ToString();
                }

                // Determine the url for the related table and use to populate the Url property of the new resultsLayer.
                string resultsUrl = relatesLayer.Url;

                resultsUrl = resultsUrl.Substring(0, resultsUrl.LastIndexOf('/') + 1);
                resultsUrl = resultsUrl.Insert(resultsUrl.Length, relatedTableID);


                // Create a FeatureLayer for the results based on the url of the related records. At this point, the feature layer will
                // retrieve all the graphics/info from the layer. In the resultsLayer_Initialized, we trim that down based on the Object id field.
                resultsLayer = new FeatureLayer()
                {
                    Url = resultsUrl,
                    ProxyUrl = relatesLayer.ProxyUrl
                };

                resultsLayer.OutFields.Add("*");

                // Initialize the resultsLayer to populate layer metadata (LayerInfo) so the OID field can be retrieved.
                resultsLayer.Initialized += resultsLayer_Initialized;
                resultsLayer.InitializationFailed += resultsLayer_InitializationFailed;
                resultsLayer.UpdateCompleted += resultsLayer_UpdateCompleted;

                resultsLayer.Initialize();

            }
            else
            {
                Grid infoWindowGrid = Utils.FindChildOfType<Grid>(popupWindow, 3);
                infoWindowGrid.Children.Remove(indicator);

                infoWindowGrid.Children.Add(NoRecordsFoundView);

                ((DelegateCommand)CloseNoRecordsView).RaiseCanExecuteChanged();
            }
        }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:56,代码来源:QueryRelatedViewModel.cs

示例3: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            AddRecordButton.IsEnabled = false;

            // Create the LocalFeatureService and set MaxRecords property
            _localFeatureService = new LocalFeatureService(@"..\Maps-and-Data\CitiesOverOneMillion.mpk")
            {
                MaxRecords = 100000,
            };

            // Register an event handler for the PropertyChanged Event
            _localFeatureService.PropertyChanged += (s, propertyChangedEventArgs) =>
            {
                // Get the property
                var property = _localFeatureService.GetType().GetProperty(propertyChangedEventArgs.PropertyName);

                // Get the Value
                var value = property.GetValue(_localFeatureService, null);

                if (value == null)
                    return;

                // Get the property type
                string varType = value.GetType().ToString();

                // Display the property info
                switch (varType)
                {
                    case "System.Collections.ObjectModel.ReadOnlyCollection`1[ESRI.ArcGIS.Client.Local.LayerDetails]":
                        statusDisplay.Items.Insert(0, propertyChangedEventArgs.PropertyName + ": " + _localFeatureService.FeatureLayers.Count.ToString());
                        break;
                    default:
                        statusDisplay.Items.Insert(0, propertyChangedEventArgs.PropertyName + ": " + value.ToString());
                        break;
                }

                // Display the error
                if (_localFeatureService.Error != null)
                    statusDisplay.Items.Insert(0, "Error: " + _localFeatureService.Error.Message);
            };

            // Start the LocalFeatureService
            _localFeatureService.StartAsync(x =>
            {
                // Create a new FeatureLayer (to contain the table)
                _featureLayerTable = new FeatureLayer()
                {
                    Url = _localFeatureService.UrlFeatureService + "/1",
                    ID = "EditTable",
                    DisableClientCaching = true,
                    AutoSave = false,
                    //Do not use ESRI.ArcGIS.Client.FeatureLayer.QueryMode.OnDemand
                    Mode = ESRI.ArcGIS.Client.FeatureLayer.QueryMode.Snapshot,
                    OutFields = new OutFields() { "*" },
                };

                /*
                * Register a series of inline event handlers...
                */

                // Register an handler for the InitializationFailed event
                _featureLayerTable.InitializationFailed += (s, e) =>
                {
                    statusDisplay.Items.Insert(0, _featureLayerTable.InitializationFailure.Message);
                };

                // Register a handler for the Initialized event (raised by an explicit Initialize call)
                _featureLayerTable.Initialized += (s, e) =>
                {
                    statusDisplay.Items.Insert(0, "FeatureLayer Initialized Event Raised");
                    statusDisplay.Items.Insert(0, "FeatureLayer contains: " + _featureLayerTable.Graphics.Count.ToString() + " features"); //This will be 0.
                    _featureLayerTable.Update();
                };

                // Register a handler for the UpdateCompleted event (raised by an explicit Update call)
                _featureLayerTable.UpdateCompleted += (senderObj, eventArgs) =>
                {
                    statusDisplay.Items.Insert(0, "FeatureLayer UpdateCompleted Event Raised");
                    statusDisplay.Items.Insert(0, "FeatureLayer contains: " + _featureLayerTable.Graphics.Count.ToString() + " features"); //This will be the total number (n) graphic features (up to service query limit).
                    AddRecordButton.IsEnabled = true;
                };

                // Register a handler for the Begin Save Edits event (raised by the explicit Save Edits call)
                _featureLayerTable.BeginSaveEdits += (s1, beginEditEventArgs) =>
                {
                    statusDisplay.Items.Insert(0, "FeatureLayer BeginSaveEdits Event Raised");
                };

                // Register a handler for the End Save Edits event (raised by server response)
                _featureLayerTable.EndSaveEdits += (s2, endEditEventArgs) =>
                {
                    statusDisplay.Items.Insert(0, "## Edit Successful ##");
                    // Edit was successful - call Update to trigger a refresh and display the number of features
                    _featureLayerTable.Update();
                };

                // Register a handler for the Save Edits Failed event (raised by server response)
                _featureLayerTable.SaveEditsFailed += (s3, taskFailedEventArgs) =>
//.........这里部分代码省略.........
开发者ID:GlenDhu,项目名称:tips-and-tricks-wpf,代码行数:101,代码来源:MainWindow.xaml.cs

示例4: OnConnect

		/// <summary>
		/// Connects to the service to retrieve fields information.
		/// </summary>
		/// <param name="commandParameter"></param>
		private void OnConnect(object commandParameter)
		{
			if (!CanConnect(commandParameter)) return;
			try
			{
                bool savedConfiguration = commandParameter as string == Constants.SAVED_CONFIGURATION;
                if (!savedConfiguration)
    				Reset();

				IsBusy = true;

				initializedAction = (f) =>
				{
					IsConnected = true;
					if (f == null || f.LayerInfo == null || f.LayerInfo.Fields == null)
						Error = new Exception(Resources.Strings.LayerInfoMissing);
					if (IsTable)
					{
						UseServiceRenderer = false;
						AutoPinResults = false;
						AutoZoomToResults = false;
					}
					OnPropertyChanged("QueryTitle");
					OnPropertyChanged("Fields");
					OnPropertyChanged("HasResults");
					OnPropertyChanged("IsTable");
					OnPropertyChanged("IsConnectionValid");
					AddChanged();

                    if (!savedConfiguration)
                        InitalizeOutFields();
                    else
                        initializeExpressions();
				};

				var url = !ServiceUrl.StartsWith("http") ? string.Format("http://{0}", ServiceUrl) : ServiceUrl;

				resultLayer = new FeatureLayer()
				{
					DisableClientCaching = true,
					Url = url
				};
				if (UseProxy && !string.IsNullOrEmpty(ProxyUrl))
					resultLayer.ProxyUrl = ProxyUrl;

				// Subscribes to initialized event and initializes layer.
				resultLayer.InitializationFailed += ResultLayer_InitializationFailed;
				resultLayer.Initialized += ResultLayer_Initialized;

				resultLayer.Initialize();
			}
			catch (Exception ex)
			{
				IsConnected = true;
				IsBusy = false;
				if (ex is UriFormatException)
				{
					Error = new UriFormatException(string.Format(Resources.Strings.UriFormatError, ServiceUrl), ex);
				}
				else
				{
					Error = new Exception(string.Format(Resources.Strings.UnableToAccess, ServiceUrl), ex);
				}
			}
		}
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:69,代码来源:QueryViewModel.cs

示例5: OnExecute

		/// <summary>
		/// Executes the query on the feature or map service.
		/// </summary>
		/// <param name="commandParameter"></param>
		private void OnExecute(object commandParameter)
		{
			if (!CanExecute(commandParameter)) return;

			// Removes the result layer from map when not pinned.
			ClearResults();

			IsBusy = true;

			// Sets the initialize action which is executed after layer has initialized.
			initializedAction = (f) =>
			{
				if (f != null && f.LayerInfo != null)
				{
					IsBusy = true;

					// Updates renderer based on geometry type
					// when opting out of using service-defined renderer.
                    if (!UseServiceRenderer && !IsTable)
                        f.Renderer = new SimpleRenderer() { Symbol = GetSymbol(f.LayerInfo.GeometryType) };

                    if (IsTable) // hide tables from map contents
                        LayerProperties.SetIsVisibleInMapContents(f, false);

                    f.ID = Guid.NewGuid().ToString();
                    if (SetLayerNameAction != null)
                        SetLayerNameAction(f, QueryTitle);

					//  Add layer to map.
					if (AddLayerAction != null)
						AddLayerAction(resultLayer);

					// Subscribes and updates FeatureLayer to query the service.
					f.UpdateFailed += ResultLayer_UpdateFailed;
					f.UpdateCompleted += ResultLayer_UpdateCompleted;
					f.Update();
				}
			};

			var url = !ServiceUrl.StartsWith("http") ? string.Format("http://{0}", ServiceUrl) : ServiceUrl;
			// Creates a new result layer.
			resultLayer = new FeatureLayer()
			{
				DisableClientCaching = true,
				Url = url
			};
			if (UseProxy && !string.IsNullOrEmpty(ProxyUrl))
				resultLayer.ProxyUrl = ProxyUrl;
			
			// Updates FeatureLayer.OutFields with visible fields
			resultLayer.OutFields.AddRange(from f in OutFields where f.IsVisible select f.Name);

			// Updates FeatureLayer.Where clause with QueryExpressions
			if (QueryExpressions != null)
			{
				var whereClause = new StringBuilder();
				ExpressionViewModel previous = null;
				bool mustEnd = false;
				// Iterates through each expression determining its position in a group
				// and calls its ToString() method.
				for (int i = 0; i < QueryExpressions.Count; i++)
				{
					var current = QueryExpressions[i];
					ExpressionViewModel next = null;
					if (i + 1 < QueryExpressions.Count)
						next = QueryExpressions[i + 1];
					bool startOfGroup = previous == null ||
						(previous.GroupID != current.GroupID &&
						next != null && current.GroupID == next.GroupID);
					if (startOfGroup)
						mustEnd = true;
					bool endOfGroup = mustEnd &&
						(next == null || next.GroupID != current.GroupID);
					if (endOfGroup)
						mustEnd = false;
					if (current.HasValueSet)
						whereClause.Append(current.ToString(startOfGroup, endOfGroup));
					previous = current;
				}
				resultLayer.Where = whereClause.ToString();
			}

			// Subscribes to initialized event and initializes layer.
			resultLayer.InitializationFailed += ResultLayer_InitializationFailed;
			resultLayer.Initialized += ResultLayer_Initialized;
			resultLayer.Initialize();
		}
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:91,代码来源:QueryViewModel.cs


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