コード例 #1
0
        private async void myMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Identify the tapped graphics
            IdentifyGraphicsOverlayResult result = null;

            try
            {
                result = await _myMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, e.Position, 1, false);
            }
            catch (Exception ex)
            {
                new AlertDialog.Builder(this).SetMessage(ex.ToString()).SetTitle("Error").Show();
            }

            // Return if there are no results
            if (result == null || result.Graphics.Count < 1)
            {
                return;
            }

            // Get the first identified graphic
            Graphic identifiedGraphic = result.Graphics.First();

            // Clear any existing selection, then select the tapped graphic
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Perform the calculation and show the results
            _resultTextView.Text = GetOutputText(selectedGeometry);
        }
コード例 #2
0
        private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Identify the tapped graphics.
            IdentifyGraphicsOverlayResult result = null;

            try
            {
                result = await _myMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, e.Position, 1, false);
            }
            catch (Exception ex)
            {
                new UIAlertView("Error", ex.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }

            // Return if there are no results.
            if (result == null || result.Graphics.Count < 1)
            {
                return;
            }

            // Get the smallest identified graphic.
            Graphic identifiedGraphic = result.Graphics.OrderBy(graphic => GeometryEngine.Area(graphic.Geometry)).First();

            // Clear any existing selection, then select the tapped graphic.
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry.
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Perform the calculation and show the results.
            _resultTextView.Text = GetOutputText(selectedGeometry);
        }
コード例 #3
0
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            // Identify the tapped graphics
            IdentifyGraphicsOverlayResult result = null;

            try
            {
                result = await MyMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, e.Position, 1, false);
            }
            catch (Exception ex)
            {
                await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK");
            }

            // Return if there are no results
            if (result == null || result.Graphics.Count < 1)
            {
                return;
            }

            // Get the first identified graphic
            Graphic identifiedGraphic = result.Graphics.First();

            // Clear any existing selection, then select the tapped graphic
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Perform the calculation and show the results
            ResultTextbox.Text = GetOutputText(selectedGeometry);
        }
コード例 #4
0
        private async void MapViewTapped(object sender, GeoViewInputEventArgs geoViewInputEventArgs)
        {
            // Identify the tapped graphics
            IdentifyGraphicsOverlayResult result = null;

            try
            {
                result = await MyMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, geoViewInputEventArgs.Position, 1, false);
            }
            catch (Exception e)
            {
                await new MessageDialog(e.ToString(), "Error").ShowAsync();
            }

            // Return if there are no results
            if (result == null || result.Graphics.Count < 1)
            {
                return;
            }

            // Get the first identified graphic
            Graphic identifiedGraphic = result.Graphics.First();

            // Clear any existing selection, then select the tapped graphic
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Perform the calculation and show the results
            ResultTextbox.Text = GetOutputText(selectedGeometry);
        }
コード例 #5
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;
            }
        }
コード例 #6
0
        private async void MapViewTapped(object sender, GeoViewInputEventArgs geoViewInputEventArgs)
        {
            IdentifyGraphicsOverlayResult result = null;

            try
            {
                // Identify the tapped graphics
                result = await MyMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, geoViewInputEventArgs.Position, 1, false);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }

            // Return if there are no results
            if (result == null || result.Graphics.Count < 1)
            {
                return;
            }

            // Get the first identified graphic
            Graphic identifiedGraphic = result.Graphics.First();

            // Clear any existing selection, then select the tapped graphic
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Update the spatial relationship display
            switch (selectedGeometry.GeometryType)
            {
            case GeometryType.Point:
                PointTreeEntry.ItemsSource    = null;
                PolygonTreeEntry.ItemsSource  = GetSpatialRelationships(selectedGeometry, _polygonGraphic.Geometry);
                PolylineTreeEntry.ItemsSource = GetSpatialRelationships(selectedGeometry, _polylineGraphic.Geometry);
                break;

            case GeometryType.Polygon:
                PolygonTreeEntry.ItemsSource  = null;
                PointTreeEntry.ItemsSource    = GetSpatialRelationships(selectedGeometry, _pointGraphic.Geometry);
                PolylineTreeEntry.ItemsSource = GetSpatialRelationships(selectedGeometry, _polylineGraphic.Geometry);
                break;

            case GeometryType.Polyline:
                PolylineTreeEntry.ItemsSource = null;
                PointTreeEntry.ItemsSource    = GetSpatialRelationships(selectedGeometry, _pointGraphic.Geometry);
                PolygonTreeEntry.ItemsSource  = GetSpatialRelationships(selectedGeometry, _polygonGraphic.Geometry);
                break;
            }

            // Expand the tree view
            PolylineTreeEntry.IsExpanded = true;
            PolygonTreeEntry.IsExpanded  = true;
            PointTreeEntry.IsExpanded    = true;
        }
        private void listDirections_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e)
        {
            _directionsOverlay.ClearSelection();

            if (e.AddedItems != null && e.AddedItems.Count == 1)
            {
                var graphic = e.AddedItems[0] as Graphic;
                graphic.IsSelected = true;
            }
        }
