private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                _trafficOverlay.Visibility  = Visibility.Collapsed;
                _trafficOverlay.DataContext = null;

                var identifyTask = new IdentifyTask(new Uri(_trafficLayer.ServiceUri));
                // Get current viewpoints extent from the MapView
                var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
                var viewpointExtent  = currentViewpoint.TargetGeometry.Extent;

                IdentifyParameters identifyParams = new IdentifyParameters(e.Location, viewpointExtent, 5, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth)
                {
                    LayerIDs         = new int[] { 2, 3, 4 },
                    LayerOption      = LayerOption.Top,
                    SpatialReference = MyMapView.SpatialReference,
                };

                var result = await identifyTask.ExecuteAsync(identifyParams);

                if (result != null && result.Results != null && result.Results.Count > 0)
                {
                    _trafficOverlay.DataContext = result.Results.First();
                    _trafficOverlay.Visibility  = Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
        }
        private async void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                incidentOverlay.Visibility = Visibility.Collapsed;
                incidentOverlay.DataContext = null;

                var identifyTask = new IdentifyTask(new Uri(_trafficLayer.ServiceUri));

                IdentifyParameter identifyParams = new IdentifyParameter(e.Location, mapView.Extent, 5, (int)mapView.ActualHeight, (int)mapView.ActualWidth)
                {
                    LayerIDs = new int[] { 2, 3, 4 },
                    LayerOption = LayerOption.Top,
                    SpatialReference = mapView.SpatialReference,
                };

                var result = await identifyTask.ExecuteAsync(identifyParams);

                if (result != null && result.Results != null && result.Results.Count > 0)
                {
                    incidentOverlay.DataContext = result.Results.First();
                    incidentOverlay.Visibility = Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Identify Error");
            }
        }
        // Identify features at the click point
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                progress.Visibility = Visibility.Visible;
                resultsGrid.DataContext = null;

				GraphicsOverlay graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"];
				graphicsOverlay.Graphics.Clear();
				graphicsOverlay.Graphics.Add(new Graphic(e.Location));

                IdentifyParameters identifyParams = new IdentifyParameters(e.Location, MyMapView.Extent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth)
                {
                    LayerOption = LayerOption.Visible,
                    SpatialReference = MyMapView.SpatialReference,
                };

                IdentifyTask identifyTask = new IdentifyTask(
                    new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"));

                var result = await identifyTask.ExecuteAsync(identifyParams);

                resultsGrid.DataContext = result.Results;
                if (result != null && result.Results != null && result.Results.Count > 0)
                    titleComboBox.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Identify Sample");
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #4
0
        private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
                Geometry         = clickPoint,
                MapExtent        = MyMap.Extent,
                Width            = (int)MyMap.ActualWidth,
                Height           = (int)MyMap.ActualHeight,
                LayerOption      = LayerOption.visible,
                SpatialReference = MyMap.SpatialReference
            };



            //IdentifyTask identifyTask = new IdentifyTask("http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServer/");
            IdentifyTask identifyTask = new IdentifyTask(arcgisLayer.Url);


            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed           += IdentifyTask_Failed;
            identifyTask.ExecuteAsync(identifyParams);

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            graphicsLayer.ClearGraphics();
            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = clickPoint,
                Symbol   = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphicsLayer.Graphics.Add(graphic);
        }
        private async void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                incidentOverlay.Visibility  = Visibility.Collapsed;
                incidentOverlay.DataContext = null;

                var identifyTask = new IdentifyTask(new Uri(_trafficLayer.ServiceUri));

                IdentifyParameter identifyParams = new IdentifyParameter(e.Location, mapView.Extent, 5, (int)mapView.ActualHeight, (int)mapView.ActualWidth)
                {
                    LayerIDs         = new int[] { 2, 3, 4 },
                    LayerOption      = LayerOption.Top,
                    SpatialReference = mapView.SpatialReference,
                };

                var result = await identifyTask.ExecuteAsync(identifyParams);

                if (result != null && result.Results != null && result.Results.Count > 0)
                {
                    incidentOverlay.DataContext = result.Results.First();
                    incidentOverlay.Visibility  = Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Identify Error");
            }
        }
		private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
		{
			try
			{
				_trafficOverlay.Visibility = Visibility.Collapsed;
				_trafficOverlay.DataContext = null;

				var identifyTask = new IdentifyTask(new Uri(_trafficLayer.ServiceUri));
				// Get current viewpoints extent from the MapView
				var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
				var viewpointExtent = currentViewpoint.TargetGeometry.Extent;

				IdentifyParameters identifyParams = new IdentifyParameters(e.Location, viewpointExtent, 5, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth)
				{
					LayerIDs = new int[] { 2, 3, 4 },
					LayerOption = LayerOption.Top,
					SpatialReference = MyMapView.SpatialReference,
				};

				var result = await identifyTask.ExecuteAsync(identifyParams);

				if (result != null && result.Results != null && result.Results.Count > 0)
				{
					_trafficOverlay.DataContext = result.Results.First();
					_trafficOverlay.Visibility = Visibility.Visible;
				}
			}
			catch (Exception ex)
			{
				var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
			}
		}
Beispiel #7
0
        private void MyDrawObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs e)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.Geometry as MapPoint;

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
                SpatialReference = MyMap.SpatialReference,
                Geometry         = clickPoint,
                MapExtent        = MyMap.Extent,
                Width            = (int)MyMap.ActualWidth,
                Height           = (int)MyMap.ActualHeight,
                LayerOption      = LayerOption.visible
            };

            IdentifyTask identifyTask = new IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer");

            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed           += IdentifyTask_Failed;
            identifyTask.ExecuteAsync(identifyParams);

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            graphicsLayer.ClearGraphics();
            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = clickPoint,
                Symbol   = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphicsLayer.Graphics.Add(graphic);
        }
