//create point at click
        private void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            MyOverlay.Graphics.Clear();
            //get clicked point
            var point   = e.Location;
            var graphic = new Graphic(point, m_pmsYAH);

            int mile = 4;
            //create 1 mile (radius) buffer around point
            var buffer = GeometryEngine.Buffer(point, 1609.34 / mile);

            //create symbol for buffer
            var buffSym = new SimpleLineSymbol();

            buffSym.Color = Colors.Purple;
            buffSym.Style = SimpleLineSymbolStyle.Dash;
            buffSym.Width = 2;
            //create buffer graphic
            var buffer_graphic = new Graphic(buffer, buffSym);

            //add graphics to map
            MyOverlay.Graphics.Add(graphic);
            MyOverlay.Graphics.Add(buffer_graphic);

            //query nearest bars
            QueryFeatures(buffer, point);
        }
        private void SceneViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            // Ignore if tapped out of bounds (e.g. the sky).
            if (e.Location == null)
            {
                return;
            }

            // When the view is tapped, define the observer or target location with the tap point as appropriate
            if (_observerLocation == null)
            {
                // Define the observer location (plus an offset for observer height) and set the target to the same point
                _observerLocation = new MapPoint(e.Location.X, e.Location.Y, e.Location.Z + _zOffset);
                _lineOfSightAnalysis.ObserverLocation = _observerLocation;
                _lineOfSightAnalysis.TargetLocation   = _observerLocation;

                // Clear the target location (if any) so the next click will define the target
                _targetLocation = null;
            }
            else if (_targetLocation == null)
            {
                // Define the target
                _targetLocation = new MapPoint(e.Location.X, e.Location.Y, e.Location.Z + _zOffset);
                _lineOfSightAnalysis.TargetLocation = _targetLocation;

                // Clear the observer location so it can be defined again
                _observerLocation = null;
            }
        }
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            // Hide any existing callout.
            MyMapView.DismissCallout();

            // Perform the identify operation.
            IdentifyLayerResult myIdentifyResult = await MyMapView.IdentifyLayerAsync(_wmsLayer, e.Position, 20, false);

            // Return if there's nothing to show.
            if (!myIdentifyResult.GeoElements.Any())
            {
                return;
            }

            // Retrieve the identified feature, which is always a WmsFeature for WMS layers.
            WmsFeature identifiedFeature = (WmsFeature)myIdentifyResult.GeoElements[0];

            // Retrieve the WmsFeature's HTML content.
            string htmlContent = identifiedFeature.Attributes["HTML"].ToString();

            // Note that the service returns a boilerplate HTML result if there is no feature found.
            // This test should work for most arcGIS-based WMS services, but results may vary.
            if (!htmlContent.Contains("OBJECTID"))
            {
                // Return without showing the callout.
                return;
            }

            // Show a callout with the HTML content.
            ShowHtmlCallout(htmlContent, e.Location);
        }
Example #4
0
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs mapClickPoint)
        {
            IdentifyLayerResult idResult = await MyMapView.IdentifyLayerAsync(serviceRequestLayer, mapClickPoint.Position, 5, false);

            ArcGISFeature serviceRequestFeature = idResult.GeoElements.FirstOrDefault() as ArcGISFeature;

            if (serviceRequestFeature == null)
            {
                return;
            }

            // Create a new feature in the comments table
            ArcGISFeature newComment = relatedTable.CreateFeature() as ArcGISFeature;


            // Add comment text to the 'comments' attribute
            newComment.Attributes["comments"] = "Please show up on time!";


            // Relate the selected service request to the new comment
            serviceRequestFeature.RelateFeature(newComment);
            await relatedTable.AddFeatureAsync(newComment);

            var results = await relatedTable.ApplyEditsAsync();
        }
        private async void TagMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            InstaAutoBot.SelectedGraphics.Clear();

            if (TagMapView.GraphicsOverlays.Count > 0)
            {
                var tolerance        = 10d;   // Use larger tolerance for touch
                var maximumResults   = 3;     // Only return one graphic
                var onlyReturnPopups = false; // Return more than popups

                var graphicColl = new List <Graphic>();

                foreach (var go in TagMapView.GraphicsOverlays)
                {
                    // Use the following method to identify graphics in a specific graphics overlay
                    IdentifyGraphicsOverlayResult identifyResults = await TagMapView.IdentifyGraphicsOverlayAsync(
                        go,
                        e.Position,
                        tolerance,
                        onlyReturnPopups,
                        maximumResults);

                    if (identifyResults.Graphics.Count > 0)
                    {
                        IdentifyExpander.IsExpanded = true;
                        identifyResults.Graphics.ToList().ForEach(g => InstaAutoBot.SelectedGraphics.Add(g));
                    }
                }
            }
        }
