private async Task DoGeodesicLength()
        {
            ResetButton.IsEnabled = false;

            try
            {
                if (mapView1.Editor.IsActive)
                    mapView1.Editor.Cancel.Execute(null);

                //Get the input polygon geometry from the user
                inputGeom = await mapView1.Editor.RequestShapeAsync(DrawShape.Polyline);

                if (inputGeom != null)
                {
                    //Add the polygon drawn by the user
                    var g = new Graphic
                    {
                        Geometry = inputGeom,
                    };
                    myGraphicsLayer.Graphics.Add(g);


                    //Get the label point for the input geometry
                    var length = GeometryEngine.GeodesicLength(inputGeom);
                    LineLengthTextBlock.Text = length.ToString("N2") + " m";
                    LineLengthTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
                }
            }
            catch (Exception)
            {

            }
            ResetButton.IsEnabled = true;

        }
        // Unions feature geometries with a user defined polygon.
        private async void UnionButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                resultGraphics.Graphics.Clear();

                // wait for user to draw a polygon
                var poly = await mapView.Editor.RequestShapeAsync(DrawShape.Polygon);

                // get intersecting features from the feature layer
                SpatialQueryFilter filter = new SpatialQueryFilter();
                filter.Geometry = GeometryEngine.Project(poly, _statesLayer.FeatureTable.SpatialReference);
                filter.SpatialRelationship = SpatialRelationship.Intersects;
                filter.MaximumRows = 52;
                var stateFeatures = await _statesLayer.FeatureTable.QueryAsync(filter);

                // Union the feature geometries and add to graphics layer
                var states = stateFeatures.Select(feature => feature.Geometry);
                var sourcePolys = states.ToList();

				var unionPoly = GeometryEngine.Union(sourcePolys);
                var unionGraphic = new Graphic(unionPoly, _fillSymbol);

                resultGraphics.Graphics.Add(unionGraphic);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Union Error: " + ex.Message, "Union Sample");
            }
        }
        private void AddPolyLineGraphics()
        {
            MapPoint ptStart = (MapPoint)graphicsLayer.Graphics[0].Geometry;
            MapPoint ptEnd = (MapPoint)graphicsLayer.Graphics[5].Geometry;

            // Solid Blue line above point graphics
            Graphic blueLine = new Graphic()
            {
                Symbol = new SimpleLineSymbol() { Color = Colors.Blue, Style = SimpleLineStyle.Solid, Width = 4 },
                Geometry = new Polyline(new CoordinateCollection() 
                { 
                    new Coordinate(ptStart.X, ptStart.Y + 1000000),
                    new Coordinate(ptEnd.X, ptEnd.Y + 1000000)
                })
            };

            // Dashed Green line below point graphics
            Graphic greenLine = new Graphic()
            {
                Symbol = new SimpleLineSymbol() { Color = Colors.Green, Style = SimpleLineStyle.Dash, Width = 4 },
                Geometry = new Polyline(new CoordinateCollection() 
                { 
                    new Coordinate(ptStart.X, ptStart.Y - 1000000),
                    new Coordinate(ptEnd.X, ptEnd.Y - 1000000)
                })
            };

            graphicsLayer.Graphics.Add(blueLine);
            graphicsLayer.Graphics.Add(greenLine);
        }
Example #4
0
        private void ParseFile(string cached)
        {
            string[] sReferences = File.ReadAllLines(cached);
            foreach (string ap in sReferences)
            {
                try
                {
                    string[] s = ap.Split(',');
                    var g = new Graphic();
                    var pd = new ResourceDictionary();
                    pd.Source = new Uri("csGeoLayers;component/csGeoLayers/FlightTracker/FTDictionary.xaml", UriKind.Relative);
                    g.Symbol = pd["MediumMarkerSymbol"] as SimpleMarkerSymbol;

                    var mp = new MapPoint((float) Convert.ToDouble(s[7], CultureInfo.InvariantCulture),
                                          (float) Convert.ToDouble(s[6], CultureInfo.InvariantCulture),
                                          new SpatialReference(4326));

                    g.Geometry = mp;
                    Graphics.Add(g);
                }
                catch (Exception)
                {
                }
            }
            AppStateSettings.Instance.FinishDownload(_id);
        }
