// Perform identify when the map is tapped
        private async void mapView1_Tap(object sender, MapViewInputEventArgs e)
        {
            if (m_mapView == null)
                m_mapView = (MapView)sender;
            // Clear any previously displayed results
            clearResults();

            // Get the point that was tapped and show it on the map
            
            GraphicsLayer identifyPointLayer = m_mapView.Map.Layers["IdentifyPointLayer"] as GraphicsLayer;
            identifyPointLayer.Graphics.Add(new Graphic() { Geometry = e.Location });

            // Show activity
            progress.Visibility = Visibility.Visible;

            // Perform the identify operation
            List<DataItem> results = await doIdentifyAsync(e.Location);

            // Hide the activity indicator
            progress.Visibility = Visibility.Collapsed;

            // Show the results
            ResultsListPicker.ItemsSource = results;
            if (results.Count > 0)
            {
                ResultsListPicker.Visibility = Visibility.Visible;
                ShowAttributesButton.Visibility = Visibility.Visible;
            }
        }
示例#2
0
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            if (MyMapView.Editor.IsActive)
            {
                return;
            }

            var             drawShape = (DrawShape)DrawShapes.SelectedItem;
            GraphicsOverlay graphicsOverlay;

            graphicsOverlay = drawShape == DrawShape.Point ? MyMapView.GraphicsOverlays["PointGraphicsOverlay"] as GraphicsOverlay :
                              ((drawShape == DrawShape.Polyline || drawShape == DrawShape.Freehand || drawShape == DrawShape.LineSegment) ?
                               MyMapView.GraphicsOverlays["PolylineGraphicsOverlay"] as GraphicsOverlay : MyMapView.GraphicsOverlays["PolygonGraphicsOverlay"] as GraphicsOverlay);


            var graphic = await graphicsOverlay.HitTestAsync(MyMapView, e.Position);

            if (graphic != null)
            {
                //Clear previous selection
                foreach (GraphicsOverlay gOLay in MyMapView.GraphicsOverlays)
                {
                    gOLay.ClearSelection();
                }

                //Cancel editing if started
                if (MyMapView.Editor.Cancel.CanExecute(null))
                {
                    MyMapView.Editor.Cancel.Execute(null);
                }

                _editGraphic            = graphic;
                _editGraphic.IsSelected = true;
            }
        }
        private void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                _graphicsOverlay.Graphics.Clear();

                var point  = e.Location;
                var buffer = GeometryEngine.GeodesicBuffer(
                    GeometryEngine.NormalizeCentralMeridian(point),                     //Normalize in case we we're too far west/east of the world bounds
                    500, LinearUnits.Miles);

                var pointGraphic = new Graphic {
                    Geometry = point, Symbol = _pinSymbol
                };
                _graphicsOverlay.Graphics.Add(pointGraphic);

                var bufferGraphic = new Graphic {
                    Geometry = buffer, Symbol = _bufferSymbol
                };
                _graphicsOverlay.Graphics.Add(bufferGraphic);
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
        }
        void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                _graphicsOverlay.Graphics.Clear();

                var pointGeom  = e.Location;
                var bufferGeom = GeometryEngine.Buffer(pointGeom, 5 * milesToMetersConversion);

                //show geometries on map
                if (_graphicsOverlay != null)
                {
                    var pointGraphic = new Graphic {
                        Geometry = pointGeom, Symbol = _pms
                    };
                    _graphicsOverlay.Graphics.Add(pointGraphic);

                    var bufferGraphic = new Graphic {
                        Geometry = bufferGeom, Symbol = _sfs
                    };
                    _graphicsOverlay.Graphics.Add(bufferGraphic);
                }
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Geometry Engine Failed!").ShowAsync();
            }
        }
示例#5
0
        public override async void MapViewTapped(MapView mapView, MapViewInputEventArgs e, bool drawing)
        {
            if (!drawing)
            {
                var graphic = await GraphicsLayer.HitTestAsync(mapView, e.Position);

                if (graphic != null)
                {
                    OnItemTapped(int.Parse($"{graphic.Attributes[CURR_GEO]}"));
                }
                return;
            }

            MapPoint newPoint = (MapPoint)GeometryEngine.Project(e.Location, SpatialReferences.Wgs84);

            if (_drawPointList.Count == 0)
            {
                AddGraphic(newPoint, DRAFT, MapShapeLayer.GetSymbol(GeoMarkerType.Point, GeoStatus.Hilight));
            }
            else
            {
                Polyline line = new Polyline(new MapPoint[] { _drawPointList.Last(), newPoint });
                AddGraphic(line, DRAFT, MapShapeLayer.GetSymbol(GeoMarkerType.Line, GeoStatus.Hilight));
            }

            _drawPointList.Add(newPoint);
        }
        // On tap, either get related records for the tapped well or find nearby wells if no well was tapped
        private async void mapView1_Tap(object sender, MapViewInputEventArgs e)
        {
            // Show busy UI
            BusyVisibility = Visibility.Visible;

            // Get the map
            if (m_mapView == null)
                m_mapView = (MapView)sender;
                      

            // Create graphic and add to tap points
            var g = new Graphic() { Geometry = e.Location };
            TapPoints.Add(g);

            // Buffer graphic by 100 meters, create graphic with buffer, add to buffers
            var buffer = GeometryEngine.Buffer(g.Geometry, 100);
            Buffers.Add(new Graphic() { Geometry = buffer });

            // Find intersecting parcels and show them on the map
            var result = await doQuery(buffer);
            if (result != null && result.FeatureSet != null && result.FeatureSet.Features.Count > 0)
            {
                // Instead of adding parcels one-by-one, update the Parcels collection all at once to
                // allow the map to render the new features in one rendering pass.
                Parcels = new ObservableCollection<Graphic>(Parcels.Union(result.FeatureSet.Features));
            }

            // Hide busy UI
            BusyVisibility = Visibility.Collapsed;
        }
        private void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                graphicsLayer.Graphics.Clear();

                // Convert screen point to map point
                var point = e.Location;
                var buffer = GeometryEngine.Buffer(point, 5 * MILES_TO_METERS);

                //show geometries on map
                if (graphicsLayer != null)
                {
                    var pointGraphic = new Graphic { Geometry = point, Symbol = _pinSymbol };
                    graphicsLayer.Graphics.Add(pointGraphic);

                    var bufferGraphic = new Graphic { Geometry = buffer, Symbol = _bufferSymbol };
                    graphicsLayer.Graphics.Add(bufferGraphic);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Geometry Engine Failed!");
            }
        }
