Esempio n. 1
0
        private void DoMesurement(Graphic graphic)
        {
            List <Graphic> graphicList = new List <Graphic>();

            graphicList.Add(graphic);

            if (widgetConfig.AlwaysProject || this.CurrentPage.MapUnits == ScaleLine.ScaleLineUnit.DecimalDegrees)
            {
                geometryService.ProjectAsync(graphicList, new SpatialReference(widgetConfig.ProjectToWKID));
            }
            else
            {
                switch (this.measurementMode)
                {
                case MODE_LENGTH:
                    geometryService.LengthsAsync(graphicList, this.CurrentPage.MapUnits);
                    break;

                case MODE_AREA:
                    geometryService.AreasAndLengthsAsync(graphicList, this.CurrentPage.MapUnits);
                    break;
                }
            }
        }
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline;
            polyline.SpatialReference = MyMap.SpatialReference;
            Graphic graphic = new Graphic()
            {
                Symbol = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                Geometry = polyline
            };

            GeometryService geometryService =
                            new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
            geometryService.LengthsCompleted += GeometryService_LengthsCompleted;
            geometryService.Failed += GeometryService_Failed;

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.Graphics.Add(graphic);
            geometryService.LengthsAsync(graphicsLayer.Graphics.ToList(), LinearUnit.SurveyMile, CalculationType.Geodesic, null);
        }
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline;
            polyline.SpatialReference = MyMap.SpatialReference;
            Graphic graphic = new Graphic()
            {
                Symbol   = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                Geometry = polyline
            };

            GeometryService geometryService =
                new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

            geometryService.LengthsCompleted += GeometryService_LengthsCompleted;
            geometryService.Failed           += GeometryService_Failed;

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            graphicsLayer.Graphics.Add(graphic);
            geometryService.LengthsAsync(graphicsLayer.Graphics.ToList(), LinearUnit.SurveyMile, CalculationType.Geodesic, null);
        }