Example #6
0
        private void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            try
            {
                // Create a map point (in the WebMercator projected coordinate system) from the GUI screen coordinate.
                MapPoint userTappedMapPoint = MyMapView.ScreenToLocation(e.Position);

                // Add the map point to the list that will be used by the GeometryEngine.ConvexHull operation.
                _inputPointCollection.Add(userTappedMapPoint);

                // Create a simple marker symbol to display where the user tapped/clicked on the map. The marker symbol
                // will be a solid, red circle.
                SimpleMarkerSymbol userTappedSimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle,
                                                                                         System.Windows.Media.Colors.Red, 10);

                // Create a new graphic for the spot where the user clicked on the map using the simple marker symbol.
                Graphic userTappedGraphic = new Graphic(userTappedMapPoint, userTappedSimpleMarkerSymbol);

                // Set the Z index for the user tapped graphic so that it appears above the convex hull graphic(s) added later.
                userTappedGraphic.ZIndex = 1;

                // Add the user tapped/clicked map point graphic to the graphic overlay.
                _graphicsOverlay.Graphics.Add(userTappedGraphic);
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem adding user tapped graphics.
                MessageBox.Show(ex.Message, "Can't add user tapped graphic!");
            }
        }
Example #7
0
        /// <summary>
        /// Gets called when user taps on the map
        /// </summary>
        /// <param name="sender">Sender control</param>
        /// <param name="e">event args</param>
        private async void MapBookMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            // Wait for double tap to fire
            // Identify is only peformed on single tap. The delay is used to detect and ignore double taps
            await Task.Delay(500);

            // If view has been double tapped, set tapped to handled and flag back to false
            // If view has been tapped just once, perform identify
            if (this.isViewDoubleTapped == true)
            {
                e.Handled = true;
                this.isViewDoubleTapped = false;
            }
            else
            {
                // get the tap location in screen units
                Point tapScreenPoint = e.Position;

                var pixelTolerance   = 10;
                var returnPopupsOnly = false;
                var maxLayerResults  = 5;

                // identify all layers in the MapView, passing the tap point, tolerance, types to return, and max results
                IReadOnlyList <IdentifyLayerResult> idLayerResults = await this.MapBookMapView.IdentifyLayersAsync(tapScreenPoint, pixelTolerance, returnPopupsOnly, maxLayerResults);

                this.ViewModel.IdentifyCommand.Execute(idLayerResults);
            }
        }
Example #8
0
        private async void SceneViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            // Get the scene layer from the scene (first and only operational layer).
            ArcGISSceneLayer sceneLayer = (ArcGISSceneLayer)MySceneView.Scene.OperationalLayers.First();

            // Clear any existing selection.
            sceneLayer.ClearSelection();

            // Identify the layer at the tap point.
            // Use a 10-pixel tolerance around the point and return a maximum of one feature.
            IdentifyLayerResult result = await MySceneView.IdentifyLayerAsync(sceneLayer, e.Position, 10, false, 1);

            // Get the GeoElements that were identified (will be 0 or 1 element).
            IReadOnlyList <GeoElement> geoElements = result.GeoElements;

            // If a GeoElement was identified, select it in the scene.
            if (geoElements.Any())
            {
                GeoElement geoElement = geoElements.FirstOrDefault();
                if (geoElement != null)
                {
                    // Select the feature to highlight it in the scene view.
                    sceneLayer.SelectFeature((Feature)geoElement);
                }
            }
        }