示例#8
0
        // Reverse geocode the clicked point and add a graphic and map tip to the map
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                _graphicsOverlay.Graphics.Add(new Graphic(e.Location));

                var result = await _locator.ReverseGeocodeAsync(e.Location, 50, SpatialReferences.Wgs84, CancellationToken.None);

                var overlay = new ContentControl()
                {
                    HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top
                };
                overlay.Template    = layoutGrid.Resources["MapTipTemplate"] as ControlTemplate;
                overlay.DataContext = result;
                MapView.SetViewOverlayAnchor(overlay, e.Location);
                MyMapView.Overlays.Items.Add(overlay);
            }
            catch (AggregateException aex)
            {
                var _x = new MessageDialog(aex.InnerExceptions[0].Message, "Reverse Geocode").ShowAsync();
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Reverse Geocode").ShowAsync();
            }
        }
示例#9
0
        private async void MapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                _layerList.ForEach(layer => SetAllNormal(layer));

                bool hit = false;
                foreach (var layer in _layerList.Where(x => x.GraphicsLayer.IsVisible))
                {
                    var graphic = await layer.GraphicsLayer.HitTestAsync(mapView, e.Position);

                    if (graphic != null)
                    {
                        HilightItem(graphic, layer);

                        attrList.ItemsSource = graphic.Attributes.Where(x => x.Key != KEY_CODE);
                        attrInfo.Visibility  = Visibility.Visible;
                        hit = true;
                        break;
                    }
                }

                if (!hit)
                {
                    attrInfo.Visibility = Visibility.Hidden;
                }
            }
            catch (Exception ex)
            {
                attrInfo.Visibility = Visibility.Hidden;
                _pop.ShowPopup("HitTest Error: " + ex.Message, "Hit Testing");
            }
        }
        // Select a set of wells near the click point
        private async void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                _wellsLayer.Graphics.Clear();
                wellsGrid.ItemsSource = relationshipsGrid.ItemsSource = null;

                QueryTask queryTask =
                    new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0"));

                Query query = new Query("1=1")
                {
                    Geometry = Expand(mapView.Extent, e.Location, 0.01),
                    ReturnGeometry = true,
                    OutSpatialReference = mapView.SpatialReference,
                    OutFields = OutFields.All
                };

                var result = await queryTask.ExecuteAsync(query);
                if (result.FeatureSet.Features != null && result.FeatureSet.Features.Count > 0)
                {
                    _wellsLayer.Graphics.AddRange(result.FeatureSet.Features);
                    wellsGrid.ItemsSource = result.FeatureSet.Features;
                    resultsPanel.Visibility = Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
                var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
        }
示例#11
0
        private void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                _graphicOverlay.Graphics.Clear();

                // Convert screen point to map point
                var point  = e.Location;
                var buffer = GeometryEngine.Buffer(point, 5 * MILES_TO_METERS);

                var bufferGraphic = new Graphic {
                    Geometry = buffer, Symbol = _bufferSymbol
                };
                _graphicOverlay.Graphics.Add(bufferGraphic);

                var pointGraphic = new Graphic {
                    Geometry = point, Symbol = _pinSymbol
                };
                _graphicOverlay.Graphics.Add(pointGraphic);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Geometry Engine Failed!");
            }
        }
        // Get user Stop points
        private void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            if (!_isMapReady)
                return;

            try
            {
                e.Handled = true;

                if (_directionsOverlay.Graphics.Count() > 0)
                {
                    panelResults.Visibility = Visibility.Collapsed;

                    _stopsOverlay.Graphics.Clear();
                    _routesOverlay.Graphics.Clear();
                    _directionsOverlay.GraphicsSource = null;
                }

                _stopsOverlay.Graphics.Add(new Graphic(e.Location));
            }
            catch (System.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");
            }
        }
