コード例 #1
0
        private async void OnDrawComplete(MapViewEventArgs args)
        {
            if (_api != null)
            {
                MapView          mapview = MapView.Active;
                Map              map     = mapview?.Map;
                SpatialReference spatRef = map?.SpatialReference;
                Unit             unit    = spatRef?.Unit;

                if (unit != null)
                {
                    string unitName = unit.Name;
                    string label    = _api.GetLengthUnitLabel();

                    if (label != unitName)
                    {
                        double           factor            = unit.ConversionFactor;
                        SpatialReference cyclSpatreference = await CoordSystemUtils.CycloramaSpatialReferenceAsync();

                        bool projected = cyclSpatreference.IsProjected;
                        Unit cyclUnit  = cyclSpatreference.Unit;

                        double cyclFactor = cyclUnit.ConversionFactor;
                        var    conversion = projected ? factor / cyclFactor : factor * cyclFactor;

                        _api.SetLengthUnitLabel(unitName);
                        _api.SetLengthUnitFactor(conversion);
                    }
                }
            }
        }
コード例 #2
0
        public async Task <MapPoint> AddHeightToMapPointAsync(MapPoint srcPoint)
        {
            return(await QueuedTask.Run(async() =>
            {
                MapView mapView = MapView.Active;
                Map map = mapView.Map;
                SpatialReference srcSpatialReference = map.SpatialReference;
                SpatialReference dstSpatialReference = await CoordSystemUtils.CycloramaSpatialReferenceAsync();

                ProjectionTransformation dstProjection = ProjectionTransformation.Create(srcSpatialReference,
                                                                                         dstSpatialReference);
                MapPoint dstPoint = GeometryEngine.Instance.ProjectEx(srcPoint, dstProjection) as MapPoint;

                if (dstPoint != null)
                {
                    double?height = await _cycloMediaGroupLayer.GetHeightAsync(dstPoint.X, dstPoint.Y);

                    if (height != null)
                    {
                        dstPoint = MapPointBuilder.CreateMapPoint(dstPoint.X, dstPoint.Y, ((double)height), dstSpatialReference);
                        ProjectionTransformation srcProjection = ProjectionTransformation.Create(dstSpatialReference,
                                                                                                 srcSpatialReference);
                        srcPoint = GeometryEngine.Instance.ProjectEx(dstPoint, srcProjection) as MapPoint;
                    }
                }

                return srcPoint;
            }));
        }