Example #9
0
        /// <summary>
        /// this method display the value of country name region name and its population when a location is tapped on the map.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void MyMap_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            try
            {
                //identify all layers in the MapView, passing the tap point, tolerance,
                //types to return, and max results
                IReadOnlyList <IdentifyLayerResult> idlayerResults =
                    await MyMapView.IdentifyLayersAsync(e.Position, 10, false, 5);

                if (idlayerResults.Count > 0)
                {
                    IdentifyLayerResult idResults = idlayerResults.FirstOrDefault();
                    FeatureLayer        idLayer   = idResults.LayerContent as FeatureLayer;
                    idLayer.ClearSelection();

                    CountryTitleLabel.Content    = "Country";
                    RegionTitleLabel.Content     = "Region";
                    PopulationTitleLabel.Content = "2015 Population";

                    foreach (GeoElement idElement in idResults.GeoElements)
                    {
                        Feature idFeature = idElement as Feature;
                        idLayer.SelectFeature(idFeature);

                        IDictionary <string, object> attributes = idFeature.Attributes;
                        string attKey  = string.Empty;
                        object attVal1 = new object();

                        foreach (var attribute in attributes)
                        {
                            attKey  = attribute.Key;
                            attVal1 = attribute.Value;

                            if (string.Compare(attKey, "Country") == 0)
                            {
                                CountryValueLabel.Content = attVal1;
                            }

                            if (string.Compare(attKey, "Major_Region") == 0)
                            {
                                RegionValueLabel.Content = attVal1;
                            }

                            if (string.Compare(attKey, "pop2015") == 0)
                            {
                                string pop = attVal1 + "000";
                                int.TryParse(pop, out int result);
                                string formatString = String.Format("{0:n0}", result);
                                PopulationValueLabel.Content = formatString;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #10
0
 private void _arSceneView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
 {
     if (_arSceneView.SetInitialTransformation(e.Position))
     {
         DisplayScene();
         _arKitStatusLabel.Hidden = true;
     }
 }
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            // 既にフィーチャが選択状態の場合は、選択を解除する
            foreach (EncLayer layer in _mainMapView.Map.OperationalLayers.OfType <EncLayer>())
            {
                layer.ClearSelection();
            }

            // コールアウトを非表示にする
            _mainMapView.DismissCallout();

            // マップ上をクリックした地点にあるフィーチャを取得する
            IReadOnlyList <IdentifyLayerResult> results = await _mainMapView.IdentifyLayersAsync(e.Position, 10, false);

            // 該当するフィーチャが無い場合
            if (results.Count < 1)
            {
                return;
            }

            // 取得されたフィーチャが含まれるレイヤーのリストが返されるので、ENCレイヤーのみを取得する
            IEnumerable <IdentifyLayerResult> encResults             = results.Where(result => result.LayerContent is EncLayer);
            IEnumerable <IdentifyLayerResult> encResultsWithFeatures = encResults.Where(result => result.GeoElements.Count > 0);

            // ENCレイヤーのリストから最上位のレイヤーを取得する
            IdentifyLayerResult firstResult     = encResultsWithFeatures.First();
            EncLayer            containingLayer = firstResult.LayerContent as EncLayer;

            // レイヤーに含まれるフィーチャ リストから最後のフィーチャを取得する
            EncFeature firstFeature = firstResult.GeoElements.Last() as EncFeature;

            // 取得したフィーチャを選択(ハイライト表示)する
            containingLayer.SelectFeature(firstFeature);

            // フィーチャの関連情報を取得を文字列に変換する
            var attributes = new System.Text.StringBuilder();

            attributes.AppendLine(firstFeature.Description);

            if (firstFeature.Attributes.Count > 0)
            {
                // フィーチャの属性(key:属性のフィールド名、value:属性のフィールド値のペア)を取得する
                foreach (var attribute in firstFeature.Attributes)
                {
                    var fieldName  = attribute.Key;
                    var fieldValue = attribute.Value;
                    attributes.AppendLine(fieldName + ": " + fieldValue);
                }
                attributes.AppendLine();
            }

            // ENCフィーチャの頭文字と関連情報を指定してコールアウトを作成する
            CalloutDefinition definition = new CalloutDefinition(firstFeature.Acronym, attributes.ToString());

            // コールアウトをマップ上でクリックした場所に表示する
            _mainMapView.ShowCalloutAt(e.Location, definition);
        }
        private void mapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            var reverseGeocodeCommand = this.ReverseGeocodeCommand;

            if (reverseGeocodeCommand.CanExecute(MapViewModel.Current))
            {
                reverseGeocodeCommand.Execute(e.Location);
            }
        }
Example #13
0
 /// <summary>
 /// 地图双击事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void mapView_GeoViewDoubleTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
 {
     //if (routeStops == null || routeStops.Count <= 1)
     //    return;
     //List<MapPoint> stopList = await GraphHooperHelper.GetRouteStopsAsync(routeStops[0], routeStops[routeStops.Count - 1]);
     //routeStops.Clear();
     //AddNavigateRouteToGraphicsOverlay(LineOverlay, stopList, SimpleLineSymbolStyle.Dash, Colors.Blue, 5);
     ////AddPolygonToGraphicsOverlay(PolygonOverlay, polygonVertexes, SimpleFillSymbolStyle.DiagonalCross, Colors.LawnGreen, new SimpleLineSymbol(SimpleLineSymbolStyle.Dash,Colors.DarkBlue, 2));
     //e.Handled = true;
 }
Example #14
0
        private void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            // Enable the Save button
            SaveButton.IsEnabled = true;
            // Grab a point on the map
            var mapClickPoint = e.Location;

            // Call a method to add the feature to an existing feature collection
            AddFeature(mapClickPoint);
        }
Example #15
0
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            DataContext = this;
            // search
            var             tapPoint = e.Location;
            var             buffer   = GeometryEngine.Buffer(tapPoint, 10);
            QueryParameters query    = new QueryParameters();

            query.Geometry = buffer;
            var results = await fLayer.FeatureTable.QueryFeaturesAsync(query);

            if (results.Count() > 0)
            {
                chartValues = new ChartValues <ObservableChartMapPoint>();
                var firstResult = results.First();
                var randoGeom   = firstResult.Geometry as Esri.ArcGISRuntime.Geometry.Polyline;
                randoTitle = firstResult.Attributes["NOM"].ToString();


                Camera cam       = new Camera(firstResult.Geometry.Extent.GetCenter(), 4200, myMapView.MapRotation, 55, 0);
                var    viewPoint = new Viewpoint(firstResult.Geometry, cam);
                //scen
                myMapView.SetViewpointAsync(viewPoint, System.TimeSpan.FromMilliseconds(4000));
                mySceneView.SetViewpointAsync(viewPoint, System.TimeSpan.FromMilliseconds(4000));
                var      i         = 0;
                double   distance  = 0;
                MapPoint lastPoint = null;



                foreach (var part in randoGeom.Parts)
                {
                    foreach (var point in part.Points)
                    {
                        // si on est pas sur le premier point
                        if (i > 0)
                        {
                            distance += GeometryEngine.DistanceGeodetic(lastPoint, point, LinearUnits.Kilometers, AngularUnits.Degrees, GeodeticCurveType.Geodesic).Distance;
                        }
                        // sauvegrde du point pour distance.
                        lastPoint = point;
                        // on ne prend pas tous les points.
                        if (i % 2 == 0)
                        {
                            double elevation = await sceneSurface.GetElevationAsync(point);

                            chartValues.Add(new ObservableChartMapPoint(Math.Round(distance, 4), elevation, point));
                        }
                        i++;
                    }
                }
                // charts
            }
            // zoom on both scene+mapview
        }
Example #16
0
        private void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            // Clear any prior incident and routes from the graphics.
            _incidentGraphicsOverlay.Graphics.Clear();

            // Get the tapped point.
            _incidentPoint = e.Location;

            // Populate the facility parameters than solve using the task.
            PopulateParametersAndSolveRouteAsync();
        }
 private void ArSceneView_GeoViewDoubleTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
 {
     if (arSceneView.SetInitialTransformation(e.Position))
     {
         if (arSceneView.Scene == null)
         {
             arSceneView.ArSceneView.PlaneRenderer.Enabled = false;
             trackingStatus.Text = string.Empty;
             InitializeScene();
         }
     }
 }