コード例 #8
0
        private void FilterGraphicsBasedonSelection(object selectedvalue, GraphicsOverlay gl)
        {
            //var selectedvalue = ((Selector)sender).SelectedValue;
            gl.ClearSelection();
            gl.Graphics.Where(x =>
                              (x.Attributes.Keys.Contains("Primary Type") == true) &&
                              (x.Attributes["Primary Type"].ToString() == selectedvalue.ToString()))
            .ToList().ForEach(selectGraphic);

            mapViewModel.SelectedGraphicsCount = $"Found {gl.SelectedGraphics.Count().ToString()} crimes ";
        }
コード例 #9
0
        private void listResults_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e)
        {
            _addressOverlay.ClearSelection();

            if (e.AddedItems != null)
            {
                foreach (var graphic in e.AddedItems.OfType <Graphic>())
                {
                    graphic.IsSelected = true;
                }
            }
        }
コード例 #10
0
        private void resultsGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            _graphicsOverlay.ClearSelection();

            if (e.AddedItems != null && e.AddedItems.Count > 0)
            {
                var graphic = e.AddedItems[0] as Graphic;
                if (graphic != null)
                {
                    graphic.IsSelected = true;
                }
            }
        }
コード例 #11
0
        void listDirections_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            _directionsOverlay.ClearSelection();

            if (e.AddedItems != null && e.AddedItems.Count == 1)
            {
                var graphic = e.AddedItems[0] as Graphic;
                if (graphic != null)
                {
                    graphic.IsSelected = true;
                }
            }
        }
コード例 #12
0
ファイル: MapPage.xaml.cs プロジェクト: GeoGeeks/OnMap
        private async void listDirections_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e)
        {
            _directionsOverlay.ClearSelection();

            if (e.AddedItems != null && e.AddedItems.Count == 1)
            {
                var graphic = e.AddedItems[0] as Graphic;
                ShowHideDirectionsButton.Icon = new SymbolIcon(Windows.UI.Xaml.Controls.Symbol.Add);
                listDirections.Visibility     = Visibility.Collapsed;
                await MyMapView.SetViewAsync(graphic.Geometry.Extent.Expand(1.25));

                graphic.IsSelected = true;
            }
        }
コード例 #13
0
        async void MyMapView_GeoViewTapped(System.Object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            // Clear any currently visible callouts, route graphics, or selections
            MyMapView.DismissCallout();
            _routeGraphicsOverlay.Graphics.Clear();
            _placesGraphicsOverlay.ClearSelection();

            // Get the place under the tap
            IdentifyGraphicsOverlayResult idResult = await MyMapView.IdentifyGraphicsOverlayAsync(_placesGraphicsOverlay, e.Position, 12, false);

            Graphic clickedElement = idResult.Graphics.FirstOrDefault();

            if (clickedElement != null)
            {
                // Select the place to highlight it; get name and address
                clickedElement.IsSelected = true;
                string name    = clickedElement.Attributes["Name"].ToString();
                string address = clickedElement.Attributes["Address"].ToString();

                // Create a callout definition that shows the name and address for the place; set the element as a tag
                CalloutDefinition definition = new CalloutDefinition(name, address);
                definition.Tag = clickedElement;

                // Handle button clicks for the button on the callout
                // This event receives the value assigned as the CalloutDefinition.Tag
                // ** Fix API ref for this!
                // https://developers.arcgis.com/net/latest/wpf/api-reference/html/P_Esri_ArcGISRuntime_UI_CalloutDefinition_OnButtonClick.htm
                definition.OnButtonClick = new Action <object>(async(tag) =>
                {
                    // Get the geoelement that represents the place
                    GeoElement poiElement = tag as GeoElement;
                    if (poiElement == null)
                    {
                        return;
                    }

                    // Call a function in the viewmodel that will route to this location
                    var routeGraphic = await _viewModel.RouteToPoiAsync(_deviceLocation, poiElement.Geometry as MapPoint, MyMapView.SpatialReference);

                    // Add the route graphic to the map view and zoom to its extent
                    _routeGraphicsOverlay.Graphics.Add(routeGraphic);
                    await MyMapView.SetViewpointGeometryAsync(routeGraphic.Geometry, 30);
                });

                // Set the button icon and show the callout at the click location
                definition.ButtonImage = WalkIcon;
                MyMapView.ShowCalloutAt(e.Location, definition);
            }
        }