示例#14
0
        private async void AssociatedObject_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            MapView                mapView    = sender as MapView;
            OverlayItemsControl    overlays   = mapView.Overlays;
            OverlayItemsCollection collection = overlays.Items;

            System.Windows.Controls.Border overlayControl = (System.Windows.Controls.Border)collection[0];

            // get the location tapped on the map
            var mapPoint = e.Location;

            // Get possible features and if none found, move to next layer
            FeatureLayer featureLayer = (FeatureLayer)mapView.Map.Layers[1];

            // Get possible features and if none found, move to next layer
            var foundFeatures = await featureLayer.HitTestAsync(mapView, new Rect(e.Position, new Size(10, 10)), 1);

            if (foundFeatures.Count() == 0)
            {
                return;
            }

            var feature = await featureLayer.FeatureTable.QueryAsync(foundFeatures[0]);

            overlayControl.DataContext = feature.Attributes;

            Esri.ArcGISRuntime.Controls.MapView.SetViewOverlayAnchor(overlayControl, mapPoint);
            overlayControl.Visibility = Visibility.Visible;
        }
        // Get user Stop points
        private void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            if (!_isMapReady)
                return;

            try
            {
                e.Handled = true;

                if (directionsLayer.Graphics.Count() > 0)
                {
                    panelResults.Visibility = Visibility.Collapsed;

                    stopsLayer.Graphics.Clear();
                    routesLayer.Graphics.Clear();
                    directionsLayer.GraphicsSource = null;
                }

                stopsLayer.Graphics.Add(new Graphic(e.Location));
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Sample Error");
            }
        }
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                var flayer = MyMapView.Map.Layers.OfType <FeatureLayer>().FirstOrDefault();
                if (flayer == null)
                {
                    return;
                }

                var rows = await flayer.HitTestAsync(MyMapView, e.Position);

                if (rows != null && rows.Length > 0)
                {
                    var features = await flayer.FeatureTable.QueryAsync(rows);

                    FeatureOverlay.DataContext = features.FirstOrDefault();
                    MapView.SetViewOverlayAnchor(FeatureOverlay, e.Location);
                }
                else
                {
                    FeatureOverlay.DataContext = null;
                }
            }
            catch (Exception ex)
            {
                FeatureOverlay.DataContext = null;
                MessageBox.Show("HitTest Error: " + ex.Message, "Sample Error");
            }
            finally
            {
                FeatureOverlay.Visibility = (FeatureOverlay.DataContext != null) ? Visibility.Visible : Visibility.Collapsed;
            }
        }
        /// <summary>
        /// Selects feature for editing and query its attachments.
        /// </summary>
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            var layer = MyMapView.Map.Layers["Incidents"] as FeatureLayer;
            var table = (ArcGISFeatureTable)layer.FeatureTable;

            layer.ClearSelection();
            SetAttachmentEditor();
            string message = null;

            try
            {
                // Performs hit test on layer to select feature.
                var features = await layer.HitTestAsync(MyMapView, e.Position);

                if (features == null || !features.Any())
                {
                    return;
                }
                var featureID = features.FirstOrDefault();
                layer.SelectFeatures(new long[] { featureID });
                await QueryAttachmentsAsync(featureID);
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            if (!string.IsNullOrWhiteSpace(message))
            {
                await new MessageDialog(message).ShowAsync();
            }
        }
        // Select a set of wells near the click point
        private async void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                wellsLayer.Graphics.Clear();
                wellsGrid.ItemsSource = relationshipsGrid.ItemsSource = null;

                QueryTask queryTask =
                    new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0"));

                Query query = new Query("1=1")
                {
                    Geometry            = Expand(mapView.Extent, e.Location, 0.01),
                    ReturnGeometry      = true,
                    OutSpatialReference = mapView.SpatialReference,
                    OutFields           = OutFields.All
                };

                var result = await queryTask.ExecuteAsync(query);

                if (result.FeatureSet.Features != null && result.FeatureSet.Features.Count > 0)
                {
                    wellsLayer.Graphics.AddRange(result.FeatureSet.Features);
                    wellsGrid.ItemsSource   = result.FeatureSet.Features;
                    resultsPanel.Visibility = Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Query Related Tables");
            }
        }
        // Perform identify when the map is tapped
        private async void mapView1_Tap(object sender, MapViewInputEventArgs e)
        {
            if (m_mapView == null)
            {
                m_mapView = (MapView)sender;
            }
            // Clear any previously displayed results
            clearResults();

            // Get the point that was tapped and show it on the map

            GraphicsLayer identifyPointLayer = m_mapView.Map.Layers["IdentifyPointLayer"] as GraphicsLayer;

            identifyPointLayer.Graphics.Add(new Graphic()
            {
                Geometry = e.Location
            });

            // Show activity
            progress.Visibility = Visibility.Visible;

            // Perform the identify operation
            List <DataItem> results = await doIdentifyAsync(e.Location);

            // Hide the activity indicator
            progress.Visibility = Visibility.Collapsed;

            // Show the results
            ResultsListPicker.ItemsSource = results;
            if (results.Count > 0)
            {
                ResultsListPicker.Visibility    = Visibility.Visible;
                ShowAttributesButton.Visibility = Visibility.Visible;
            }
        }
 /// <summary>
 /// Selects feature for editing.
 /// </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["Incidents"] as FeatureLayer;
     layer.ClearSelection();
     SetGeometryEditor();
     string message = null;
     try
     {
         // Performs hit test on layer to select feature.
         var features = await layer.HitTestAsync(MyMapView, e.Position);
         if (features == null || !features.Any())
             return;
         var featureID = features.FirstOrDefault();
         layer.SelectFeatures(new long[] { featureID });
         var feature = await layer.FeatureTable.QueryAsync(featureID);
         SetGeometryEditor(feature);
     }
     catch (Exception ex)
     {
         message = ex.Message;
     }
     if (!string.IsNullOrWhiteSpace(message))
         MessageBox.Show(message);
 }
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                var flayer = MyMapView.Map.Layers.OfType <FeatureLayer>().FirstOrDefault();
                if (flayer == null)
                {
                    return;
                }

                var rows = await flayer.HitTestAsync(MyMapView, e.Position);

                if (rows != null && rows.Length > 0)
                {
                    var features = await flayer.FeatureTable.QueryAsync(rows);

                    _featureOverlay.DataContext = features.First()
                                                  .Attributes.Select(kvp => new Tuple <string, object>(kvp.Key, kvp.Value));
                    MapView.SetViewOverlayAnchor(_featureOverlay, e.Location);
                }
                else
                {
                    _featureOverlay.DataContext = null;
                }
            }
            catch (Exception ex)
            {
                _featureOverlay.DataContext = null;
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
            finally
            {
                _featureOverlay.Visibility = (_featureOverlay.DataContext != null) ? Visibility.Visible : Visibility.Collapsed;
            }
        }
        private void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                // get the map overlay element by name
                var mapOverlay = this.FindName("mapTip") as FrameworkElement;
                // verify that the overlay was found
                if (mapOverlay == null)
                {
                    return;
                }

                mapOverlay.Visibility = System.Windows.Visibility.Collapsed;
                // get the location tapped on the map
                var mapPoint = e.Location;

                // get a buffer that is about 8 pixels in equivalent map distance
                var mapUnitsPerPixel = this.MyMapView.Extent.Width / this.MyMapView.ActualWidth;
                var bufferDist       = mapUnitsPerPixel * 8;
                var searchBuffer     = GeometryEngine.Buffer(mapPoint, bufferDist);

                if (UseOnlineDataOption.IsChecked == true)
                {
                    this.QueryOnline(mapOverlay, searchBuffer);
                }
                else
                {
                    this.QueryOffline(mapOverlay, searchBuffer);
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
示例#23
0
        /// <summary>
        /// 点击地图上 显示信息  如地震信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MyMapView_OnMapViewTapped(object sender, MapViewInputEventArgs e)
        {
            List <EarthquakeMsg> list = earthquake.EarthquakeMsgs;

            if (list == null)
            {
                return;
            }
            for (int i = 0; i < list.Count; i++)
            {
                var normalizedPoint = GeometryEngine.NormalizeCentralMeridian(e.Location);
                var projectedCenter = GeometryEngine.Project(normalizedPoint, SpatialReferences.Wgs84) as MapPoint;
                float.Parse(projectedCenter.X.ToString("0.00"));
                if (float.Parse(projectedCenter.X.ToString("0.00")) == list[i].longitude && float.Parse(projectedCenter.Y.ToString("0.00")) == list[i].latitude)
                {
                    double margin_left   = e.Position.X - this.earthquakeMsgDetailBorder.ActualWidth;
                    double margin_top    = e.Position.Y - this.earthquakeMsgDetailBorder.ActualHeight * 0.5;
                    double margin_right  = this.MyMapView.ActualWidth - margin_left - this.earthquakeMsgDetailBorder.ActualWidth;
                    double margin_bottom = this.MyMapView.ActualHeight - margin_top - this.earthquakeMsgDetailBorder.ActualHeight;
                    this.earthquakeMsgDetailBorder.Margin      = new Thickness(margin_left, margin_top, margin_right, margin_bottom);
                    this.earthquakeMsgDetailBorder.Visibility  = Visibility.Visible;
                    this.earthquakeMsgDetailBorder.DataContext = list[i];
                    return;
                }
            }
        }
示例#24
0
        public override async void MapViewTapped(MapView mapView, MapViewInputEventArgs e, bool drawing)
        {
            if (drawing)
            {
                DeleteGraphic(DRAFT);
            }

            ClearHilight();

            var graphic = await GraphicsLayer.HitTestAsync(mapView, e.Position);

            if (graphic != null)
            {
                if (_layerInfo.MarkerType == EventMarkerType.Proportional)
                {
                    (graphic.Symbol as SimpleMarkerSymbol).Color = DefaultSettings.GetColor(GeoStatus.Hilight);
                }
                else
                {
                    graphic.Symbol = _layerInfo.GetSymbol(GeoStatus.Hilight);
                }

                OnPointTapped(graphic.Geometry as MapPoint);
            }
            else
            {
                if (drawing)
                {
                    AddGraphic(e.Location, DRAFT, 1, GeoStatus.Hilight);
                }

                OnPointTapped((MapPoint)GeometryEngine.Project(e.Location, SpatialReferences.Wgs84));
            }
        }
        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();
            }
        }
		// Select a set of wells near the click point
		private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
		{
			try
			{
				_wellsOverlay.Graphics.Clear();
				wellsGrid.ItemsSource = relationshipsGrid.ItemsSource = null;

				QueryTask queryTask =
					new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0"));
				
				// Get current viewpoints extent from the MapView
				var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
				var viewpointExtent = currentViewpoint.TargetGeometry.Extent;

				Query query = new Query("1=1")
				{
					Geometry = Expand(viewpointExtent, e.Location, 0.01),
					ReturnGeometry = true,
					OutSpatialReference = MyMapView.SpatialReference,
					OutFields = OutFields.All
				};

				var result = await queryTask.ExecuteAsync(query);
				if (result.FeatureSet.Features != null && result.FeatureSet.Features.Count > 0)
				{
					_wellsOverlay.Graphics.AddRange(result.FeatureSet.Features.OfType<Graphic>());
					wellsGrid.ItemsSource = result.FeatureSet.Features;
					resultsPanel.Visibility = Visibility.Visible;
				}
			}
			catch (Exception ex)
			{
				var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
			}
		}