Example #18
0
        private async void mapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            var table   = Mymap.OperationalLayers.OfType <FeatureCollectionLayer>().First().FeatureCollection.Tables.First();
            var feature = table.CreateFeature();

            feature.Geometry           = e.Location;
            feature.Attributes["Text"] = $"{e.Location.X},{e.Location.Y}";
            try
            {
                await table.AddFeatureAsync(feature);
            }
            catch { }
        }
        private async void mapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            var r = await mapView.IdentifyGraphicsOverlayAsync(mapView.GraphicsOverlays[0], e.Position, 1, false);

            r.GraphicsOverlay.ClearSelection();
            var g = r.Graphics?.FirstOrDefault();

            attributeView.ItemsSource = g?.Attributes;
            if (g != null)
            {
                g.IsSelected = true;
            }
        }
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            try
            {
                // Create a map point (in the WebMercator projected coordinate system) from the GUI screen coordinate.
                MapPoint userTappedMapPoint = MyMapView.ScreenToLocation(e.Position);

                // Get the buffer size from the textbox.
                double bufferInMiles = System.Convert.ToDouble(BufferDistanceMilesTextBox.Text);

                // Create a variable to be the buffer size in meters. There are 1609.34 meters in one mile.
                double bufferInMeters = bufferInMiles * 1609.34;

                // Get a buffered polygon from the GeometryEngine Buffer operation centered on the map point.
                // Note: The input distance to the Buffer operation is in meters. This matches the backdrop
                // basemap units which is also meters.
                Geometry bufferGeometry = GeometryEngine.Buffer(userTappedMapPoint, bufferInMeters);

                // Create the outline (a simple line symbol) for the buffered polygon. It will be a solid, thick, green line.
                SimpleLineSymbol bufferSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Windows.UI.Colors.Green, 5);

                // Create the color that will be used for the fill of the buffered polygon. It will be a semi-transparent, green color.
                Windows.UI.Color bufferFillColor = Windows.UI.Color.FromArgb(125, 0, 255, 0);

                // Create simple fill symbol for the buffered polygon. It will be solid, semi-transparent, green fill with a solid,
                // thick, green outline.
                SimpleFillSymbol bufferSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, bufferFillColor, bufferSimpleLineSymbol);

                // Create a new graphic for the buffered polygon using the defined simple fill symbol.
                Graphic bufferGraphic = new Graphic(bufferGeometry, bufferSimpleFillSymbol);

                // Add the buffered polygon graphic to the graphic overlay.
                _graphicsOverlay.Graphics.Add(bufferGraphic);

                // Create a simple marker symbol to display where the user tapped/clicked on the map. The marker symbol will be a
                // solid, red circle.
                SimpleMarkerSymbol userTappedSimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Windows.UI.Colors.Red, 5);

                // Create a new graphic for the spot where the user clicked on the map using the simple marker symbol.
                Graphic userTappedGraphic = new Graphic(userTappedMapPoint, userTappedSimpleMarkerSymbol);

                // Add the user tapped/clicked map point graphic to the graphic overlay.
                _graphicsOverlay.Graphics.Add(userTappedGraphic);
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem generating the buffer polygon.
                MessageDialog theMessageDialog = new MessageDialog("Geometry Engine Failed: " + ex.Message);
                await theMessageDialog.ShowAsync();
            }
        }