Example #5
0
 static GasOverlayMats()
 {
     TransmitterShader = ShaderDatabase.MetaOverlay;
     Graphic subGraphic = GraphicDatabase.Get<Graphic_Single>(TransmitterAtlasPath, TransmitterShader);
     LinkedOverlayGraphic = new Graphic_LinkedGasPipe(subGraphic);
     subGraphic.MatSingle.renderQueue = 3800;
 }
        private void Initialize()
        {
            // Create new Map with basemap
            Map myMap = new Map(Basemap.CreateImagery());

            // Create initial map location and reuse the location for graphic
            MapPoint centralLocation = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator);
            Viewpoint initialViewpoint = new Viewpoint(centralLocation, 7500);

            // Set initial viewpoint
            myMap.InitialViewpoint = initialViewpoint;

            // Provide used Map to the MapView
            _myMapView.Map = myMap;

            // Create overlay to where graphics are shown
            GraphicsOverlay overlay = new GraphicsOverlay();

            // Add created overlay to the MapView
            _myMapView.GraphicsOverlays.Add(overlay);

            // Create a simple marker symbol
            SimpleMarkerSymbol simpleSymbol = new SimpleMarkerSymbol()
            {
                Color = Color.Red,
                Size = 10,
                Style = SimpleMarkerSymbolStyle.Circle
            };

            // Add a new graphic with a central point that was created earlier
            Graphic graphicWithSymbol = new Graphic(centralLocation, simpleSymbol);
            overlay.Graphics.Add(graphicWithSymbol);
        }
