Beispiel #1
0
        private void OnView_Tapped(object sender, Esri.ArcGISRuntime.UI.GeoViewInputEventArgs e)
        {
            MapPoint geoPoint = getGeoPoint(e);

            geoPoint = (MapPoint)GeometryEngine.Project(geoPoint, SpatialReference.Create(3857));
            Polygon buffer = (Polygon)GeometryEngine.Buffer(geoPoint, 1000.0);

            GraphicCollection graphics = (threeD ? bufferAndQuerySceneGraphics : bufferAndQueryMapGraphics).Graphics;

            graphics.Clear();
            graphics.Add(new Graphic(buffer, BUFFER_SYMBOL));
            graphics.Add(new Graphic(geoPoint, CLICK_SYMBOL));

            Esri.ArcGISRuntime.Data.QueryParameters query = new Esri.ArcGISRuntime.Data.QueryParameters();
            query.Geometry = buffer;
            LayerCollection operationalLayers;

            if (threeD)
            {
                operationalLayers = sceneView.Scene.OperationalLayers;
            }
            else
            {
                operationalLayers = mapView.Map.OperationalLayers;
            }
            foreach (Layer layer in operationalLayers)
            {
                ((FeatureLayer)layer).SelectFeaturesAsync(query, SelectionMode.New);
            }
        }
        private async void OnView_Tapped(object sender, Esri.ArcGISRuntime.UI.GeoViewInputEventArgs e)
        {
            MapPoint geoPoint = getGeoPoint(e);

            geoPoint = (MapPoint)GeometryEngine.Project(geoPoint, SpatialReference.Create(3857));
            if (QueryandBufferButton.Content == FindResource("LocationSelected"))
            {
                Polygon           buffer   = (Polygon)GeometryEngine.Buffer(geoPoint, 1000.0);
                GraphicCollection graphics = (threeD ? bufferAndQuerySceneGraphics : bufferAndQueryMapGraphics).Graphics;
                graphics.Clear();
                graphics.Add(new Graphic(buffer, BUFFER_SYMBOL));
                graphics.Add(new Graphic(geoPoint, CLICK_SYMBOL));

                Esri.ArcGISRuntime.Data.QueryParameters query = new Esri.ArcGISRuntime.Data.QueryParameters();
                query.Geometry = buffer;
                LayerCollection operationalLayers;
                if (threeD)
                {
                    operationalLayers = sceneView.Scene.OperationalLayers;
                }
                else
                {
                    operationalLayers = mapView.Map.OperationalLayers;
                }
                foreach (Layer layer in operationalLayers)
                {
                    await((FeatureLayer)layer).SelectFeaturesAsync(query, SelectionMode.New);
                }
            }
            else if (RoutingButton.Content == FindResource("RoutingSelected"))
            {
                GraphicCollection graphics = (threeD ? sceneRouteGraphics : mapRouteGraphics).Graphics;
                if (originPoint == null)
                {
                    originPoint = geoPoint;
                    graphics.Clear();
                    graphics.Add(new Graphic(originPoint, ROUTE_ORIGIN_SYMBOL));
                }
                else
                {
                    graphics.Add(new Graphic(geoPoint, ROUTE_DESTINATION_SYMBOL));

                    if (routeParameters != null)
                    {
                        routeParameters.ReturnDirections = false;
                        routeParameters.ReturnRoutes     = true;
                        routeParameters.ReturnStops      = false;
                    }
                    else
                    {
                        RoutingButton_Click(null, null);
                    }

                    var stop1      = new Stop(originPoint);
                    var stop2      = new Stop(geoPoint);
                    var stopPoints = new List <Stop> {
                        stop1, stop2
                    };
                    routeParameters.SetStops(stopPoints);

                    var routeResult = await routeTask.SolveRouteAsync(routeParameters);

                    // get the route from the results
                    var route = routeResult.Routes[0];

                    // create a graphic (with a dashed line symbol) to represent the route
                    var routeSymbol  = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Colors.Yellow, 5);
                    var routeGraphic = new Graphic(route.RouteGeometry, routeSymbol);

                    graphics.Add(routeGraphic);
                    originPoint = null;
                }
            }
        }