Example #21
0
        private void OnGeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            CusGeoViewInputEventArgs args = new CusGeoViewInputEventArgs(new CusMapPoint
            {
                X = e.Location.X,
                Y = e.Location.Y,
                M = e.Location.M,
                Z = e.Location.Z
            }, new Point(e.Position.X, e.Position.Y))
            {
                Handled = e.Handled
            };

            Element.OnGeoViewTapped(args);
        }
Example #22
0
        private void ArSceneView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            // Get the tapped screen point.
            PointF screenPoint = e.Position;

            if (_arSceneView.SetInitialTransformation(screenPoint))
            {
                DisplayScene();
                _helpLabel.Visibility = ViewStates.Gone;
            }
            else
            {
                Toast.MakeText(this, "ARCore doesn't recognize that point as a plane.", ToastLength.Short);
            }
        }
Example #23
0
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            // First clear any existing selections.
            ClearAllSelections();

            try
            {
                // Perform the identify operation.
                IReadOnlyList <IdentifyLayerResult> results = await MyMapView.IdentifyLayersAsync(e.Position, 5, false);

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

                // Get the results that are from ENC layers.
                IEnumerable <IdentifyLayerResult> encResults = results.Where(result => result.LayerContent is EncLayer);

                // Get the ENC results that have features.
                IEnumerable <IdentifyLayerResult> encResultsWithFeatures = encResults.Where(result => result.GeoElements.Count > 0);

                // Get the first result with ENC features.
                IdentifyLayerResult firstResult = encResultsWithFeatures.First();

                // Get the layer associated with this set of results.
                EncLayer containingLayer = (EncLayer)firstResult.LayerContent;

                // Select the smallest (area) feature in the layer.
                EncFeature smallestFeature = (EncFeature)firstResult.GeoElements.OrderBy(f => GeometryEngine.Area(f.Geometry)).First();

                // Select the feature.
                containingLayer.SelectFeature(smallestFeature);

                // Create the callout definition.
                CalloutDefinition definition = new CalloutDefinition(smallestFeature.Acronym, smallestFeature.Description);

                // Show the callout.
                MyMapView.ShowCalloutAt(e.Location, definition);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
            }
        }
        /// <summary>
        /// 地图点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void sceneView_GeoViewTappedAsync(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            //MapPoint mapLocation = e.Location;
            //Esri.ArcGISRuntime.Geometry.Geometry myGeometry = GeometryEngine.Project(mapLocation, SpatialReferences.Wgs84);
            //MapPoint projectedLocation = myGeometry as MapPoint;

            double tolerance        = 0;
            int    maximumResults   = 1;
            bool   onlyReturnPopups = false;

            IdentifyGraphicsOverlayResult identifyResults = await sceneView.IdentifyGraphicsOverlayAsync(
                CylinderOverlayForVisitorData,
                e.Position,
                tolerance,
                onlyReturnPopups,
                maximumResults);

            if (identifyResults.Graphics.Count > 0)
            {
                Graphic     graphic     = identifyResults.Graphics[0];
                MapPoint    mapPoint    = graphic.Geometry as MapPoint;
                VisitorItem visitorItem = GraphicsAttributes.ContainsKey(graphic) ? (GraphicsAttributes[graphic] as VisitorItem) : null;
                if (visitorItem != null)
                {
                    List <VisitorItem> visitorList = new List <VisitorItem>();
                    for (int month = 0; month < VisitorsByMonthAndPlace.Count; month++)
                    {
                        for (int viewIndex = 0; viewIndex < VisitorsByMonthAndPlace[month].Count; viewIndex++)
                        {
                            if (VisitorsByMonthAndPlace[month][viewIndex].ViewId == visitorItem.ViewId)
                            {
                                visitorList.Add(VisitorsByMonthAndPlace[month][viewIndex]);
                            }
                        }
                    }
                    //显示回调框
                    sceneView.ShowCalloutAt(mapPoint, new VisitorCallout(visitorList), new Point(0, 0));
                }
            }
            else
            {
                sceneView.DismissCallout();
            }
        }
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            try
            {
                // Project the tapped location to WGS 84.
                var projectedPoint = (MapPoint)GeometryEngine.Project(e.Location, SpatialReferences.Wgs84);

                // Add the map point to the list that will be used by the GeometryEngine.ConvexHull operation.
                _inputPointCollection.Add(projectedPoint);

                // Check if there are at least three points.
                if (_inputPointCollection.Count > 2)
                {
                    // Enable the button for creating hulls.
                    ConvexHullButton.IsEnabled = true;
                }

                // Create a simple marker symbol to display where the user tapped/clicked on the map. The marker symbol
                // will be a solid, red circle.
                SimpleMarkerSymbol userTappedSimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Red, 10);

                // Create a new graphic for the spot where the user clicked on the map using the simple marker symbol.
                Graphic userTappedGraphic = new Graphic(e.Location, new Dictionary <string, object>
                {
                    { "Type", "Point" }
                }, userTappedSimpleMarkerSymbol)
                {
                    ZIndex = 0
                };

                // Set the Z index for the user tapped graphic so that it appears above the convex hull graphic(s) added later.
                userTappedGraphic.ZIndex = 1;

                // Add the user tapped/clicked map point graphic to the graphic overlay.
                _graphicsOverlay.Graphics.Add(userTappedGraphic);
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem adding user tapped graphics.
                MessageDialog theMessageDialog = new MessageDialog("Can't add user tapped graphic!" + ex.Message);
                await theMessageDialog.ShowAsync();
            }
        }
        private void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            try
            {
                // Get the location tapped by the user (a map point in the WebMercator projected coordinate system).
                MapPoint userTapPoint = e.Location;

                // Get the buffer distance (miles) entered in the text box.
                double bufferInMiles = System.Convert.ToDouble(BufferDistanceMilesTextBox.Text);

                // Call a helper method to convert the input distance to meters.
                double bufferInMeters = LinearUnits.Miles.ToMeters(bufferInMiles);

                // Create a planar buffer graphic around the input location at the specified distance.
                Esri.ArcGISRuntime.Geometry.Geometry bufferGeometryPlanar = GeometryEngine.Buffer(userTapPoint, bufferInMeters);
                Graphic planarBufferGraphic = new Graphic(bufferGeometryPlanar);

                // Create a geodesic buffer graphic using the same location and distance.
                Esri.ArcGISRuntime.Geometry.Geometry bufferGeometryGeodesic = GeometryEngine.BufferGeodetic(userTapPoint, bufferInMeters, LinearUnits.Meters, double.NaN, GeodeticCurveType.Geodesic);
                Graphic geodesicBufferGraphic = new Graphic(bufferGeometryGeodesic);

                // Create a graphic for the user tap location.
                Graphic locationGraphic = new Graphic(userTapPoint);

                // Get the graphics overlays.
                GraphicsOverlay planarBufferGraphicsOverlay   = MyMapView.GraphicsOverlays["PlanarPolys"];
                GraphicsOverlay geodesicBufferGraphicsOverlay = MyMapView.GraphicsOverlays["GeodesicPolys"];
                GraphicsOverlay tapPointGraphicsOverlay       = MyMapView.GraphicsOverlays["TapPoints"];

                // Add the buffer polygons and tap location graphics to the appropriate graphic overlays.
                planarBufferGraphicsOverlay.Graphics.Add(planarBufferGraphic);
                geodesicBufferGraphicsOverlay.Graphics.Add(geodesicBufferGraphic);
                tapPointGraphicsOverlay.Graphics.Add(locationGraphic);
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem generating the buffers.
                MessageDialog dialog = new MessageDialog(ex.Message, "Error creating buffers");
                dialog.ShowAsync();
            }
        }
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            try
            {
                // Create a map point (in the WebMercator projected coordinate system) from the GUI screen coordinate.
                MapPoint userTappedMapPoint = MyMapView.ScreenToLocation(e.Position);

                // Get the buffer size (in miles) from the text box.
                double bufferDistanceInMiles = System.Convert.ToDouble(BufferDistanceMilesTextBox.Text);

                // Create a variable to be the buffer size in meters. There are 1609.34 meters in one mile.
                double bufferDistanceInMeters = bufferDistanceInMiles * 1609.34;

                // Add the map point to the list that will be used by the GeometryEngine.Buffer operation.
                _bufferPointsList.Add(userTappedMapPoint);

                // Add the buffer distance to the list that will be used by the GeometryEngine.Buffer operation.
                _bufferDistancesList.Add(bufferDistanceInMeters);

                // Create a simple marker symbol to display where the user tapped/clicked on the map. The marker symbol will be a
                // solid, red circle.
                SimpleMarkerSymbol userTappedSimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Windows.UI.Colors.Red, 10);

                // Create a new graphic for the spot where the user clicked on the map using the simple marker symbol.
                Graphic userTappedGraphic = new Graphic(userTappedMapPoint, userTappedSimpleMarkerSymbol);

                // Specify a ZIndex value on the user input map point graphic to assist with the drawing order of mixed geometry types
                // being added to a single GraphicCollection. The lower the ZIndex value, the lower in the visual stack the graphic is
                // drawn. Typically, Polygons would have the lowest ZIndex value (ex: 0), then Polylines (ex: 1), and finally MapPoints (ex: 2).
                userTappedGraphic.ZIndex = 2;

                // Add the user tapped/clicked map point graphic to the graphic overlay.
                _graphicsOverlay.Graphics.Add(userTappedGraphic);
            }
            catch (System.Exception ex)
            {
                // Display an error message.
                MessageDialog theMessageDialog = new MessageDialog("Error creating list of map points for buffer: " + ex.Message);
                await theMessageDialog.ShowAsync();
            }
        }
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            // Clear any existing result.
            ResultWebView.Visibility = Visibility.Collapsed;

            try
            {
                // Perform the identify operation.
                IdentifyLayerResult myIdentifyResult = await MyMapView.IdentifyLayerAsync(_wmsLayer, e.Position, 20, false);

                // Return if there's nothing to show.
                if (!myIdentifyResult.GeoElements.Any())
                {
                    return;
                }

                // Retrieve the identified feature, which is always a WmsFeature for WMS layers.
                WmsFeature identifiedFeature = (WmsFeature)myIdentifyResult.GeoElements[0];

                // Retrieve the WmsFeature's HTML content.
                string htmlContent = identifiedFeature.Attributes["HTML"].ToString();

                // Note that the service returns a boilerplate HTML result if there is no feature found.
                // This test should work for most arcGIS-based WMS services, but results may vary.
                if (!htmlContent.Contains("OBJECTID"))
                {
                    // Return without showing the callout.
                    return;
                }

                // Show the result.
                ResultWebView.NavigateToString(htmlContent);
                ResultWebView.Visibility = Visibility.Visible;
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.ToString(), "Error").ShowAsync();
            }
        }