コード例 #14
0
 private void CancelButton_click(object sender, RoutedEventArgs e)
 {
     _sketchOverlay.Graphics.Clear();
     overviewoverlay.ClearSelection();
     generaloverlay.ClearSelection();
     coastaloverlay.ClearSelection();
     approachoverlay.ClearSelection();
     berthingoverlay.ClearSelection();
     harbouroverlay.ClearSelection();
     if (MyMapView.SketchEditor.CancelCommand.CanExecute(null))
     {
         MyMapView.SketchEditor.CancelCommand.Execute(null);
         // lvUsers.Items.Clear();
         // var systemCursor1 = System.Windows.Input.Cursors.Arrow;
         // Cursor = systemCursor1;
         // MyMapView.GeoViewTapped -= MyMapView_OnGeoViewTapped;
         // MyMapView.GeoViewTapped += MapViewTapped;
     }
 }
コード例 #15
0
        private async void myMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Identify the tapped graphics
            IdentifyGraphicsOverlayResult result = await _myMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, e.Position, 1, false);

            // Return if there are no results
            if (result.Graphics.Count < 1)
            {
                return;
            }

            // Get the first identified graphic
            Graphic identifiedGraphic = result.Graphics.First();

            // Clear any existing selection, then select the tapped graphic
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Perform the calculation and show the results
            _resultTextView.Text = GetOutputText(selectedGeometry);
        }
コード例 #16
0
 // 裁剪
 private void ClipMenuItem_Click(object sender, RoutedEventArgs e)
 {
     operation = OperateType.Cal_Clip;
     graphicsLayer.ClearSelection();
     listOfClipGraphics.Clear();
 }
コード例 #17
0
        // myMapView 事件
        private async void MyMapView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            IInputElement ie  = (IInputElement)(sender);
            MapPoint      loc = myMapView.ScreenToLocation(e.GetPosition(ie));

            switch (operation)
            {
            case OperateType.DrawPoint:     //画点
                Graphic pt = new Graphic(loc, pointSymbol);
                graphicsLayer.Graphics.Add(pt);
                break;

            case OperateType.DrawPolyline:    //画线
                pointCollection.Add(loc); if (pointCollection.Count >= 2)
                {
                    if (pointCollection.Count > 2)
                    {
                        Graphic         g  = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1];
                        PolylineBuilder lb = new PolylineBuilder(pointCollection); g.Geometry = lb.ToGeometry();
                    }
                    else
                    {
                        Esri.ArcGISRuntime.Geometry.Polyline l = new Esri.ArcGISRuntime.Geometry.Polyline(pointCollection);
                        Graphic lg = new Graphic(l, lineSymbol);
                        graphicsLayer.Graphics.Add(lg);
                    }
                }
                break;

            case OperateType.DrawPolygon:    //画多边形
                pointCollection.Add(loc); if (pointCollection.Count >= 3)
                {
                    if (pointCollection.Count > 3)
                    {
                        Graphic        g  = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1];
                        PolygonBuilder pb = new PolygonBuilder(pointCollection); g.Geometry = pb.ToGeometry();
                    }
                    else
                    {
                        Esri.ArcGISRuntime.Geometry.Polygon p = new Esri.ArcGISRuntime.Geometry.Polygon(pointCollection);
                        Graphic pg = new Graphic(p, fillSymbol);
                        graphicsLayer.Graphics.Add(pg);
                    }
                }
                break;

            case OperateType.None:    //缺省状态
                graphicsLayer.ClearSelection();
                IdentifyGraphicsOverlayResult result = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                //选择图形元素
                if (result.Graphics.Count < 1)
                {
                    curSelGraphic = null;
                    EditVertexMenuItem.IsEnabled   = false;
                    UneditVertexMenuItem.IsEnabled = false;
                    return;
                }
                curSelGraphic                = result.Graphics.First();
                curSelGraphic.IsSelected     = true;
                EditVertexMenuItem.IsEnabled = true;
                break;
            }
        }