Example #7
0
 private IEnumerator WaitForFade(Graphic g, float fadeInTime, float waitTime, float fadeOutTime, float waitAfter = 0)
 {
     yield return g.DOFade(1, fadeInTime).WaitForCompletion();
     yield return StartCoroutine(WaitOrSkip(waitTime));
     yield return g.DOFade(0, fadeOutTime).WaitForCompletion();
     yield return StartCoroutine(WaitOrSkip(waitAfter));
 }
        private async void MyMap_Tapped_1(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            var mp = MyMap.ScreenToMap(e.GetPosition(MyMap));
            Graphic g = new Graphic() { Geometry = mp };
            var graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.Graphics.Add(g);

            var bufferResult = GeometryEngine.Buffer(mp, 100);
            var bufferLayer = MyMap.Layers["BufferLayer"] as GraphicsLayer;
            bufferLayer.Graphics.Add(new Graphic() { Geometry = bufferResult });


            var queryTask = new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer/2"));
            var query = new ESRI.ArcGIS.Runtime.Tasks.Query()
            {
                ReturnGeometry = true,
                OutSpatialReference = MyMap.SpatialReference,
                Geometry = bufferResult
            };
            query.OutFields.Add("OWNERNME1");

            try
            {
                var queryResult = await queryTask.ExecuteAsync(query);
                if (queryResult != null && queryResult.FeatureSet != null)
                {
                    var resultLayer = MyMap.Layers["MyResultsGraphicsLayer"] as GraphicsLayer;
                    resultLayer.Graphics.AddRange(queryResult.FeatureSet.Features);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Example #9
0
        protected override Graphic OnCreateGraphic(GraphicCollection cluster, MapPoint point, int maxClusterCount)
        {
            if (cluster.Count == 1) return cluster[0];

            double sum = 0;

            foreach (var g in cluster) {
                if (!g.Attributes.ContainsKey("Poi")) continue;
                try {
                    var poi = g.Attributes["Poi"] as PoI;
                    if (poi == null) continue;
                    if (poi.Labels.ContainsKey(AggregateLabel))
                        sum += Convert.ToDouble(poi.Labels[AggregateLabel]);
                }
                catch { }
            }
            //double size = (sum + 450) / 30;
            var size = (Math.Log(sum * SymbolScale / 10) * 10 + 20);
            if (size < 12) size = 12;
            var graphic = new Graphic
            {
                Symbol = new ClusterSymbol { Size = size },
                Geometry = point
            };
            graphic.Attributes.Add("Count", sum);
            graphic.Attributes.Add("Size", size);
            graphic.Attributes.Add("Color", InterpolateColor(size - 12, 100));
            return graphic;
        }
Example #10
0
        public override void Draw(Graphic g)
        {
            var position = _c.Position * _c.Scale;
            var size = _c.Size * _c.Scale;

            g.DrawRectangle(position, size, true, Style.Background);
        }
		/// <summary>
		/// XAML creation of polygon and polyline geometries are currently not supported, so
		/// here they are created in code. Points are generated in the XAML for this sample.
		/// </summary>
		private void CreateGeometries()
		{
			var layer = mapView1.Map.Layers.OfType<GraphicsLayer>().First();
			int i = 0;
			foreach (var g in layer.Graphics)
				g.Attributes["Label"] = "Label #" + (++i).ToString();

			Polyline line = new Polyline(FromArray(-100,-30, -80,0, -60,-30, -40,0), SpatialReferences.Wgs84);
			var graphic = new Graphic(line, (Esri.ArcGISRuntime.Symbology.Symbol)Resources["OutlinedAndDashedSymbol"]);
			graphic.Attributes["Label"] = "OutlinedAndDashedSymbol";
			layer.Graphics.Add(graphic);

			Polygon polygon = new Polygon(FromArray(-30,-30, 0,-30, 0,0, -15,-10, -30,0, -30,-30), SpatialReferences.Wgs84);
			graphic = new Graphic(polygon, (Esri.ArcGISRuntime.Symbology.Symbol)Resources["VertexFillSymbol"]);
			graphic.Attributes["Label"] = "VertexFillSymbol";
			layer.Graphics.Add(graphic);

			//CIM symbols can only be created from JSON. The JSON is currently only constructed by publishing services to ArcGIS Server with advanced symbology
			string CIMSymbolJson = "{\"type\":\"CIMSymbolReference\",\"symbol\":{\"type\":\"CIMLineSymbol\",\"symbolLayers\":[{\"type\":\"CIMFilledStroke\",\"enable\":true,\"effects\":[{\"type\":\"CIMGeometricEffectArrow\",\"geometricEffectArrowType\":\"Block\",\"primitiveName\":null,\"width\":35}],\"capStyle\":\"Round\",\"pattern\":{\"type\":\"CIMSolidPattern\",\"color\":[0,0,0,255]},\"width\":2,\"lineStyle3D\":\"Strip\",\"alignment\":\"Center\",\"joinStyle\":\"Miter\",\"miterLimit\":10,\"patternFollowsStroke\":true}]},\"symbolName\":null}";
			var cimsymbol = Esri.ArcGISRuntime.Symbology.Symbol.FromJson(CIMSymbolJson);
			Polyline line2 = new Polyline(FromArray(20, -30, 30, 0, 50, -30, 70, 0), SpatialReferences.Wgs84);
			graphic = new Graphic(line2, cimsymbol);
			graphic.Attributes["Label"] = "CIM Symbol";
			layer.Graphics.Add(graphic);

			i = 0;
			foreach (var g in layer.Graphics)
			{
				g.Attributes["SymbolType"] = g.Symbol.GetType().Name;
				g.Attributes["ID"] = ++i;
			}
		}
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            ESRI.ArcGIS.Client.Geometry.Polygon polygon = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polygon;
            polygon.SpatialReference = MyMap.SpatialReference;
            Graphic graphic = new Graphic()
            {
                Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                Geometry = polygon,
            };

            GeometryService geometryService =
                new GeometryService("http://serverapps101.esri.com/arcgis/rest/services/Geometry/GeometryServer");
            geometryService.AreasAndLengthsCompleted += GeometryService_AreasAndLengthsCompleted;
            geometryService.Failed += GeometryService_Failed;

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.Graphics.Add(graphic);

            List<Graphic> graphicList = new List<Graphic>();
            graphicList.Add(graphic);

            // Since there are multiple overloads for AreasAndLengthsAsync, make sure to use appropriate signature with correct parameter types.
            geometryService.AreasAndLengthsAsync(graphicList,null,null, (CalculationType)calculationTypeCombo.SelectedValue );

            // GeometryService.AreasAndLengths returns distances and areas in the units of the spatial reference.
            // The units in the map view's projection is decimal degrees.
            // Use the Project method to convert graphic points to a projection that uses a measured unit (e.g. meters).
            // If the map units are in measured units, the call to Project is unnecessary.
            // Important: Use a projection appropriate for your area of interest.
        }
        void myDrawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            _geometryService.CancelAsync();
            _queryTask.CancelAsync();

            Graphic clickGraphic = new Graphic();
            clickGraphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = e.Geometry;
            // Input spatial reference for buffer operation defined by first feature of input geometry array
            clickGraphic.Geometry.SpatialReference = MyMap.SpatialReference;

            _pointAndBufferGraphicsLayer.ClearGraphics();
            _resultsGraphicsLayer.ClearGraphics();

            clickGraphic.SetZIndex(2);
            _pointAndBufferGraphicsLayer.Graphics.Add(clickGraphic);

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
                BufferSpatialReference = new SpatialReference(4326),
                OutSpatialReference = MyMap.SpatialReference,
                Unit = LinearUnit.Meter,
            };
            bufferParams.Distances.Add(100);
            bufferParams.Features.Add(clickGraphic);

            _geometryService.BufferAsync(bufferParams);
        }
        private async void FindAddressButton_Click(object sender, RoutedEventArgs e)
        {
            OnlineLocatorTask locator = GetLocation();

            var findParams = new OnlineLocatorFindParameters(AddressTextBox.Text);
            findParams.OutSpatialReference = MyMapView.SpatialReference;
            findParams.SourceCountry = "US";

            var results = await locator.FindAsync(findParams, new System.Threading.CancellationToken());

            if (results.Count > 0)
            {
                var firstMatch = results[0].Feature;
                var matchLocation = firstMatch.Geometry as MapPoint;

                var matchSym = new PictureMarkerSymbol();
                var pictureURI = new Uri("http://static.arcgis.com/images/Symbols/Basic/GreenStickpin.png");
                await matchSym.SetSourceAsync(pictureURI);

                var matchGraphic = new Graphic(matchLocation, matchSym);

                var graphicsLayer = MyMap.Layers["GeocodeResults"] as GraphicsLayer;
                graphicsLayer.Graphics.Add(matchGraphic);

                var matchExtent = new Envelope(matchLocation.X - 100,
                                               matchLocation.Y - 100,
                                               matchLocation.X + 100,
                                               matchLocation.Y + 100);
                await MyMapView.SetViewAsync(matchExtent);
            }
        }
		private async void StartButton_Click(object sender, RoutedEventArgs e)
		{
			SetupUI();

			// InstructionsTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
			StartButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;

			//Get the user's input
			densifyPolygonGeometry = (await MyMapView.Editor.RequestShapeAsync(DrawShape.Polygon)) as Polygon;

			//Create a graphic and add it to the PolygonGraphicsLayer
			var thePolygonGraphic = new Graphic
			{
				Geometry = densifyPolygonGeometry,
				Symbol = polygonSymbol
			};
			graphicsLayerPolygon.Graphics.Add(thePolygonGraphic);

			//show the vertices for the polygon
			foreach (var vert in densifyPolygonGeometry.Parts.FirstOrDefault().GetPoints())
			{
				var graphic = new Graphic { Geometry = new MapPoint(vert.X, vert.Y), Symbol = defaultVertexMarkerSymbol };
				graphicsLayerVertices.Graphics.Add(graphic);
			}

			DensifyPolygonsButton.IsEnabled = true;
		}
        private async Task doCalculateAreaAndLength()
        {
            try
            {
                //Wait for user to draw
                var geom = await mapView1.Editor.RequestShapeAsync(DrawShape.Polygon);

                //show geometry on map
                graphicsLayer.Graphics.Clear();

                var g = new Graphic { Geometry = geom, Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as Esri.ArcGISRuntime.Symbology.Symbol };
                graphicsLayer.Graphics.Add(g);

                //Calculate results
                var areaPlanar = GeometryEngine.Area(geom);
                ResultsAreaPlanar.Text = string.Format("{0} sq. miles", (areaPlanar * toSqMilesConversion).ToString("n3"));

                var perimPlanar = GeometryEngine.Length(geom);
                ResultsPerimeterPlanar.Text = string.Format("{0} miles", (perimPlanar * toMilesConversion).ToString("n3"));

                var areaGeodesic = GeometryEngine.GeodesicArea(geom);
                ResultsAreaGeodesic.Text = string.Format("{0} sq. miles", (areaGeodesic * toSqMilesConversion).ToString("n3"));

                var perimGeodesic = GeometryEngine.GeodesicLength(geom);
                ResultsPerimeterGeodesic.Text = string.Format("{0} miles", (perimGeodesic * toMilesConversion).ToString("n3"));

                Instructions.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                Results.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
            catch (System.Threading.Tasks.TaskCanceledException)
            {
                var dlg = new MessageDialog("Current sketch has been canceled.", "Task Canceled!");
                var _ = dlg.ShowAsync();
            }
        }
        public void SpawnSetup()
        {
            uiOverlay = new DroidUIOverlay(parent);
            parent.drawer.renderer.graphics.ResolveGraphics();
            parent.story.hairDef = DefDatabase<HairDef>.GetNamed("Shaved", true);

            try
            {
                if (headGraphicDef != null && bodyGraphicDef.supportsHead)
                {
                    headGraphic = headGraphicDef.graphicData.Graphic;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                return;
            }
            try
            {
                bodyGraphic = bodyGraphicDef.graphicData.Graphic;
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }

            if (headGraphic != null)
            {
                parent.drawer.renderer.graphics.headGraphic = this.headGraphic;
                parent.drawer.renderer.graphics.hairGraphic = GraphicDatabase.Get<Graphic_Multi>(parent.story.hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, parent.story.hairColor);
            }
            parent.drawer.renderer.graphics.nakedGraphic = this.bodyGraphic;
        }
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            MyDrawObject.IsEnabled = false;
            ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline;
            polyline.SpatialReference = MyMap.SpatialReference;

            Graphic polylineGraphic = new Graphic()
            {
                Geometry = polyline
            };
            List<Graphic> polylineList = new List<Graphic>();
            polylineList.Add(polylineGraphic);

            GeometryService geometryService =
              new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
            geometryService.AutoCompleteCompleted += GeometryService_AutoCompleteCompleted;
            geometryService.Failed += GeometryService_Failed;

            GraphicsLayer graphicsLayer = MyMap.Layers["ParcelsGraphicsLayer"] as GraphicsLayer;
            List<Graphic> polygonList = new List<Graphic>();
            foreach (Graphic g in graphicsLayer.Graphics)
            {
                g.Geometry.SpatialReference = MyMap.SpatialReference;
                polygonList.Add(g);
            }

            geometryService.AutoCompleteAsync(polygonList, polylineList);
        }
 public void OnPending(Graphic parent)
 {
     this.parent = parent as BodyGraphic;
     logic = new RaySegmentsCollisionLogic(this.parent.Body);
     parent.Parent.physicsLogics.Add(logic);
     logic.NewInfo += logic_NewInfo;
 }
        private void LocatorTask_AddressToLocationsCompleted(object sender, ESRI.ArcGIS.Client.Tasks.AddressToLocationsEventArgs args)
        {
            List<AddressCandidate> returnedCandidates = args.Results;

            AddressBorder.Visibility = System.Windows.Visibility.Collapsed;

            if (returnedCandidates.Count > 0)
            {
                AddressCandidate candidate = returnedCandidates[0];

                Graphic graphic = new Graphic()
                {
                    Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as Symbol,
                    Geometry = candidate.Location
                };

                graphic.Attributes.Add("Address", candidate.Address);

                graphicsLayer.Graphics.Add(graphic);

                ResultsTextBlock.Visibility = System.Windows.Visibility.Visible;
                ResultsTextBlock.Text = candidate.Address;

                double displaySize = MyMap.MinimumResolution * 30;
                ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(
                    candidate.Location.X - (displaySize / 2),
                    candidate.Location.Y - (displaySize / 2),
                    candidate.Location.X + (displaySize / 2),
                    candidate.Location.Y + (displaySize / 2));
                MyMap.ZoomTo(displayExtent);
            }
        }
        private void MyMapView_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                // Convert screen point to map point
                var point = MyMapView.ScreenToLocation(e.GetPosition(MyMapView));
                if (point == null)
                    return;

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

                Graphic bufferGraphic = null;
				if (_graphicsOverlay.Graphics.Count == 0)
                {
                    bufferGraphic = new Graphic { Geometry = buffer, Symbol = _bufferSymbol };
					_graphicsOverlay.Graphics.Add(bufferGraphic);
                }
                else
					bufferGraphic = _graphicsOverlay.Graphics[0];
                bufferGraphic.Geometry = buffer;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Geometry Engine Failed!");
            }
        }
        async void mapView1_Loaded(object sender, RoutedEventArgs e)
        {
            if (originalGraphicsLayer != null && originalGraphicsLayer.Graphics.Count == 0)
            {
                QueryTask queryTask = new QueryTask(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/1"));
                Query query = new Query("NAME = 'Mississippi'");
                query.ReturnGeometry = true;
                query.OutSpatialReference = mapView1.SpatialReference;


                var results = await queryTask.ExecuteAsync(query, CancellationToken.None);
                foreach (Graphic g in results.FeatureSet.Features)
                {
                    g.Symbol = defaultLineSymbol;
                    g.Geometry.SpatialReference = mapView1.SpatialReference;
                    originalGraphicsLayer.Graphics.Add(g);

                    foreach (var pc in (g.Geometry as Polyline).Paths)
                    {
                        foreach (var point in pc)
                        {
                            var vertice = new Graphic()
                            {
                                Symbol = defaultMarkerSymbol,
                                Geometry = new MapPoint(point.X, point.Y)
                            };
                            originalGraphicsLayer.Graphics.Add(vertice);
                        }
                    }
                }
                GeneralizeButton.IsEnabled = true;
            }
        }
        private void CreateOverlay()
        {
            // Create polygon builder and add polygon corners into it
            PolygonBuilder builder = new PolygonBuilder(SpatialReferences.WebMercator);
            builder.AddPoint(new MapPoint(-20e5, 20e5));
            builder.AddPoint(new MapPoint(20e5, 20e5));
            builder.AddPoint(new MapPoint(20e5, -20e5));
            builder.AddPoint(new MapPoint(-20e5, -20e5));

            // Get geometry from the builder
            Polygon polygonGeometry = builder.ToGeometry();

            // Create symbol for the polygon
            SimpleFillSymbol polygonSymbol = new SimpleFillSymbol(
                SimpleFillSymbolStyle.Solid,
                System.Drawing.Color.Yellow,
                null);

            // Create new graphic
            Graphic polygonGraphic = new Graphic(polygonGeometry, polygonSymbol);

            // Create overlay to where graphics are shown
            _polygonOverlay = new GraphicsOverlay();
            _polygonOverlay.Graphics.Add(polygonGraphic);

            // Add created overlay to the MapView
            _myMapView.GraphicsOverlays.Add(_polygonOverlay);
        }
        // Unions feature geometries with a user defined polygon.
        private async void UnionButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _resultGraphics.Graphics.Clear();

                // wait for user to draw a polygon
                var poly = await MyMapView.Editor.RequestShapeAsync(DrawShape.Polygon);

                // Take account of WrapAround
                var normalizedPoly = GeometryEngine.NormalizeCentralMeridian(poly) as Polygon;

                // get intersecting features from the feature layer
                SpatialQueryFilter filter = new SpatialQueryFilter();
                filter.Geometry = GeometryEngine.Project(normalizedPoly, _statesLayer.FeatureTable.SpatialReference);
                filter.SpatialRelationship = SpatialRelationship.Intersects;
                filter.MaximumRows = 52;
                var stateFeatures = await _statesLayer.FeatureTable.QueryAsync(filter);

                // Union the geometries and add to graphics layer
                var states = stateFeatures.Select(feature => feature.Geometry);
                var unionPolys = states.ToList();
              
				var unionPoly = GeometryEngine.Union(unionPolys);
                var unionGraphic = new Graphic(unionPoly, _fillSymbol);

                _resultGraphics.Graphics.Add(unionGraphic);
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog("Union Error: " + ex.Message, "Sample Error").ShowAsync();
            }
        }
        private async Task SelectParcelForOffset()
        {
            ResetButton.IsEnabled = false;


            try
            {
                offsetGraphicsLayer.Graphics.Clear();

                var pointGeom = await mapView1.Editor.RequestPointAsync();
                pointGeom.SpatialReference = mapView1.SpatialReference;
                var screenPnt = mapView1.LocationToScreen(pointGeom);

                selectedParcelGraphic = await
                    parcelGraphicsLayer.HitTestAsync(mapView1, screenPnt);

                DoOffset();
            }
            catch (Exception)
            {

            }
            ResetButton.IsEnabled = true;

        }
        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();
            }
        }
		private async Task SelectParcelForOffsetAsync()
		{
			try
			{
				ResetButton.IsEnabled = false;
				_offsetOverlay.Graphics.Clear();

				var pointGeom = await MyMapView.Editor.RequestPointAsync();
				var screenPnt = MyMapView.LocationToScreen(pointGeom);

				_selectedParcelGraphic = await
					_parcelOverlay.HitTestAsync(MyMapView, screenPnt);

				DoOffset();
			}
			catch (TaskCanceledException) { }
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "Sample Error");
			}
			finally
			{
				ResetButton.IsEnabled = true;
			}
		}
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            args.Geometry.SpatialReference = MyMap.SpatialReference;
            Graphic graphic = new Graphic(){ Geometry = args.Geometry };
            if (args.Geometry is Polyline)
              graphic.Symbol = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            else
              graphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;

            graphicsLayer.Graphics.Add(graphic);

            if (graphicsLayer.Graphics.Count == 1)
                MyDrawObject.DrawMode = DrawMode.Point;
            else if (graphicsLayer.Graphics.Count == 2)
            {
                MyDrawObject.IsEnabled = false;
                GeometryService geometryService =
                            new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
                geometryService.DistanceCompleted += GeometryService_DistanceCompleted;
                geometryService.Failed += GeometryService_Failed;

                MyDrawObject.DrawMode = DrawMode.Polyline;

                DistanceParameters distanceParameters = new DistanceParameters()
                {
                    DistanceUnit = LinearUnit.SurveyMile,
                    Geodesic = true
                };

                geometryService.DistanceAsync(graphicsLayer.Graphics[0].Geometry, graphicsLayer.Graphics[1].Geometry,distanceParameters);
                ResponseTextBlock.Text = "The distance between geometries is... ";
            }
        }
		private async void mapView1_MapViewTapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e)
		{
			var graphicsLayer = mapView1.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
			var editGraphicsLayer = mapView1.Map.Layers["EditGraphicsLayer"] as GraphicsLayer;
			if (graphicBeingEdited == null)
			{
				var hit = await graphicsLayer.HitTestAsync(sender as Esri.ArcGISRuntime.Controls.ViewBase, e.Position);
				if (hit != null)
				{
					graphicBeingEdited = hit;
					//highlight the active graphic
					graphicBeingEdited.IsSelected = true;
					//Create a temporary we can move around without 'disturbing' the original feature until commit
					Graphic g = new Graphic();
					g.Symbol = hit.Symbol ?? graphicsLayer.Renderer.GetSymbol(hit);
					g.Geometry = hit.Geometry;
					editGraphicsLayer.Graphics.Add(g);
				}
			}
			else //Commit and clean up
			{
				graphicBeingEdited.Geometry = e.Location;
				graphicBeingEdited.IsSelected = false;
				graphicBeingEdited = null;
				editGraphicsLayer.Graphics.Clear();
			}
		}
        private void mapView_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                graphicsLayer.Graphics.Clear();

                // Convert screen point to map point
                var point = mapView.ScreenToLocation(e.GetPosition(mapView));
                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!");
            }
        }