示例#27
0
        void mapView1_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            graphicsLayer.Graphics.Clear();
            try
            {
                var pointGeom = e.Location;

                var bufferGeom = GeometryEngine.Buffer(pointGeom, 5 * milesToMetersConversion);

                //show geometries on map
                if (graphicsLayer != null)
                {
                    var pointGraphic = new Graphic {
                        Geometry = pointGeom, Symbol = pms
                    };
                    graphicsLayer.Graphics.Add(pointGraphic);

                    var bufferGraphic = new Graphic {
                        Geometry = bufferGeom, Symbol = sfs
                    };
                    graphicsLayer.Graphics.Add(bufferGraphic);
                }
            }
            catch (Exception ex)
            {
                var dlg = new MessageDialog(ex.Message, "Geometry Engine Failed!");
                var _   = dlg.ShowAsync();
            }
        }
        // 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;
            }
        }
        // Handles click on the map to add a new bird sighting
        private void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                if (IsEditing)
                {
                    return;
                }

                if (LocalBirdsLayer == null)
                {
                    throw new Exception("No local geodatabase to edit.");
                }

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

                TapLocation = e.Location;
                IsEditing   = true;
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
示例#30
0
        public async void MyMapView_OnMapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                var normalizedPoint = GeometryEngine.NormalizeCentralMeridian(e.Location);
                var point           = GeometryEngine.Project(normalizedPoint, SpatialReferences.Wgs84) as MapPoint;

                if (isDelete)
                {
                    await DeleteScenic(e.Position);

                    //return;
                }
                if (isAdd)
                {
                    await AddScenic(point);

                    //return;
                }
                if (isAlter)
                {
                    await AlterScenic(e.Position);

                    //return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("HitTest Error: " + ex.Message, "Graphics Layer Hit Testing");
            }
        }