Beispiel #8
0
        private async Task RunIdentify(MapPoint mp)
        {
            // Get current viewpoints extent from the MapView
            var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
            var viewpointExtent  = currentViewpoint.TargetGeometry.Extent;
            IdentifyParameters identifyParams = new IdentifyParameters(mp, viewpointExtent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth)
            {
                LayerOption      = LayerOption.Visible,
                SpatialReference = MyMapView.SpatialReference,
            };

            IdentifyTask identifyTask = new IdentifyTask(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
                                                                 "Demographics/ESRI_Census_USA/MapServer"));

            progress.IsActive = true;

            try
            {
                TitleComboBox.ItemsSource = null;
                ResultsGrid.ItemsSource   = null;
                var result = await identifyTask.ExecuteAsync(identifyParams);

                GraphicsLayer graphicsLayer = MyMapView.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.Graphics.Clear();
                graphicsLayer.Graphics.Add(new Graphic()
                {
                    Geometry = mp
                });

                var _dataItems = new List <DataItem>();
                if (result != null && result.Results != null && result.Results.Count > 0)
                {
                    foreach (var r in result.Results)
                    {
                        Feature feature = r.Feature;
                        string  title   = r.Value.ToString() + " (" + r.LayerName + ")";
                        _dataItems.Add(new DataItem()
                        {
                            Title = title,
                            Data  = feature.Attributes
                        });
                    }
                }
                TitleComboBox.ItemsSource = _dataItems;
                if (_dataItems.Count > 0)
                {
                    TitleComboBox.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            finally
            {
                progress.IsActive = false;
            }
        }
Beispiel #9
0
        private async Task RunIdentify(MapPoint mp)
        {
            IdentifyParameters identifyParams = new IdentifyParameters(mp, mapView1.Extent, 2, (int)mapView1.ActualHeight, (int)mapView1.ActualWidth)
            {
                LayerOption      = LayerOption.Visible,
                SpatialReference = mapView1.SpatialReference,
            };

            IdentifyTask identifyTask = new IdentifyTask(new Uri("http://54.187.22.10:6080/arcgis/rest/services/" +
                                                                 "Resultados_presidenciales/MapServer"));

            progress.IsActive = true;

            try
            {
                TitleComboBox.ItemsSource = null;
                ResultsGrid.ItemsSource   = null;
                var result = await identifyTask.ExecuteAsync(identifyParams);

                GraphicsLayer graphicsLayer = mapView1.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.Graphics.Clear();
                graphicsLayer.Graphics.Add(new Graphic()
                {
                    Geometry = mp
                });

                var _dataItems = new List <DataItem>();
                if (result != null && result.Results != null && result.Results.Count > 0)
                {
                    foreach (var r in result.Results)
                    {
                        Feature feature = r.Feature;
                        string  title   = r.Value.ToString() + " (" + r.LayerName + ")";
                        _dataItems.Add(new DataItem()
                        {
                            Title = title,
                            Data  = feature.Attributes
                        });
                    }
                }
                TitleComboBox.ItemsSource = _dataItems;
                if (_dataItems.Count > 0)
                {
                    TitleComboBox.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            finally
            {
                progress.IsActive = false;
            }
        }
        /// <summary>
        /// Identifies feature to highlight.
        /// </summary>
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            // Ignore tap events while in edit mode so we do not interfere with edit geometry.
            var inEditMode = EditButton.IsEnabled;

            if (inEditMode)
            {
                return;
            }

            // Get current viewpoints extent from the MapView
            var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
            var viewpointExtent  = currentViewpoint.TargetGeometry.Extent;

            var layer     = MyMapView.Map.Layers["RecreationalArea"] as ArcGISDynamicMapServiceLayer;
            var task      = new IdentifyTask(new Uri(layer.ServiceUri));
            var mapPoint  = MyMapView.ScreenToLocation(e.Position);
            var parameter = new IdentifyParameters(mapPoint, viewpointExtent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth);

            // Clears map of any highlights.
            var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay;

            overlay.Graphics.Clear();

            SetGeometryEditor();

            string message = null;

            try
            {
                // Performs an identify and adds feature result as selected into overlay.
                var result = await task.ExecuteAsync(parameter);

                if (result == null || result.Results == null || result.Results.Count < 1)
                {
                    return;
                }
                var graphic = (Graphic)result.Results[0].Feature;
                graphic.IsSelected = true;
                overlay.Graphics.Add(graphic);

                // Prepares geometry editor.
                var featureID = Convert.ToInt64(graphic.Attributes["Objectid"], CultureInfo.InvariantCulture);
                SetGeometryEditor(featureID);
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            if (!string.IsNullOrWhiteSpace(message))
            {
                await new MessageDialog(message).ShowAsync();
            }
        }
        /// <summary>
        /// Identifies graphic to highlight and query its related records.
        /// </summary>
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            var layer    = MyMapView.Map.Layers["ServiceRequests"] as ArcGISDynamicMapServiceLayer;
            var task     = new IdentifyTask(new Uri(layer.ServiceUri));
            var mapPoint = MyMapView.ScreenToLocation(e.Position);

            // Get current viewpoints extent from the MapView
            var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
            var viewpointExtent  = currentViewpoint.TargetGeometry.Extent;

            var parameter = new IdentifyParameters(mapPoint, viewpointExtent, 5, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth);

            // Clears map of any highlights.
            var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay;

            overlay.Graphics.Clear();

            SetRelatedRecordEditor();

            string message = null;

            try
            {
                // Performs an identify and adds graphic result into overlay.
                var result = await task.ExecuteAsync(parameter);

                if (result == null || result.Results == null || result.Results.Count < 1)
                {
                    return;
                }
                var graphic = (Graphic)result.Results[0].Feature;
                overlay.Graphics.Add(graphic);

                // Prepares related records editor.
                var    featureID = Convert.ToInt64(graphic.Attributes["OBJECTID"], CultureInfo.InvariantCulture);
                string requestID = null;
                if (graphic.Attributes["Service Request ID"] != null)
                {
                    requestID = Convert.ToString(graphic.Attributes["Service Request ID"], CultureInfo.InvariantCulture);
                }
                SetRelatedRecordEditor(featureID, requestID);

                await QueryRelatedRecordsAsync();
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            if (!string.IsNullOrWhiteSpace(message))
            {
                MessageBox.Show(message);
            }
        }
		private async Task RunIdentify(MapPoint mp)
		{
			// Get current viewpoints extent from the MapView
			var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
			var viewpointExtent = currentViewpoint.TargetGeometry.Extent;
			IdentifyParameters identifyParams = new IdentifyParameters(mp, viewpointExtent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth)
			{
				LayerOption = LayerOption.Visible,
				SpatialReference = MyMapView.SpatialReference,
			};

			IdentifyTask identifyTask = new IdentifyTask(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
				"Demographics/ESRI_Census_USA/MapServer"));
			progress.IsActive = true;

			try
			{
				TitleComboBox.ItemsSource = null;
				ResultsGrid.ItemsSource = null;
				var result = await identifyTask.ExecuteAsync(identifyParams);

				GraphicsLayer graphicsLayer = MyMapView.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
				graphicsLayer.Graphics.Clear();
				graphicsLayer.Graphics.Add(new Graphic() { Geometry = mp });

				var _dataItems = new List<DataItem>();
				if (result != null && result.Results != null && result.Results.Count > 0)
				{
					foreach (var r in result.Results)
					{
						Feature feature = r.Feature;
						string title = r.Value.ToString() + " (" + r.LayerName + ")";
						_dataItems.Add(new DataItem()
						{
							Title = title,
							Data = feature.Attributes
						});
					}
				}
				TitleComboBox.ItemsSource = _dataItems;
				if (_dataItems.Count > 0)
					TitleComboBox.SelectedIndex = 0;
			}
			catch (Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(ex.Message);
			}
			finally
			{
				progress.IsActive = false;
			}
		}
Beispiel #13
0
        /// <summary>
        /// Identifies feature to highlight.
        /// </summary>
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            var layer    = MyMapView.Map.Layers["PoolPermit"] as ArcGISDynamicMapServiceLayer;
            var task     = new IdentifyTask(new Uri(layer.ServiceUri));
            var mapPoint = MyMapView.ScreenToLocation(e.Position);

            // Get current viewpoints extent from the MapView
            var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
            var viewpointExtent  = currentViewpoint.TargetGeometry.Extent;
            var parameter        = new IdentifyParameters(mapPoint, viewpointExtent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth);

            // Clears map of any highlights.
            var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay;

            overlay.Graphics.Clear();

            SetAttributeEditor();

            string message = null;

            try
            {
                // Performs an identify and adds feature result as selected into overlay.
                var result = await task.ExecuteAsync(parameter);

                if (result == null || result.Results == null || result.Results.Count < 1)
                {
                    return;
                }
                var graphic = (Graphic)result.Results[0].Feature;
                graphic.IsSelected = true;
                overlay.Graphics.Add(graphic);

                // Prepares attribute editor.
                var featureID = Convert.ToInt64(graphic.Attributes["OBJECTID"], CultureInfo.InvariantCulture);
                var hasPool   = Convert.ToString(graphic.Attributes["Has_Pool"], CultureInfo.InvariantCulture);
                if (choices == null)
                {
                    choices = await GetChoicesAsync();
                }
                SetAttributeEditor(featureID, hasPool);
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            if (!string.IsNullOrWhiteSpace(message))
            {
                await new MessageDialog(message).ShowAsync();
            }
        }
        private async Task RunIdentify(MapPoint mp)
        {
            IdentifyParameter identifyParams = new IdentifyParameter()
            {
                Geometry = mp,
                MapExtent = MyMap.Extent,
                Width = (int)MyMap.ActualWidth,
                Height = (int)MyMap.ActualHeight,
                LayerOption = LayerOption.Visible,
                SpatialReference = MyMap.SpatialReference,
                Tolerance = 2
            };

            IdentifyTask identifyTask = new IdentifyTask(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
                "Demographics/ESRI_Census_USA/MapServer"));
            progress.IsActive = true;

            try
            {
                var result = await identifyTask.ExecuteAsync(identifyParams);

                GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.Graphics.Clear();
                graphicsLayer.Graphics.Add(new Graphic() { Geometry = mp });

                var _dataItems = new List<DataItem>();
                if (result != null && result.Results != null && result.Results.Count > 0)
                {
                    foreach (var r in result.Results)
                    {
                        Graphic feature = r.Feature;
                        string title = r.Value.ToString() + " (" + r.LayerName + ")";
                        _dataItems.Add(new DataItem()
                        {
                            Title = title,
                            Data = feature.Attributes
                        });
                    }
                }
                TitleComboBox.ItemsSource = _dataItems;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            finally
            {
                progress.IsActive = false;
            }
        }
Beispiel #15
0
        /// <summary>
        /// Identifies feature to highlight.
        /// </summary>
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            // Ignore tap events while in edit mode so we do not interfere with edit geometry.
            if (MyMapView.Editor.IsActive)
            {
                return;
            }

            var layer     = MyMapView.Map.Layers["WildFire"] as ArcGISDynamicMapServiceLayer;
            var task      = new IdentifyTask(new Uri(layer.ServiceUri));
            var mapPoint  = MyMapView.ScreenToLocation(e.Position);
            var parameter = new IdentifyParameters(mapPoint, MyMapView.Extent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth);

            // Clears map of any highlights.
            var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay;

            overlay.Graphics.Clear();

            SetGeometryEditor();

            string message = null;

            try
            {
                // Performs an identify and adds feature result as selected into overlay.
                var result = await task.ExecuteAsync(parameter);

                if (result == null || result.Results == null || result.Results.Count < 1)
                {
                    return;
                }
                var graphic = (Graphic)result.Results[0].Feature;
                graphic.IsSelected = true;
                overlay.Graphics.Add(graphic);

                // Prepares geometry editor.
                var featureID = Convert.ToInt64(graphic.Attributes["OBJECTID"], CultureInfo.InvariantCulture);
                SetGeometryEditor(featureID);
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            if (!string.IsNullOrWhiteSpace(message))
            {
                MessageBox.Show(message);
            }
        }
		/// <summary>
		/// Identifies feature to highlight.
		/// </summary>
		private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
		{
			// Ignore tap events while in edit mode so we do not interfere with edit geometry.
			var inEditMode = EditButton.IsEnabled;
			if (inEditMode)
				return;

			// Get current viewpoints extent from the MapView
			var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
			var viewpointExtent = currentViewpoint.TargetGeometry.Extent;

			var layer = MyMapView.Map.Layers["RecreationalArea"] as ArcGISDynamicMapServiceLayer;
			var task = new IdentifyTask(new Uri(layer.ServiceUri));
			var mapPoint = MyMapView.ScreenToLocation(e.Position);
			var parameter = new IdentifyParameters(mapPoint, viewpointExtent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth);

			// Clears map of any highlights.
			var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay;
			overlay.Graphics.Clear();

			SetGeometryEditor();

			string message = null;
			try
			{
				// Performs an identify and adds feature result as selected into overlay.
				var result = await task.ExecuteAsync(parameter);
				if (result == null || result.Results == null || result.Results.Count < 1)
					return;
				var graphic = (Graphic)result.Results[0].Feature;
				graphic.IsSelected = true;
				overlay.Graphics.Add(graphic);

				// Prepares geometry editor.
				var featureID = Convert.ToInt64(graphic.Attributes["Objectid"], CultureInfo.InvariantCulture);
				SetGeometryEditor(featureID);
			}
			catch (Exception ex)
			{
				message = ex.Message;
			}
			if (!string.IsNullOrWhiteSpace(message))
				await new MessageDialog(message).ShowAsync();
		}
        /// <summary>
        /// Identifies graphic to highlight and query its related records.
        /// </summary>
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            var layer = MyMapView.Map.Layers["ServiceRequests"] as ArcGISDynamicMapServiceLayer;
            var task = new IdentifyTask(new Uri(layer.ServiceUri));
            var mapPoint = MyMapView.ScreenToLocation(e.Position);

            // Get current viewpoints extent from the MapView
            var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
            var viewpointExtent = currentViewpoint.TargetGeometry.Extent;

            var parameter = new IdentifyParameters(mapPoint, viewpointExtent, 5, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth);

            // Clears map of any highlights.
            var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay;
            overlay.Graphics.Clear();

            SetRelatedRecordEditor();

            string message = null;
            try
            {
                // Performs an identify and adds graphic result into overlay.
                var result = await task.ExecuteAsync(parameter);
                if (result == null || result.Results == null || result.Results.Count < 1)
                    return;
                var graphic = (Graphic)result.Results[0].Feature;
                overlay.Graphics.Add(graphic);

                // Prepares related records editor.
                var featureID = Convert.ToInt64(graphic.Attributes["OBJECTID"], CultureInfo.InvariantCulture);
                string requestID = null;
                if(graphic.Attributes["Service Request ID"] != null)
                     requestID = Convert.ToString(graphic.Attributes["Service Request ID"], CultureInfo.InvariantCulture);
                SetRelatedRecordEditor(featureID, requestID);

                await QueryRelatedRecordsAsync();
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            if (!string.IsNullOrWhiteSpace(message))
                MessageBox.Show(message);
        }
Beispiel #18
0
        /// <summary>
        /// constructor
        /// </summary>
        public VIdentify()
        {
            //dbgDialog.textBlock1.Text = "Identify log:\n";
            dbgResizable.textBlock1.Text = "Identify log:\n";

            DataItems = new ObservableCollection <DataItem>();
            //identifyDialog = new IdentifyWnd()
            //identifyDialog.Margin = new Thickness(10),
            identifyDialog.DataContext = DataItems;
            identifyDialog.app         = this;
            identifyDialog.Closed     += new EventHandler(identifyDialog_Closed);


            srvUrl       = "http://rngis.algis.com/ArcGIS/rest/services/SeismicNavigat/MapServer";       // "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer";
            identifyTask =
                new IdentifyTask(srvUrl);
            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed           += IdentifyTask_Failed;
        }         // public VIdentify()
Beispiel #19
0
        //async void AssociatedObject_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        //{
        //    MapView mapView = sender as MapView;
        //    var screenPoint = e.GetPosition(mapView);

        //    // Convert the screen point to a point in map coordinates
        //    var mapPoint = mapView.ScreenToLocation(screenPoint);

        //    // get the FeatureLayer
        //    FeatureLayer featureLayer = mapView.Map.Layers[1] as FeatureLayer;
        //    // Get the FeatureTable from the FeatureLayer.
        //    Esri.ArcGISRuntime.Data.FeatureTable featureTable = featureLayer.FeatureTable;

        //    // Translate the MapPoint into Microsoft Point object.
        //    System.Windows.Point windowsPoint = mapView.LocationToScreen(mapPoint);
        //    // get the Row IDs of the features that are hit
        //    long[] featureLayerRowIDs = await featureLayer.HitTestAsync(mapView, windowsPoint);

        //    if (featureLayerRowIDs.Length == 1)
        //    {

        //        // Cause the features in the FeatureLayer to highlight (cyan) in the Map.
        //        featureLayer.SelectFeatures(featureLayerRowIDs);

        //        // Perform a Query on the FeatureLayer.FeatureTable using the ObjectID of the feature tapped/clicked on in the map. Actually it is a List of ObjectID values
        //        // but since we are trying for an Identify type of operation we really only have one ObjectID in the list.
        //        IEnumerable<GeodatabaseFeature> geoDatabaseFeature = (IEnumerable<GeodatabaseFeature>)await featureTable.QueryAsync(featureLayerRowIDs);

        //        foreach (Esri.ArcGISRuntime.Data.GeodatabaseFeature oneGeoDatabaseFeature in geoDatabaseFeature)
        //        {
        //            // Get the desired Field attribute values from the GeodatabaseFeature.
        //            System.Collections.Generic.IDictionary<string, object> attributes = oneGeoDatabaseFeature.Attributes;

        //            object postID = attributes["POST_ID"];

        //            // Construct a StringBuilder to hold the text from the Field attributes.
        //            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
        //            stringBuilder.AppendLine("POST ID: " + postID.ToString());

        //            Messenger.Default.Send<NotificationMessage>(new NotificationMessage(stringBuilder.ToString()));
        //        }
        //    }
        //}

        async void AssociatedObject_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            MapView mapView     = sender as MapView;
            var     screenPoint = e.GetPosition(mapView);

            // Convert the screen point to a point in map coordinates
            var mapPoint = mapView.ScreenToLocation(screenPoint);

            // Create a new IdentifyTask pointing to the map service to identify (USA)
            var uri          = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer");
            var identifyTask = new IdentifyTask(uri);

            // Create variables to store identify parameter information
            //--current map extent (Envelope)
            var extent = mapView.Extent;
            //--tolerance, in pixels, for finding features
            var tolerance = 7;
            //--current height, in pixels, of the map control
            var height = (int)mapView.ActualHeight;
            //--current width, in pixels, of the map control
            var width = (int)mapView.ActualWidth;

            // Create a new IdentifyParameter; pass the variables above to the constructor
            var identifyParams = new Esri.ArcGISRuntime.Tasks.Query.IdentifyParameters(mapPoint, extent, tolerance, height, width);

            // Identify only the top most visible layer in the service
            identifyParams.LayerOption = LayerOption.Top;

            // Set the spatial reference to match with the map's
            identifyParams.SpatialReference = mapView.SpatialReference;

            // Execute the task and await the result
            IdentifyResult idResult = await identifyTask.ExecuteAsync(identifyParams);

            // See if a result was returned
            if (idResult != null && idResult.Results.Count > 0)
            {
                // Get the feature for the first result
                var topLayerFeature = idResult.Results[0].Feature as Graphic;

                // do something
            }
        }
Beispiel #20
0
        public Task <IdentifyResult> DoIdentify(string serviceId, string layers, MapPoint pt)
        {
            LayerObject lo = null;

            foreach (var t in ConfigUtil.DynamicLayer)
            {
                if (serviceId != t.Id)
                {
                    continue;
                }
                lo = t;
            }
            if (lo == null)
            {
                return(null);
            }

            //创建查询IdentifyTask
            IdentifyTask task = new IdentifyTask(lo.Uri);


            if (lo.Token != null)
            {
                task.Token = lo.Token;
            }

            //设置查询参数
            var queryPara = new IdentifyParameters(pt, Map.MapView.Extent, 7
                                                   , (int)Map.MapView.ActualHeight, (int)Map.MapView.ActualWidth)
            {
                LayerOption = LayerOption.Visible
            };

            var layerArr = layers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            var ids = (from layer in layerArr select lo.GetLayerId(layer) into layerId where layerId != null select(int) layerId).ToList();

            queryPara.LayerIDs = ids;

            queryPara.SpatialReference = Map.MapView.SpatialReference;
            return(task.ExecuteAsync(queryPara));
        }
		/// <summary>
		/// Identifies feature to highlight.
		/// </summary>
		private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
		{
			var layer = MyMapView.Map.Layers["PoolPermit"] as ArcGISDynamicMapServiceLayer;
			var task = new IdentifyTask(new Uri(layer.ServiceUri));
			var mapPoint = MyMapView.ScreenToLocation(e.Position);
            
            // Get current viewpoints extent from the MapView
            var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
            var viewpointExtent = currentViewpoint.TargetGeometry.Extent;
			var parameter = new IdentifyParameters(mapPoint, viewpointExtent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth);

			// Clears map of any highlights.
			var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay;
			overlay.Graphics.Clear();

			SetAttributeEditor();

			string message = null;
			try
			{
				// Performs an identify and adds feature result as selected into overlay.
				var result = await task.ExecuteAsync(parameter);
				if (result == null || result.Results == null || result.Results.Count < 1)
					return;
				var graphic = (Graphic)result.Results[0].Feature;
				graphic.IsSelected = true;
				overlay.Graphics.Add(graphic);

				// Prepares attribute editor.
				var featureID = Convert.ToInt64(graphic.Attributes["OBJECTID"], CultureInfo.InvariantCulture);
				var hasPool = Convert.ToString(graphic.Attributes["Has_Pool"], CultureInfo.InvariantCulture);
				if (choices == null)
					choices = await GetChoicesAsync();
				SetAttributeEditor(featureID, hasPool);
			}
			catch (Exception ex)
			{
				message = ex.Message;
			}
			if (!string.IsNullOrWhiteSpace(message))
				await new MessageDialog(message).ShowAsync();
		}
        // Performs the identify operation and returns the results as DataItems
        private async Task <List <DataItem> > doIdentifyAsync(MapPoint point)
        {
            // Initialize paraemters for the identify operation
            IdentifyParameter identifyParams = new IdentifyParameter(point, m_mapView.Extent, 2,
                                                                     (int)m_mapView.ActualHeight, (int)m_mapView.ActualWidth)
            {
                SpatialReference = m_mapView.SpatialReference,
                ReturnGeometry   = true
            };

            // Initialize the identify task with the service to identify features from
            IdentifyTask identifyTask = new IdentifyTask(new Uri(
                                                             "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"));
            var dataItems = new List <DataItem>();

            try
            {
                // Do the identify operation
                var result = await identifyTask.ExecuteAsync(identifyParams);

                // Create DataItems that encapsulate each result
                if (result != null && result.Results != null && result.Results.Count > 0)
                {
                    foreach (var r in result.Results)
                    {
                        dataItems.Add(new DataItem()
                        {
                            Title      = string.Format("{0} ({1})", r.Value, r.LayerName),
                            Attributes = r.Feature.Attributes,
                            Geometry   = r.Feature.Geometry
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            // Return the results as DataItems
            return(dataItems);
        }
Beispiel #23
0
        // Identify features at the click point
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                progress.Visibility     = Visibility.Visible;
                resultsGrid.DataContext = null;

                GraphicsOverlay graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"];
                graphicsOverlay.Graphics.Clear();
                graphicsOverlay.Graphics.Add(new Graphic(e.Location));

                // Get current viewpoints extent from the MapView
                var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
                var viewpointExtent  = currentViewpoint.TargetGeometry.Extent;

                IdentifyParameters identifyParams = new IdentifyParameters(e.Location, viewpointExtent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth)
                {
                    LayerOption      = LayerOption.Visible,
                    SpatialReference = MyMapView.SpatialReference,
                };

                IdentifyTask identifyTask = new IdentifyTask(
                    new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"));

                var result = await identifyTask.ExecuteAsync(identifyParams);

                resultsGrid.DataContext = result.Results;
                if (result != null && result.Results != null && result.Results.Count > 0)
                {
                    titleComboBox.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Identify Sample");
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #24
0
        private void DoIdentification(MapPoint point)
        {
            IdentifyParameters identifyParams = new IdentifyParameters();

            identifyParams.LayerOption      = (LayerOption)Enum.Parse(typeof(LayerOption), widgetConfig.IdentifyOption, true);
            identifyParams.Tolerance        = widgetConfig.Tolerance;
            identifyParams.MapExtent        = this.MapControl.Extent;
            identifyParams.Height           = (int)this.MapControl.ActualHeight;
            identifyParams.Width            = (int)this.MapControl.ActualWidth;
            identifyParams.SpatialReference = new SpatialReference(this.MapSRWKID);
            identifyParams.ReturnGeometry   = true;
            identifyParams.Geometry         = point;

            this.IsBusy = true;
            this.ClearGraphics(0);

            for (int i = 0; i < widgetConfig.IdentifyLayers.Length; i++)
            {
                LivingMapLayer livingMapConfig = GetLivingMapConfig(widgetConfig.IdentifyLayers[i].Title);

                if (livingMapConfig != null && !string.IsNullOrEmpty(livingMapConfig.RESTURL))
                {
                    identifyParams.LayerIds.Clear();

                    int[] doLayers = GetIdentifiableLayers(livingMapConfig.ID, widgetConfig.IdentifyLayers[i].LayerIDs);
                    foreach (int kk in doLayers)
                    {
                        identifyParams.LayerIds.Add(kk);
                    }

                    IdentifyTask identifyTask = new IdentifyTask(livingMapConfig.RESTURL);
                    identifyTask.ExecuteCompleted += new EventHandler <IdentifyEventArgs>(IdentifyTask_ExecuteCompleted);
                    identifyTask.Failed           += new EventHandler <TaskFailedEventArgs>(IdentifyTask_Failed);
                    identifyTask.Token             = (livingMapConfig.Token == null) ? "" : livingMapConfig.Token;
                    identifyTask.ProxyURL          = livingMapConfig.ProxyURL;
                    identifyTask.ExecuteAsync(identifyParams, livingMapConfig.Title);
                }
            }
        }
		private async void MyMapView_Tapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e)
		{
			try
			{
				progress.Visibility = Visibility.Visible;
				resultsGrid.DataContext = null;

				GraphicsOverlay graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"];
				graphicsOverlay.Graphics.Clear();
				graphicsOverlay.Graphics.Add(new Graphic(e.Location));

				// Get current viewpoints extent from the MapView
				var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
				var viewpointExtent = currentViewpoint.TargetGeometry.Extent;

				IdentifyParameters identifyParams = new IdentifyParameters(e.Location, viewpointExtent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth)
				{
					LayerOption = LayerOption.Visible,
					SpatialReference = MyMapView.SpatialReference,
				};

				IdentifyTask identifyTask = new IdentifyTask(
					new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"));

				var result = await identifyTask.ExecuteAsync(identifyParams);

				resultsGrid.DataContext = result.Results;
				if (result != null && result.Results != null && result.Results.Count > 0)
					titleComboBox.SelectedIndex = 0;
			}
			catch (Exception ex)
			{
				var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
			}
			finally
			{
				progress.Visibility = Visibility.Collapsed;
			}
		}
        /// <summary>
        /// Identifies feature to highlight.
        /// </summary>
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            // Ignore tap events while in edit mode so we do not interfere with edit geometry.
            if (MyMapView.Editor.IsActive)
                return;

            var layer = MyMapView.Map.Layers["WildFire"] as ArcGISDynamicMapServiceLayer;
            var task = new IdentifyTask(new Uri(layer.ServiceUri));
            var mapPoint = MyMapView.ScreenToLocation(e.Position);
            var parameter = new IdentifyParameters(mapPoint, MyMapView.Extent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth);

            // Clears map of any highlights.
            var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay;
            overlay.Graphics.Clear();

            SetGeometryEditor();

            string message = null;
            try
            {
                // Performs an identify and adds feature result as selected into overlay.
                var result = await task.ExecuteAsync(parameter);
                if (result == null || result.Results == null || result.Results.Count < 1)
                    return;
                var graphic = (Graphic)result.Results[0].Feature;
                graphic.IsSelected = true;
                overlay.Graphics.Add(graphic);

                // Prepares geometry editor.
                var featureID = Convert.ToInt64(graphic.Attributes["OBJECTID"], CultureInfo.InvariantCulture);
                SetGeometryEditor(featureID);
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            if (!string.IsNullOrWhiteSpace(message))
                MessageBox.Show(message);
        }
        private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
        {
            MapPoint mapPoint = e.MapPoint;

            if (_displayViewshedInfo && resultLayer != null && e.Gesture == GestureType.Tap)
            {
                ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
                {
                    Geometry         = mapPoint,
                    MapExtent        = MyMap.Extent,
                    Width            = (int)MyMap.ActualWidth,
                    Height           = (int)MyMap.ActualHeight,
                    LayerOption      = LayerOption.visible,
                    SpatialReference = MyMap.SpatialReference
                };

                IdentifyTask identifyTask = new IdentifyTask(resultLayer.Url);
                identifyTask.ExecuteCompleted += (s, ie) =>
                {
                    if (ie.IdentifyResults.Count > 0)
                    {
                        foreach (var identifyresult in ie.IdentifyResults)
                        {
                            if (identifyresult.LayerId == 1)
                            {
                                Graphic g = identifyresult.Feature;
                                MyInfoWindow.Anchor  = e.MapPoint;
                                MyInfoWindow.Content = g.Attributes;
                                MyInfoWindow.IsOpen  = true;
                                break;
                            }
                        }
                    }
                };
                identifyTask.ExecuteAsync(identifyParams);
            }
        }
        private async void MyMapView_Tapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e)
        {
            try
            {
                progress.Visibility     = Visibility.Visible;
                resultsGrid.DataContext = null;

                GraphicsOverlay graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"];
                graphicsOverlay.Graphics.Clear();
                graphicsOverlay.Graphics.Add(new Graphic(e.Location));

                IdentifyParameters identifyParams = new IdentifyParameters(e.Location, MyMapView.Extent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth)
                {
                    LayerOption      = LayerOption.Visible,
                    SpatialReference = MyMapView.SpatialReference,
                };

                IdentifyTask identifyTask = new IdentifyTask(
                    new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"));

                var result = await identifyTask.ExecuteAsync(identifyParams);

                resultsGrid.DataContext = result.Results;
                if (result != null && result.Results != null && result.Results.Count > 0)
                {
                    titleComboBox.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #29
0
        // Identify features at the click point
        private async void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                progress.Visibility     = Visibility.Visible;
                resultsGrid.DataContext = null;

                graphicsLayer.Graphics.Clear();
                graphicsLayer.Graphics.Add(new Graphic(e.Location));

                IdentifyParameter identifyParams = new IdentifyParameter(e.Location, mapView.Extent, 2, (int)mapView.ActualHeight, (int)mapView.ActualWidth)
                {
                    LayerOption      = LayerOption.Visible,
                    SpatialReference = mapView.SpatialReference,
                };

                IdentifyTask identifyTask = new IdentifyTask(
                    new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"));

                var result = await identifyTask.ExecuteAsync(identifyParams);

                resultsGrid.DataContext = result.Results;
                if (result != null && result.Results != null && result.Results.Count > 0)
                {
                    titleComboBox.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Identify Sample");
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
            }
        }
        private static async Task<KeyValuePair<Layer,IEnumerable<IdentifyFeature>>> IdentifyLayer(MapViewController controller, Layer layer, Point tapPoint, MapPoint mapPoint)
        {
            if (layer is ArcGISDynamicMapServiceLayer)
            {
                var dynamicLayer = ((ArcGISDynamicMapServiceLayer)layer);
                
                if (!dynamicLayer.ServiceInfo.Capabilities.Contains("Query"))                
                    return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, null);
                
                var identifyTask = new IdentifyTask(new Uri(dynamicLayer.ServiceUri, UriKind.Absolute));

				var resolution = controller.UnitsPerPixel;
				var center = controller.Extent.GetCenter();
				var extent = new Envelope(center.X - resolution * c_defaultTolerance, center.Y - resolution * c_defaultTolerance,
					center.X + resolution * c_defaultTolerance, center.Y + resolution * c_defaultTolerance, controller.SpatialReference);
                var identifyParameter = new IdentifyParameters(mapPoint, extent, c_defaultTolerance, c_defaultTolerance,
                    c_defaultTolerance, DisplayInformation.GetForCurrentView().LogicalDpi)
				{
                    LayerOption = LayerOption.Visible,
                    LayerTimeOptions = dynamicLayer.LayerTimeOptions,
                    LayerIDs = dynamicLayer.VisibleLayers,
                    DynamicLayerInfos = dynamicLayer.DynamicLayerInfos,
                    GeodatabaseVersion = dynamicLayer.GeodatabaseVersion,
                    TimeExtent = controller.TimeExtent,
                };
                var identifyItems = (await identifyTask.ExecuteAsync(identifyParameter)).Results;
                var identifyFeatures = new List<IdentifyFeature>();

                try
                {
                    var dict = new Dictionary<int, IReadOnlyList<FieldInfo>>();
                    foreach (var identifyItem in identifyItems)
                    {
                        IReadOnlyList<FieldInfo> fields;
                        if(dict.ContainsKey(identifyItem.LayerID))
                            fields = dict[identifyItem.LayerID];
                        else
                        {
                            fields = await GetFieldInfo(dynamicLayer, identifyItem);                            
                            dict[identifyItem.LayerID] = fields;
                        }                        
                        var identifyFeature = ReplaceAliasWithFieldName(identifyItem, fields);                        
                        identifyFeatures.Add(identifyFeature);
                    }

                }
                catch (Exception ex)
                {
                    
                    throw;
                }
                return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, identifyFeatures);
            }
            if (layer is ArcGISTiledMapServiceLayer)
            {
                var tiledlayer = ((ArcGISTiledMapServiceLayer) layer);
                if (!tiledlayer.ServiceInfo.Capabilities.Contains("Query"))
                    return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, null);

                var identifyTask = new IdentifyTask(new Uri(tiledlayer.ServiceUri, UriKind.Absolute));
				var resolution = controller.UnitsPerPixel;
				var center = controller.Extent.GetCenter();
				var extent = new Envelope(center.X - resolution * c_defaultTolerance, center.Y - resolution * c_defaultTolerance,
					center.X + resolution * c_defaultTolerance, center.Y + resolution * c_defaultTolerance, controller.SpatialReference);
                var identifyParameter = new IdentifyParameters(mapPoint, extent, c_defaultTolerance, c_defaultTolerance,
                    c_defaultTolerance, DisplayInformation.GetForCurrentView().LogicalDpi)
                {
                    LayerOption = LayerOption.Visible,                    
                    TimeExtent = controller.TimeExtent,
                };

                var identifyItems = (await identifyTask.ExecuteAsync(identifyParameter)).Results;
                
                var identifyFeatures = new List<IdentifyFeature>();
                var dict = new Dictionary<int, IReadOnlyList<FieldInfo>>();
                foreach (var identifyItem in identifyItems)
                {
                    IReadOnlyList<FieldInfo> fields;
                    if (dict.ContainsKey(identifyItem.LayerID))
                        fields = dict[identifyItem.LayerID];
                    else
                    {
                        fields = await GetFieldInfo(tiledlayer, identifyItem);
                        dict[identifyItem.LayerID] = fields;
                    }
                    var identifyFeature = ReplaceAliasWithFieldName(identifyItem, fields);
                    identifyFeatures.Add(identifyFeature);
                }                                           
                return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, identifyFeatures);
            }
            if (layer is FeatureLayer)
            {
                var featureLayer = ((FeatureLayer)layer);
                var featureIds = await controller.FeatureLayerHitTestAsync(featureLayer, tapPoint, 1000);
                IEnumerable<Feature> features = new List<Feature>();
                if (featureIds != null && featureIds.Any())
                    features = await featureLayer.FeatureTable.QueryAsync(featureIds);

                var schema = featureLayer.FeatureTable.Schema;
                IList<IdentifyFeature> displayFeatures = new List<IdentifyFeature>();
                foreach (var f in features)
                {
                    var objectIDFieldName = schema.Fields.FirstOrDefault(x => x.Type == FieldType.Oid).Name;
                    var objectIDFieldValue = f.Attributes[objectIDFieldName].ToString();
                    IdentifyItem identifyItem = new IdentifyItem(-1, featureLayer.DisplayName, objectIDFieldName, objectIDFieldValue, f);
                    IdentifyFeature identifyFeature = new IdentifyFeature(identifyItem, schema.Fields);
                    displayFeatures.Add(identifyFeature);
                }
                return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, displayFeatures);
            }
            if (layer is GraphicsLayer)
            {
                var graphicsLayer = ((GraphicsLayer) layer);
                var graphics = await controller.GraphicsLayerHitTestAsync(graphicsLayer, tapPoint, 1000);                
                return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, graphics.Select(f => new IdentifyFeature(new IdentifyItem(
                    -1, 
                    layer.DisplayName,
                    "",
                    "",
                    f
                    ))));
            }

            // Not supported or not implemented yet
            return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer,null);
        }
Beispiel #31
0
        private void myMap_MouseClick(object sender, Map.MouseEventArgs args)
        {
            if (activateIdentify == true)
            {

                GraphicsLayer graphicsLayer = myMap.Layers["identifyIconGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.ClearGraphics();
                ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
                {
                    Geometry = args.MapPoint,
                    Symbol = LayoutRoot.Resources["identifyLocationSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
                };
                // Add the identify graphic
                graphicsLayer.Graphics.Add(graphic);

                IdentifyTask identifyTask = new IdentifyTask("http://unibeast/ArcGIS/rest/services/InternetVector/MapServer");
                identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
                identifyTask.Failed += IdentifyTask_Failed;

                IdentifyParameters identifyParameters = new IdentifyParameters();
                // Search all layers
                identifyParameters.LayerOption = LayerOption.all;

                // Initialize extent of map width and height for identify parameters
                identifyParameters.MapExtent = myMap.Extent;
                identifyParameters.Width = (int)myMap.ActualWidth;
                identifyParameters.Height = (int)myMap.ActualHeight;

                // Identify the point clicked on the map
                identifyParameters.Geometry = args.MapPoint;

                // Execute the identify task
                identifyTask.ExecuteAsync(identifyParameters);
            }
        }
        // Perform Identify when the map is clicked.
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs args)
        {
            // Show an icon at the Identify location.
            GraphicsLayer graphicsLayer = MyMap.Layers["IdentifyIconGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();
            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = args.MapPoint,
                Symbol = LayoutRoot.Resources["IdentifyLocationSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphicsLayer.Graphics.Add(graphic);

            // Identify task initialization.
            IdentifyTask identifyTask = new IdentifyTask("http://maverick.arcgis.com/ArcGIS/rest/services/World_WGS84/MapServer/");
            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed += IdentifyTask_Failed;

            // Initialize Identify parameters. Specify search of all layers.
            IdentifyParameters identifyParameters = new IdentifyParameters();
            //identifyParameters.LayerOption = LayerOption.all;
            identifyParameters.LayerIds.AddRange(new int[] { 0, 1 });

            // Pass the current Map properties to Identify parameters.
            identifyParameters.MapExtent = MyMap.Extent;
            identifyParameters.Width = (int)MyMap.ActualWidth;
            identifyParameters.Height = (int)MyMap.ActualHeight;

            // Identify features at the click point.
            identifyParameters.Geometry = args.MapPoint;

            identifyTask.ExecuteAsync(identifyParameters);
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            MapPoint mapPoint = e.MapPoint;
              if (_displayViewshedInfo && resultLayer != null)
              {

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
              Geometry = mapPoint,
              MapExtent = MyMap.Extent,
              Width = (int)MyMap.ActualWidth,
              Height = (int)MyMap.ActualHeight,
              LayerOption = LayerOption.visible,
              SpatialReference = MyMap.SpatialReference
            };

            IdentifyTask identifyTask = new IdentifyTask(resultLayer.Url);
            identifyTask.ExecuteCompleted += (s, ie) =>
            {
              if (ie.IdentifyResults.Count > 0)
              {
            foreach (var identifyresult in ie.IdentifyResults)
            {
              if (identifyresult.LayerId == 1)
              {
                Graphic g = identifyresult.Feature;
                MyInfoWindow.Anchor = e.MapPoint;
                MyInfoWindow.Content = g.Attributes;
                MyInfoWindow.IsOpen = true;
                break;
              }
            }
              }
            };
            identifyTask.ExecuteAsync(identifyParams);
              }
              else
              {
            _geoprocessorTask.CancelAsync();

            graphicsLayer.ClearGraphics();

            mapPoint.SpatialReference = new SpatialReference(102100);

            Graphic graphic = new Graphic()
            {
              Symbol = LayoutRoot.Resources["StartMarkerSymbol"] as Symbol,
              Geometry = mapPoint
            };
            graphicsLayer.Graphics.Add(graphic);

            MyMap.Cursor = System.Windows.Input.Cursors.Wait;

            List<GPParameter> parameters = new List<GPParameter>();
            parameters.Add(new GPFeatureRecordSetLayer("Input_Features", mapPoint));
            parameters.Add(new GPString("Height", HeightTextBox.Text));
            parameters.Add(new GPLinearUnit("Distance", esriUnits.esriMiles, Convert.ToDouble(MilesTextBox.Text)));

            _geoprocessorTask.OutputSpatialReference = new SpatialReference(102100);
            _geoprocessorTask.SubmitJobAsync(parameters);
              }
        }
        private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
                Geometry = clickPoint,
                MapExtent = MyMap.Extent,
                Width = (int)MyMap.ActualWidth,
                Height = (int)MyMap.ActualHeight,
                LayerOption = LayerOption.visible,
                SpatialReference = MyMap.SpatialReference
            };

            IdentifyTask identifyTask = new IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
                "Demographics/ESRI_Census_USA/MapServer");
            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed += IdentifyTask_Failed;
            identifyTask.ExecuteAsync(identifyParams);

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();
            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = clickPoint,
                Symbol = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphicsLayer.Graphics.Add(graphic);
        }
        private void DoIdentify()
        {
            if (Map == null)
            {
                return;
            }

            if (PendingIdentifies > 0 && identifyTasks != null)
            {
                foreach (IdentifyTask task in identifyTasks)
                {
                    task.CancelAsync();
                }
            }
            identifyTasks = new List <IdentifyTask>();
            List <IdentifyParameters> parameters = new List <IdentifyParameters>();
            List <Layer> layers = new List <Layer>();
            List <GraphicsLayerResult> graphicsLayerResults = new List <GraphicsLayerResult>();

            identifyTaskResults = new List <object>();
            IdentifyTask identifyTask;

            _popupInfo = MapApplication.Current.GetPopup(null, null);

            // Watch for property changes on the view model. The one in particular that this event handler is interested
            // in is when the popupitem changes. When this happens we will want to then establish a new event handler for
            // when properties change of the popupitem. In particular, when the Graphic property changes so that we can
            // reconstruct the header value for the popup if the value that changed was the field used to display in the
            // header.
            _popupInfo.PropertyChanged += _popupInfo_PropertyChanged;

            for (int i = Map.Layers.Count - 1; i >= 0; i--)
            {
                Layer layer = Map.Layers[i];
                if (!ESRI.ArcGIS.Client.Extensibility.LayerProperties.GetIsPopupEnabled(layer))
                {
                    continue;
                }
                if (!layer.Visible)
                {
                    continue;
                }
                if (layer is ArcGISDynamicMapServiceLayer || layer is ArcGISTiledMapServiceLayer)
                {
                    Collection <int> layerIds = getIdentifyLayerIds(layer);

                    // If layer is a dynamic map service layer, get layer definitions
                    IEnumerable <LayerDefinition> layerDefinitions = null;
                    IEnumerable <TimeOption>      timeOptions      = null;
                    if (layer is ArcGISDynamicMapServiceLayer)
                    {
                        var dynamicLayer = (ArcGISDynamicMapServiceLayer)layer;
                        if (dynamicLayer.LayerDefinitions != null)
                        {
                            layerDefinitions = dynamicLayer.LayerDefinitions.Where(
                                l => layerIds.Contains(l.LayerID));
                        }

                        if (dynamicLayer.LayerTimeOptions != null)
                        {
                            timeOptions = dynamicLayer.LayerTimeOptions.Where(
                                to => layerIds.Contains(int.Parse(to.LayerId)));
                        }
                        else if (dynamicLayer.TimeExtent != null)
                        {
                            timeOptions = dynamicLayer.Layers.Select(l => new TimeOption()
                            {
                                LayerId = l.ID.ToString(),
                                UseTime = true
                            });
                        }
                    }

                    if ((layer.GetValue(ESRI.ArcGIS.Mapping.Core.LayerExtensions.LayerInfosProperty) as Collection <LayerInformation>)
                        == null) //require layer infos
                    {
                        continue;
                    }
                    if ((layerIds != null && layerIds.Count > 0))
                    {
                        identifyTask = new IdentifyTask(IdentifySupport.GetLayerUrl(layer));
                        identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
                        identifyTask.Failed           += IdentifyTask_Failed;

                        string proxy = IdentifySupport.GetLayerProxyUrl(layer);
                        if (!string.IsNullOrEmpty(proxy))
                        {
                            identifyTask.ProxyURL = proxy;
                        }

                        int width, height;
                        if (!int.TryParse(Map.ActualHeight.ToString(), out height))
                        {
                            height = 100;
                        }
                        if (!int.TryParse(Map.ActualWidth.ToString(), out width))
                        {
                            width = 100;
                        }
                        IdentifyParameters identifyParams = new IdentifyParameters()
                        {
                            Geometry         = clickPoint,
                            MapExtent        = Map.Extent,
                            SpatialReference = Map.SpatialReference,
                            LayerOption      = LayerOption.visible,
                            Width            = width,
                            Height           = height,
                            LayerDefinitions = layerDefinitions,
                            TimeExtent       = AssociatedObject.TimeExtent,
                            TimeOptions      = timeOptions
                        };
                        foreach (int item in layerIds)
                        {
                            identifyParams.LayerIds.Add(item);
                        }
                        identifyTasks.Add(identifyTask);
                        parameters.Add(identifyParams);
                        layers.Add(layer);
                    }
                }
                else if (layer is GraphicsLayer &&
                         ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetPopUpsOnClick(layer as GraphicsLayer))
                {
                    GraphicsLayer         graphicsLayer = layer as GraphicsLayer;
                    GeneralTransform      t             = GetTransformToRoot(Map);
                    IEnumerable <Graphic> selected      = Core.Utility.FindGraphicsInHostCoordinates(graphicsLayer, t.Transform(Map.MapToScreen(clickPoint)));
                    if (selected != null)
                    {
                        List <Graphic> results = new List <Graphic>(selected);
                        if (results.Count > 0)
                        {
                            graphicsLayerResults.Add(new GraphicsLayerResult()
                            {
                                Layer        = graphicsLayer,
                                Results      = results,
                                ClickedPoint = clickPoint
                            });
                        }
                    }
                }
            }
            PendingIdentifies = identifyTasks.Count + graphicsLayerResults.Count;
            if (PendingIdentifies > 0)
            {
                for (int i = 0; i < identifyTasks.Count; i++)
                {
                    identifyTasks[i].ExecuteAsync(parameters[i], new UserState()
                    {
                        ClickedPoint = clickPoint, Layer = layers[i]
                    });
                }
                for (int i = 0; i < graphicsLayerResults.Count; i++)
                {
                    reportResults(graphicsLayerResults[i]);
                }
            }
        }
Beispiel #36
0
        private static async Task <KeyValuePair <Layer, IEnumerable <IdentifyFeature> > > IdentifyLayer(MapViewController controller, Layer layer, Point tapPoint, MapPoint mapPoint)
        {
            if (layer is ArcGISDynamicMapServiceLayer)
            {
                var dynamicLayer = ((ArcGISDynamicMapServiceLayer)layer);

                if (!dynamicLayer.ServiceInfo.Capabilities.Contains("Query"))
                {
                    return(new KeyValuePair <Layer, IEnumerable <IdentifyFeature> >(layer, null));
                }

                var identifyTask = new IdentifyTask(new Uri(dynamicLayer.ServiceUri, UriKind.Absolute));

                var resolution = controller.UnitsPerPixel;
                var center     = controller.Extent.GetCenter();
                var extent     = new Envelope(center.X - resolution * c_defaultTolerance, center.Y - resolution * c_defaultTolerance,
                                              center.X + resolution * c_defaultTolerance, center.Y + resolution * c_defaultTolerance, controller.SpatialReference);
                var identifyParameter = new IdentifyParameters(mapPoint, extent, c_defaultTolerance, c_defaultTolerance,
                                                               c_defaultTolerance, DisplayInformation.GetForCurrentView().LogicalDpi)
                {
                    LayerOption        = LayerOption.Visible,
                    LayerTimeOptions   = dynamicLayer.LayerTimeOptions,
                    LayerIDs           = dynamicLayer.VisibleLayers,
                    DynamicLayerInfos  = dynamicLayer.DynamicLayerInfos,
                    GeodatabaseVersion = dynamicLayer.GeodatabaseVersion,
                    TimeExtent         = controller.TimeExtent,
                };
                var identifyItems    = (await identifyTask.ExecuteAsync(identifyParameter)).Results;
                var identifyFeatures = new List <IdentifyFeature>();

                try
                {
                    var dict = new Dictionary <int, IReadOnlyList <FieldInfo> >();
                    foreach (var identifyItem in identifyItems)
                    {
                        IReadOnlyList <FieldInfo> fields;
                        if (dict.ContainsKey(identifyItem.LayerID))
                        {
                            fields = dict[identifyItem.LayerID];
                        }
                        else
                        {
                            fields = await GetFieldInfo(dynamicLayer, identifyItem);

                            dict[identifyItem.LayerID] = fields;
                        }
                        var identifyFeature = ReplaceAliasWithFieldName(identifyItem, fields);
                        identifyFeatures.Add(identifyFeature);
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                return(new KeyValuePair <Layer, IEnumerable <IdentifyFeature> >(layer, identifyFeatures));
            }
            if (layer is ArcGISTiledMapServiceLayer)
            {
                var tiledlayer = ((ArcGISTiledMapServiceLayer)layer);
                if (!tiledlayer.ServiceInfo.Capabilities.Contains("Query"))
                {
                    return(new KeyValuePair <Layer, IEnumerable <IdentifyFeature> >(layer, null));
                }

                var identifyTask = new IdentifyTask(new Uri(tiledlayer.ServiceUri, UriKind.Absolute));
                var resolution   = controller.UnitsPerPixel;
                var center       = controller.Extent.GetCenter();
                var extent       = new Envelope(center.X - resolution * c_defaultTolerance, center.Y - resolution * c_defaultTolerance,
                                                center.X + resolution * c_defaultTolerance, center.Y + resolution * c_defaultTolerance, controller.SpatialReference);
                var identifyParameter = new IdentifyParameters(mapPoint, extent, c_defaultTolerance, c_defaultTolerance,
                                                               c_defaultTolerance, DisplayInformation.GetForCurrentView().LogicalDpi)
                {
                    LayerOption = LayerOption.Visible,
                    TimeExtent  = controller.TimeExtent,
                };

                var identifyItems = (await identifyTask.ExecuteAsync(identifyParameter)).Results;

                var identifyFeatures = new List <IdentifyFeature>();
                var dict             = new Dictionary <int, IReadOnlyList <FieldInfo> >();
                foreach (var identifyItem in identifyItems)
                {
                    IReadOnlyList <FieldInfo> fields;
                    if (dict.ContainsKey(identifyItem.LayerID))
                    {
                        fields = dict[identifyItem.LayerID];
                    }
                    else
                    {
                        fields = await GetFieldInfo(tiledlayer, identifyItem);

                        dict[identifyItem.LayerID] = fields;
                    }
                    var identifyFeature = ReplaceAliasWithFieldName(identifyItem, fields);
                    identifyFeatures.Add(identifyFeature);
                }
                return(new KeyValuePair <Layer, IEnumerable <IdentifyFeature> >(layer, identifyFeatures));
            }
            if (layer is FeatureLayer)
            {
                var featureLayer = ((FeatureLayer)layer);
                var featureIds   = await controller.FeatureLayerHitTestAsync(featureLayer, tapPoint, 1000);

                IEnumerable <Feature> features = new List <Feature>();
                if (featureIds != null && featureIds.Any())
                {
                    features = await featureLayer.FeatureTable.QueryAsync(featureIds);
                }

                var schema = featureLayer.FeatureTable.Schema;
                IList <IdentifyFeature> displayFeatures = new List <IdentifyFeature>();
                foreach (var f in features)
                {
                    var             objectIDFieldName  = schema.Fields.FirstOrDefault(x => x.Type == FieldType.Oid).Name;
                    var             objectIDFieldValue = f.Attributes[objectIDFieldName].ToString();
                    IdentifyItem    identifyItem       = new IdentifyItem(-1, featureLayer.DisplayName, objectIDFieldName, objectIDFieldValue, f);
                    IdentifyFeature identifyFeature    = new IdentifyFeature(identifyItem, schema.Fields);
                    displayFeatures.Add(identifyFeature);
                }
                return(new KeyValuePair <Layer, IEnumerable <IdentifyFeature> >(layer, displayFeatures));
            }
            if (layer is GraphicsLayer)
            {
                var graphicsLayer = ((GraphicsLayer)layer);
                var graphics      = await controller.GraphicsLayerHitTestAsync(graphicsLayer, tapPoint, 1000);

                return(new KeyValuePair <Layer, IEnumerable <IdentifyFeature> >(layer, graphics.Select(f => new IdentifyFeature(new IdentifyItem(
                                                                                                                                    -1,
                                                                                                                                    layer.DisplayName,
                                                                                                                                    "",
                                                                                                                                    "",
                                                                                                                                    f
                                                                                                                                    )))));
            }

            // Not supported or not implemented yet
            return(new KeyValuePair <Layer, IEnumerable <IdentifyFeature> >(layer, null));
        }
        public void IdentifyPoint(Map ParcelMap, ref Configuration config, ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint)
        {
            if (config.IdentifyURL == "")
            return;

              if (config.IdentifyLayerCount == 0)
            return;

              if (config.UseQueryIdentify)
              {
            _dataItems = new List<DataItem>();

            GeometryService geometryServicePointSnap = new GeometryService(config.GeometryServerUrl);
            if (geometryServicePointSnap == null)
              return;

            QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);

            geometryServicePointSnap.BufferCompleted += GeometryService_IdentifyPointBufferCompleted;
            geometryServicePointSnap.Failed += GeometryService_Failed;
            geometryServicePointSnap.CancelAsync();

            SimpleMarkerSymbol defaultSymbolMarker = new SimpleMarkerSymbol()
            {
              Color = System.Windows.Media.Brushes.Black, Size = 8,
              Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle
            };

            Graphic clickGraphic = new Graphic();
            clickGraphic.Symbol = defaultSymbolMarker as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = clickPoint;

            // Input spatial reference for buffer operation defined by first feature of input geometry array
            clickGraphic.Geometry.SpatialReference = ParcelMap.SpatialReference;

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
              BufferSpatialReference = ParcelMap.SpatialReference,
              OutSpatialReference = ParcelMap.SpatialReference,
              Unit = LinearUnit.Meter,
            };
            bufferParams.Distances.Add(config.SnapTolerance * config.SpatialReferenceUnitsPerMeter);
            bufferParams.Features.Add(clickGraphic);
            geometryServicePointSnap.BufferAsync(bufferParams, queryItem);
              }
              else
              {
            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
              Geometry = clickPoint,
              MapExtent = ParcelMap.Extent,
              Width = (int)ParcelMap.ActualWidth,
              Height = (int)ParcelMap.ActualHeight,
              LayerOption = LayerOption.visible,
              SpatialReference = ParcelMap.SpatialReference
            };

            // For performance, we allow certain layers to be only identified.
            if (config.IdentifyLayerIDs != null)
              foreach (int id in config.IdentifyLayerIDs)
            identifyParams.LayerIds.Add(id);

            IdentifyTask identifyTask = new IdentifyTask(config.IdentifyURL);
            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed += IdentifyTask_Failed;

            QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);
            identifyTask.ExecuteAsync(identifyParams, queryItem);
              }
        }
        private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
        {
            MapPoint mapPoint = e.MapPoint;
              if (_displayViewshedInfo && resultLayer != null && e.Gesture == GestureType.Tap)
              {

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
              Geometry = mapPoint,
              MapExtent = MyMap.Extent,
              Width = (int)MyMap.ActualWidth,
              Height = (int)MyMap.ActualHeight,
              LayerOption = LayerOption.visible,
              SpatialReference = MyMap.SpatialReference
            };

            IdentifyTask identifyTask = new IdentifyTask(resultLayer.Url);
            identifyTask.ExecuteCompleted += (s, ie) =>
            {
              if (ie.IdentifyResults.Count > 0)
              {
            foreach (var identifyresult in ie.IdentifyResults)
            {
              if (identifyresult.LayerId == 1)
              {
                Graphic g = identifyresult.Feature;
                MyInfoWindow.Anchor = e.MapPoint;
                MyInfoWindow.Content = g.Attributes;
                MyInfoWindow.IsOpen = true;
                break;
              }
            }
              }
            };
            identifyTask.ExecuteAsync(identifyParams);
              }
        }