Example #29
0
        private async void SceneViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            try
            {
                // Remove this method from the event handler to prevent concurrent calls.
                MySceneView.GeoViewTapped -= SceneViewTapped;

                // Check that the point is on the surface.
                if (e.Location != null)
                {
                    // Clear any existing graphics from the graphics overlay.
                    _overlay.Graphics.Clear();

                    // Get the elevation value.
                    double elevation = await _baseSurface.GetElevationAsync(e.Location);

                    // Set the text displaying the elevation.
                    _elevationTextSymbol.Text      = $"{Math.Round(elevation)} m";
                    _elevationTextGraphic.Geometry = new MapPoint(e.Location.X, e.Location.Y, e.Location.Z + 850);

                    // Add the text to the graphics overlay.
                    _overlay.Graphics.Add(_elevationTextGraphic);

                    // Add the marker indicating where the user tapped.
                    _overlay.Graphics.Add(new Graphic(e.Location, _elevationMarker));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                await new MessageDialog(ex.Message, "Sample error").ShowAsync();
            }
            finally
            {
                // Re-add to the event handler.
                MySceneView.GeoViewTapped += SceneViewTapped;
            }
        }
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            // First clear any existing selections
            ClearAllSelections();

            // Perform the identify operation
            IReadOnlyList <IdentifyLayerResult> results = await MyMapView.IdentifyLayersAsync(e.Position, 5, false);

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

            // Get the results that are from ENC layers
            IEnumerable <IdentifyLayerResult> encResults = results.Where(result => result.LayerContent is EncLayer);

            // Get the ENC results that have features
            IEnumerable <IdentifyLayerResult> encResultsWithFeatures = encResults.Where(result => result.GeoElements.Count > 0);

            // Get the first result with ENC features
            IdentifyLayerResult firstResult = encResultsWithFeatures.First();

            // Get the layer associated with this set of results
            EncLayer containingLayer = firstResult.LayerContent as EncLayer;

            // Get the first identified ENC feature
            EncFeature firstFeature = firstResult.GeoElements.First() as EncFeature;

            // Select the feature
            containingLayer.SelectFeature(firstFeature);

            // Create the callout definition
            CalloutDefinition definition = new CalloutDefinition(firstFeature.Acronym, firstFeature.Description);

            // Show the callout
            MyMapView.ShowCalloutAt(e.Location, definition);
        }