示例#31
0
        // Hittest the graphics layer and show the map tip for the selected graphic
        private async void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                graphicsLayer.ClearSelection();

                var graphic = await graphicsLayer.HitTestAsync(mapView, e.Position);

                if (graphic != null)
                {
                    graphic.IsSelected = true;
                    MapView.SetMapOverlayAnchor(mapTip, e.Location);
                    mapTip.DataContext = graphic;
                    mapTip.Visibility  = System.Windows.Visibility.Visible;
                }
                else
                {
                    mapTip.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
            catch
            {
                mapTip.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
示例#32
0
        // Use geoprocessor to call drive times gp service and display results
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                progress.Visibility = Visibility.Visible;

                _inputOverlay.Graphics.Clear();

                _inputOverlay.Graphics.Add(new Graphic(e.Location));

                var parameter = new GPInputParameter();
                parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Location", e.Location));
                parameter.GPParameters.Add(new GPString("Drive_Times", "1 2 3"));

                var result = await _gpTask.ExecuteAsync(parameter);

                var features = result.OutParameters.OfType <GPFeatureRecordSetLayer>().First().FeatureSet.Features;

                _resultsOverlay.Graphics.Clear();

                _resultsOverlay.Graphics.AddRange(features.Select((fs, idx) => new Graphic(fs.Geometry, _bufferSymbols[idx])));
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
            }
        }
示例#33
0
        private void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            var normalizedPoint = GeometryEngine.NormalizeCentralMeridian(e.Location);
            var projectedCenter = GeometryEngine.Project(normalizedPoint, SpatialReferences.Wgs84) as MapPoint;

            _clickOverlay.DataContext = projectedCenter;
        }
        // Use geoprocessor to call drive times gp service and display results
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                progress.Visibility = Visibility.Visible;

                _inputOverlay.Graphics.Clear();

                _inputOverlay.Graphics.Add(new Graphic(e.Location));

                var parameter = new GPInputParameter();
                parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Location", e.Location));
                parameter.GPParameters.Add(new GPString("Drive_Times", "1 2 3"));

                var result = await _gpTask.ExecuteAsync(parameter);

                var features = result.OutParameters.OfType<GPFeatureRecordSetLayer>().First().FeatureSet.Features;

                _resultsOverlay.Graphics.Clear();

                _resultsOverlay.Graphics.AddRange(features.Select((fs, idx) => new Graphic(fs.Geometry, _bufferSymbols[idx])));
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
            }
        }
        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");
            }
        }
示例#36
0
        private async void HandleMapViewTapped(object sender, MapViewInputEventArgs e)
        {
            if (layer == null || MapEditor.IsActive)
            {
                return;
            }
            var graphic = await layer.HitTestAsync(PmssMapView, e.Position);

            if (graphic != null)
            {
                if (graphic == CurrentGraphic)
                {
                    CurrentGraphic.IsSelected = false;
                    CurrentGraphic            = null;
                }
                else
                {
                    if (CurrentGraphic != null)
                    {
                        CurrentGraphic.IsSelected = false;
                    }
                    CurrentGraphic            = graphic;
                    CurrentGraphic.IsSelected = true;
                }
            }
        }
示例#37
0
        // Hittest the graphics layer and show the map tip for the selected graphic
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                _graphicsOverlay.ClearSelection();

                var graphic = await _graphicsOverlay.HitTestAsync(MyMapView, e.Position);

                if (graphic != null)
                {
                    graphic.IsSelected = true;
                    MapView.SetViewOverlayAnchor(_mapTip, e.Location);
                    _mapTip.DataContext = graphic;
                    _mapTip.Visibility  = Visibility.Visible;
                }
                else
                {
                    _mapTip.Visibility = Visibility.Collapsed;
                }
            }
            catch
            {
                _mapTip.Visibility = Visibility.Collapsed;
            }
        }
示例#38
0
        // On tap, get an input line and perform a buffer and clip operation
        private void mapView1_Tap(object sender, MapViewInputEventArgs e)
        {
            if (!m_firstPointAdded)
            {
                m_firstPointAdded = true;

                // Clear previous results
                ClipLines.Clear();
                ClippedCounties.Clear();
                if (m_clippedCountiesLayer != null)
                {
                    Layers.Remove(m_clippedCountiesLayer);
                    m_clippedCountiesLayer = null;
                }

                // Show instructions
                StatusText       = "Tap to add a point to the line.  Double-tap to finish.";
                StatusVisibility = Visibility.Visible;
            }
            else if (BusyVisibility == Visibility.Visible)
            {
                MessageBox.Show("Please wait until the current operation is complete.");
                return;
            }
        }