Beispiel #39
0
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            MapPoint mapPoint = e.MapPoint;

            if (_displayViewshedInfo && resultLayer != null)
            {
                ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
                {
                    Geometry         = mapPoint,
                    MapExtent        = MyMap.Extent,
                    Width            = (int)MyMap.ActualWidth,
                    Height           = (int)MyMap.ActualHeight,
                    LayerOption      = LayerOption.visible,
                    SpatialReference = MyMap.SpatialReference
                };

                IdentifyTask identifyTask = new IdentifyTask(resultLayer.Url);
                identifyTask.ExecuteCompleted += (s, ie) =>
                {
                    if (ie.IdentifyResults.Count > 0)
                    {
                        foreach (var identifyresult in ie.IdentifyResults)
                        {
                            if (identifyresult.LayerId == 1)
                            {
                                Graphic g = identifyresult.Feature;
                                MyInfoWindow.Anchor  = e.MapPoint;
                                MyInfoWindow.Content = g.Attributes;
                                MyInfoWindow.IsOpen  = true;
                                break;
                            }
                        }
                    }
                };
                identifyTask.ExecuteAsync(identifyParams);
            }
            else
            {
                _geoprocessorTask.CancelAsync();

                graphicsLayer.Graphics.Clear();

                mapPoint.SpatialReference = new SpatialReference(102100);

                Graphic graphic = new Graphic()
                {
                    Symbol   = LayoutRoot.Resources["StartMarkerSymbol"] as Symbol,
                    Geometry = mapPoint
                };
                graphicsLayer.Graphics.Add(graphic);

                MyMap.Cursor = System.Windows.Input.Cursors.Wait;

                List <GPParameter> parameters = new List <GPParameter>();
                parameters.Add(new GPFeatureRecordSetLayer("Input_Features", mapPoint));
                parameters.Add(new GPString("Height", HeightTextBox.Text));
                parameters.Add(new GPLinearUnit("Distance", esriUnits.esriMiles, Convert.ToDouble(MilesTextBox.Text)));


                _geoprocessorTask.OutputSpatialReference = new SpatialReference(102100);
                _geoprocessorTask.SubmitJobAsync(parameters);
            }
        }
        public void IdentifyPoint(Map ParcelMap, ref Configuration config, ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint)
        {
            if (config.IdentifyURL == "")
            {
                return;
            }

            if (config.IdentifyLayerCount == 0)
            {
                return;
            }

            if (config.UseQueryIdentify)
            {
                _dataItems = new List <DataItem>();

                GeometryService geometryServicePointSnap = new GeometryService(config.GeometryServerUrl);
                if (geometryServicePointSnap == null)
                {
                    return;
                }

                QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);

                geometryServicePointSnap.BufferCompleted += GeometryService_IdentifyPointBufferCompleted;
                geometryServicePointSnap.Failed          += GeometryService_Failed;
                geometryServicePointSnap.CancelAsync();

                SimpleMarkerSymbol defaultSymbolMarker = new SimpleMarkerSymbol()
                {
                    Color = System.Windows.Media.Brushes.Black, Size = 8,
                    Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle
                };

                Graphic clickGraphic = new Graphic();
                clickGraphic.Symbol   = defaultSymbolMarker as ESRI.ArcGIS.Client.Symbols.Symbol;
                clickGraphic.Geometry = clickPoint;

                // Input spatial reference for buffer operation defined by first feature of input geometry array
                clickGraphic.Geometry.SpatialReference = ParcelMap.SpatialReference;

                // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
                ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
                {
                    BufferSpatialReference = ParcelMap.SpatialReference,
                    OutSpatialReference    = ParcelMap.SpatialReference,
                    Unit = LinearUnit.Meter,
                };
                bufferParams.Distances.Add(config.SnapTolerance * config.SpatialReferenceUnitsPerMeter);
                bufferParams.Features.Add(clickGraphic);
                geometryServicePointSnap.BufferAsync(bufferParams, queryItem);
            }
            else
            {
                ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
                {
                    Geometry         = clickPoint,
                    MapExtent        = ParcelMap.Extent,
                    Width            = (int)ParcelMap.ActualWidth,
                    Height           = (int)ParcelMap.ActualHeight,
                    LayerOption      = LayerOption.visible,
                    SpatialReference = ParcelMap.SpatialReference
                };

                // For performance, we allow certain layers to be only identified.
                if (config.IdentifyLayerIDs != null)
                {
                    foreach (int id in config.IdentifyLayerIDs)
                    {
                        identifyParams.LayerIds.Add(id);
                    }
                }

                IdentifyTask identifyTask = new IdentifyTask(config.IdentifyURL);
                identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
                identifyTask.Failed           += IdentifyTask_Failed;

                QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);
                identifyTask.ExecuteAsync(identifyParams, queryItem);
            }
        }
        // Performs the identify operation and returns the results as DataItems
        private async Task<List<DataItem>> doIdentifyAsync(MapPoint point)
        {
            // Initialize paraemters for the identify operation
            IdentifyParameter identifyParams = new IdentifyParameter(point, m_mapView.Extent, 2, 
                (int)m_mapView.ActualHeight, (int)m_mapView.ActualWidth)
            {
                SpatialReference = m_mapView.SpatialReference,
                ReturnGeometry = true
            };

            // Initialize the identify task with the service to identify features from
            IdentifyTask identifyTask = new IdentifyTask(new Uri(
                "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"));
            var dataItems = new List<DataItem>();

            try
            {
                // Do the identify operation
                var result = await identifyTask.ExecuteAsync(identifyParams);

                // Create DataItems that encapsulate each result
                if (result != null && result.Results != null && result.Results.Count > 0)
                {
                    foreach (var r in result.Results)
                    {
                        dataItems.Add(new DataItem()
                        {
                            Title = string.Format("{0} ({1})", r.Value, r.LayerName),
                            Attributes = r.Feature.Attributes,
                            Geometry = r.Feature.Geometry
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            // Return the results as DataItems
            return dataItems;
        }