示例#39
0
        /// <summary>
        /// On each mouse click:
        /// - HitTest the feature layer
        /// - Query the feature table for the returned row
        /// - Set the result feature for the UI
        /// </summary>
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                var rows = await _featureLayer.HitTestAsync(MyMapView, e.Position);

                if (rows != null && rows.Length > 0)
                {
                    var features = await _featureLayer.FeatureTable.QueryAsync(rows);

                    var feature = features.FirstOrDefault();
                    if (feature != null)
                    {
                        listHitFeature.ItemsSource = feature.Attributes.Select(attr => new Tuple <string, string>(attr.Key, attr.Value.ToString()));
                    }
                    else
                    {
                        listHitFeature.ItemsSource = null;
                    }
                }
                else
                {
                    listHitFeature.ItemsSource = null;
                }
            }
            catch (Exception ex)
            {
                listHitFeature.ItemsSource = null;
                var _x = new MessageDialog("HitTest Error: " + ex.Message, "Feature Layer Hit Testing Sample").ShowAsync();
            }
        }
        // Get user Stop points
        private void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            if (!_isMapReady)
            {
                return;
            }

            try
            {
                e.Handled = true;

                if (_directionsOverlay.Graphics.Count() > 0)
                {
                    panelResults.Visibility = Visibility.Collapsed;

                    _stopsOverlay.Graphics.Clear();
                    _routesOverlay.Graphics.Clear();
                    _directionsOverlay.GraphicsSource = null;
                }

                _stopsOverlay.Graphics.Add(new Graphic(e.Location));
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Sample 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();
			}
		}
        void mapView1_MapViewTapped(object sender, MapViewInputEventArgs e)
        {           
            graphicsLayer.Graphics.Clear();
            try
            {
                
                var pointGeom = e.Location;

                var bufferGeom = GeometryEngine.Buffer(pointGeom, 5 * milesToMetersConversion);

                //show geometries on map
                if (graphicsLayer != null)
                {
                    var pointGraphic = new Graphic { Geometry = pointGeom, Symbol = pms };
                    graphicsLayer.Graphics.Add(pointGraphic);

                    var bufferGraphic = new Graphic { Geometry = bufferGeom, Symbol = sfs };
                    graphicsLayer.Graphics.Add(bufferGraphic);
                }
            }
            catch (Exception ex)
            {
                var dlg = new MessageDialog(ex.Message, "Geometry Engine Failed!");
				var _ = dlg.ShowAsync();
            }
        }
示例#43
0
        private async void HandleMapViewTapped(object sender, MapViewInputEventArgs e)
        {
            if (layer == null)
            {
                return;
            }
            var graphic = await layer.HitTestAsync(mapView, e.Position);

            if (graphic != null)
            {
                string stationId   = graphic.Attributes[HydrologicAttributes.Stationid].ToString();
                string stationName = graphic.Attributes[HydrologicAttributes.Name].ToString();
                string type        = graphic.Attributes[HydrologicAttributes.Type].ToString();
                string l           = graphic.Attributes[HydrologicAttributes.L].ToString();
                try
                {
                    double dl = double.Parse(l);
                    if (!(dl > 0))
                    {
                        l = "NAN";
                    }
                }
                catch (Exception)
                {
                    l = "NAN";
                }

                string q = graphic.Attributes[HydrologicAttributes.Q].ToString();
                try
                {
                    double dq = double.Parse(q);
                    if (!(dq > 0))
                    {
                        q = "NAN";
                    }
                }
                catch (Exception)
                {
                    q = "NAN";
                }
                string wl = graphic.Attributes[HydrologicAttributes.Wl1].ToString();
                try
                {
                    double dwl = double.Parse(wl);
                    if (!(dwl > 0))
                    {
                        wl = "NAN";
                    }
                }
                catch (Exception)
                {
                    wl = "NAN";
                }
                string time = graphic.Attributes[HydrologicAttributes.Time].ToString();

                WindowMapTrigger wd = new WindowMapTrigger(stationId, stationName, type, l, q, wl, time);
                wd.Show();
            }
        }
        private void mapView1_Tap(object sender, MapViewInputEventArgs e)
        {
          

            // Create graphic
            Graphic g = new Graphic() { Geometry = e.Location };

            // Get layer and add point to it
            mapview1.Map.Layers.OfType<GraphicsLayer>().First().Graphics.Add(g);
        }
        // Use geoprocessor to call drive times gp service and display results
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
               
                progress.Visibility = Visibility.Visible;

                // If the _gpTask has completed successfully (or before it is run the first time), the _cancellationTokenSource is set to null. 
                // If it has not completed and the map is clicked/tapped again, set the _cancellationTokenSource to cancel the initial task. 
                if (_cancellationTokenSource != null)
                {
                    _cancellationTokenSource.Cancel(); // Cancel previous operation
                }

                _cancellationTokenSource = new CancellationTokenSource();

                _inputOverlay.Graphics.Clear();
                _resultsOverlay.Graphics.Clear();

                _inputOverlay.Graphics.Add(new Graphic(e.Location));

                var parameter = new GPInputParameter();
                parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Location", e.Location));
                parameter.GPParameters.Add(new GPString("Drive_Times", "1 2 3"));

                var result = await _gpTask.ExecuteAsync(parameter, _cancellationTokenSource.Token);

                _cancellationTokenSource = null; // null out to show there are no pending operations

                if (result != null)
                {
                    var features = result.OutParameters.OfType<GPFeatureRecordSetLayer>().First().FeatureSet.Features;
                    _resultsOverlay.Graphics.AddRange(features.Select((fs, idx) => new Graphic(fs.Geometry, _bufferSymbols[idx])));
                }
            }
            catch (OperationCanceledException)
            {
                // Catch this exception because it is expected (when task cancellation is successful).
                // Catching it here prevents the message from being propagated to a MessageBox. 

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Sample Error");
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
            }
        }
		private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
		{
			// Convert screen point to map point
			var mapPoint = MyMapView.ScreenToLocation(e.Position);
			var layer = MyMapView.Map.Layers["InputLayer"] as GraphicsLayer;
			layer.Graphics.Clear();
			layer.Graphics.Add(new Graphic() { Geometry = mapPoint });

			string error = null;
			Geoprocessor task = new Geoprocessor(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network/ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons"));

			var parameter = new GPInputParameter();

			parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Location", mapPoint));
			parameter.GPParameters.Add(new GPString("Drive_Times", "1 2 3"));

			try
			{
				var result = await task.ExecuteAsync(parameter);
				var r = MyMapView.Map.Layers["ResultLayer"] as GraphicsLayer;
				r.Graphics.Clear();
				foreach (GPParameter gpParameter in result.OutParameters)
				{
					if (gpParameter is GPFeatureRecordSetLayer)
					{
						GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
						List<Esri.ArcGISRuntime.Symbology.Symbol> bufferSymbols = new List<Esri.ArcGISRuntime.Symbology.Symbol>(
							  new Esri.ArcGISRuntime.Symbology.Symbol[] { LayoutRoot.Resources["FillSymbol1"] as Esri.ArcGISRuntime.Symbology.Symbol, 
								  LayoutRoot.Resources["FillSymbol2"] as Esri.ArcGISRuntime.Symbology.Symbol, 
								  LayoutRoot.Resources["FillSymbol3"] as Esri.ArcGISRuntime.Symbology.Symbol });

						int count = 0;
						foreach (Graphic graphic in gpLayer.FeatureSet.Features)
						{
							graphic.Symbol = bufferSymbols[count];
							graphic.Attributes.Add("Info", String.Format("{0} minute buffer ", 3 - count));
							r.Graphics.Add(graphic);
							count++;
						}
					}
				}
			}
			catch (Exception ex)
			{
				error = "Geoprocessor service failed: " + ex.Message;
			}
			if (error != null)
				await new MessageDialog(error).ShowAsync();
		}
		/// <summary>
		/// Selects feature and checks whether update or delete is allowed.
		/// </summary>
		private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
		{
			// Ignore tap events while in edit mode so we do not interfere with add point.
			if (MyMapView.Editor.IsActive)
				return;
			var layer = MyMapView.Map.Layers["Marine"] as FeatureLayer;
			var table = (ArcGISFeatureTable)layer.FeatureTable;
			layer.ClearSelection();

			// Service metadata includes edit fields which can be used
			// to check ownership and/or tracking the last edit made.
			if (table.ServiceInfo == null || table.ServiceInfo.EditFieldsInfo == null)
				return;
			var creatorField = table.ServiceInfo.EditFieldsInfo.CreatorField;
			if (string.IsNullOrWhiteSpace(creatorField))
				return;

			string message = null;
			try
			{
				// Performs hit test on layer to select feature.
				var features = await layer.HitTestAsync(MyMapView, e.Position);
				if (features == null || !features.Any())
					return;
				var featureID = features.FirstOrDefault();
				layer.SelectFeatures(new long[] { featureID });
				var feature = (GeodatabaseFeature)await layer.FeatureTable.QueryAsync(featureID);

				// Displays feature attributes and editing restrictions.
				if (feature.Attributes.ContainsKey(table.ObjectIDField))
					message += string.Format("[{0}] : {1}\n", table.ObjectIDField, feature.Attributes[table.ObjectIDField]);
				if (feature.Attributes.ContainsKey(creatorField))
					message += string.Format("[{0}] : {1}\n", creatorField, feature.Attributes[creatorField]);
				// Checks whether service allows current user to add/update/delete attachment of feature.
				message += string.Format("Attachments\n\tCanAdd - {0}\n\tCanUpdate - {1}\n\tCanDelete - {2}\n",
					table.CanAddAttachment(feature), table.CanUpdateAttachment(feature), table.CanDeleteAttachment(feature));
				// Checks whether service allows current user to update feature's geometry or attributes; and delete feature.
				message += string.Format("Feature\n\tCanUpdateGeometry - {0}\n\tCanUpdate - {1}\n\tCanDelete - {2}\n",
					table.CanUpdateGeometry(feature), table.CanUpdateFeature(feature), table.CanDeleteFeature(feature));
			}
			catch (Exception ex)
			{
				message = ex.Message;
			}
			if (!string.IsNullOrWhiteSpace(message))
				await new MessageDialog(message).ShowAsync();
		}
        // Hit Test the graphics layer by single point
        private async void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                var graphics = await graphicsLayer.HitTestAsync(mapView, e.Position, MAX_GRAPHICS);

                string results = "Hit: ";
                if (graphics == null || graphics.Count() == 0)
                    results += "None";
                else
                    results += string.Join(", ", graphics.Select(g => g.Attributes["ID"].ToString()).ToArray());
                txtResults.Text = results;
            }
            catch (Exception ex)
            {
                MessageBox.Show("HitTest Error: " + ex.Message, "Graphics Layer Hit Testing");
            }
        }
		/// <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);
        }
        /// <summary>
        /// On each mouse click:
        /// - HitTest the feature layer
        /// - Query the feature table for the returned row
        /// - Set the result feature for the UI
        /// </summary>
		private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
				var rows = await cities.HitTestAsync(MyMapView, e.Position);
                if (rows != null && rows.Length > 0)
                {
                    var features = await cities.FeatureTable.QueryAsync(rows);
                    ResultFeature = features.FirstOrDefault();
                }
                else
                    ResultFeature = null;
            }
            catch (Exception ex)
            {
                ResultFeature = null;
                MessageBox.Show("HitTest Error: " + ex.Message, "Feature Layer Hit Testing Sample");
            }
        }
		/// <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();
		}
        /// <summary>
        /// On each mouse click:
        /// - HitTest the feature layer
        /// - Query the feature table for the returned row
        /// - Set the result feature for the UI
        /// </summary>
		private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
				var rows = await _featureLayer.HitTestAsync(MyMapView, e.Position);
                if (rows != null && rows.Length > 0)
                {
                    // Forcing query to be executed against local cache
                    var features = await (_featureLayer.FeatureTable as ServiceFeatureTable).QueryAsync(rows, true);

                    ResultFeature = features.FirstOrDefault();
                }
                else
                    ResultFeature = null;
            }
            catch (Exception ex)
            {
                ResultFeature = null;
                MessageBox.Show("HitTest Error: " + ex.Message, "Feature Layer Hit Testing Sample");
            }
        }
        /// <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);
        }
        // Hittest the graphics layer and show the map tip for the selected graphic
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
				_graphicsOverlay.ClearSelection();

				var graphic = await _graphicsOverlay.HitTestAsync(MyMapView, e.Position);
                if (graphic != null)
                {
                    graphic.IsSelected = true;
					MapView.SetViewOverlayAnchor(mapTip, e.Location);
					_mapTip.DataContext = graphic;
					_mapTip.Visibility = System.Windows.Visibility.Visible;
                }
                else
					_mapTip.Visibility = System.Windows.Visibility.Collapsed;
            }
            catch
            {
				_mapTip.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
        private void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                _graphicsOverlay.Graphics.Clear();

                var point = e.Location;
                var buffer = GeometryEngine.GeodesicBuffer(
                    GeometryEngine.NormalizeCentralMeridian(point), //Normalize in case we we're too far west/east of the world bounds
                    500, LinearUnits.Miles);

                var pointGraphic = new Graphic { Geometry = point, Symbol = _pinSymbol };
                _graphicsOverlay.Graphics.Add(pointGraphic);

                var bufferGraphic = new Graphic { Geometry = buffer, Symbol = _bufferSymbol };
                _graphicsOverlay.Graphics.Add(bufferGraphic);
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
        }
		/// <summary>
		/// On each mouse click:
		/// - HitTest the feature layer
		/// - Query the feature table for the returned row
		/// - Set the result feature for the UI
		/// </summary>
		private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
		{
			try
			{
				var rows = await _featureLayer.HitTestAsync(MyMapView, e.Position);
				if (rows != null && rows.Length > 0)
				{
					var features = await _featureLayer.FeatureTable.QueryAsync(rows);
					var feature = features.FirstOrDefault();
					if (feature != null)
						listHitFeature.ItemsSource = feature.Attributes.Select(attr => new Tuple<string, string>(attr.Key, attr.Value.ToString()));
					else
						listHitFeature.ItemsSource = null;
				}
				else
					listHitFeature.ItemsSource = null;
			}
			catch (Exception ex)
			{
				listHitFeature.ItemsSource = null;
				var _x = new MessageDialog("HitTest Error: " + ex.Message, "Feature Layer Hit Testing Sample").ShowAsync();
			}
		}
        // Get user Stop points
        private void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                e.Handled = true;

                if (_directionsOverlay.Graphics.Count() > 0)
                {
                    panelResults.Visibility = Visibility.Collapsed;

                    _stopsOverlay.Graphics.Clear();
                    _routesOverlay.Graphics.Clear();
                    _directionsOverlay.GraphicsSource = null;
                }

                var graphicIdx = _stopsOverlay.Graphics.Count + 1;
                _stopsOverlay.Graphics.Add(CreateStopGraphic(e.Location, graphicIdx));
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
        }
        // Reverse geocode the clicked point and add a graphic and map tip to the map
        private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            try
            {
                _graphicsOverlay.Graphics.Add(new Graphic(e.Location));

                var result = await _locator.ReverseGeocodeAsync(e.Location, 50, SpatialReferences.Wgs84, CancellationToken.None);

                var overlay = new ContentControl() { HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top };
                overlay.Template = layoutGrid.Resources["MapTipTemplate"] as ControlTemplate;
                overlay.DataContext = result;
				MapView.SetViewOverlayAnchor(overlay, e.Location);
                MyMapView.Overlays.Items.Add(overlay);
            }
            catch (AggregateException aex)
            {
                var _x = new MessageDialog(aex.InnerExceptions[0].Message, "Reverse Geocode").ShowAsync();
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Reverse Geocode").ShowAsync();
            }
        }
		/// <summary>
		/// Selects feature for editing.
		/// </summary>
		private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
		{
			var layer = MyMapView.Map.Layers["Incidents"] as FeatureLayer;
			layer.ClearSelection();
			SetAttributeEditor();
			string message = null;
			try
			{
				// Performs hit test on layer to select feature.
				var features = await layer.HitTestAsync(MyMapView, e.Position);
				if (features == null || !features.Any())
					return;
				var featureID = features.FirstOrDefault();
				layer.SelectFeatures(new long[] { featureID });
				var feature = await layer.FeatureTable.QueryAsync(featureID);
				SetAttributeEditor(feature);
			}
			catch (Exception ex)
			{
				message = ex.Message;
			}
			if (!string.IsNullOrWhiteSpace(message))
				await new MessageDialog(message).ShowAsync();
		}