Exemple #1
0
 internal bool QueryVirtualEarthService(bool asyncQuery)
 {
     if (string.IsNullOrEmpty(Common.MapCore.TileServerAppId) || Common.MapCore.TileServerAppId.ToUpper(CultureInfo.InvariantCulture) == "(DEFAULT)")
     {
         lock (TileError)
         {
             TileError = SR.ProvideBingMapsAppID;
         }
         return(false);
     }
     try
     {
         ImageryMetadataRequest imageryRequest = new ImageryMetadataRequest
         {
             BingMapsKey             = common.MapCore.TileServerAppId,
             ImagerySet              = VirtualEarthTileSystem.TileSystemToMapStyle(TileSystem),
             IncludeImageryProviders = true,
             UseHTTPS = true
         };
         if (asyncQuery)
         {
             BingMapsService.GetImageryMetadataAsync(imageryRequest, ProcessImageryMetadataResponse, delegate(Exception ex)
             {
                 lock (TileError)
                 {
                     TileError = ex.Message;
                 }
             });
         }
         else
         {
             Response imageryMetadata = BingMapsService.GetImageryMetadata(imageryRequest);
             ProcessImageryMetadataResponse(imageryMetadata);
         }
     }
     catch (Exception ex2)
     {
         lock (TileError)
         {
             TileError = ex2.Message;
         }
         return(false);
     }
     return(true);
 }
Exemple #2
0
        internal string GetAttributionStrings()
        {
            if (TileImageryProviders == null)
            {
                return(string.Empty);
            }
            StringBuilder stringBuilder = new StringBuilder();
            RectangleF    rectangleF    = new RectangleF(Common.MapCore.Viewport.GetAbsoluteLocation(), Common.MapCore.Viewport.GetAbsoluteSize());
            MapPoint      minimumPoint  = Common.MapCore.PixelsToGeographic(new PointF(rectangleF.Left, rectangleF.Bottom));
            MapPoint      maximumPoint  = Common.MapCore.PixelsToGeographic(new PointF(rectangleF.Right, rectangleF.Top));
            MapBounds     a             = new MapBounds(minimumPoint, maximumPoint);
            int           num           = Math.Max((int)VirtualEarthTileSystem.LevelOfDetail(Common.MapCore.Viewport.GetGroundResolutionAtEquator()), 1);

            ImageryProvider[] array = TileImageryProviders;
            foreach (ImageryProvider imageryProvider in array)
            {
                CoverageArea[] coverageAreas = imageryProvider.CoverageAreas;
                foreach (CoverageArea coverageArea in coverageAreas)
                {
                    if (num < coverageArea.ZoomMin || num > coverageArea.ZoomMax)
                    {
                        continue;
                    }
                    MapBounds b = new MapBounds(new MapPoint(coverageArea.BoundingBox[1], coverageArea.BoundingBox[1]), new MapPoint(coverageArea.BoundingBox[3], coverageArea.BoundingBox[3]));
                    if (MapBounds.Intersect(a, b))
                    {
                        if (stringBuilder.Length > 0)
                        {
                            stringBuilder.Append("|");
                        }
                        stringBuilder.Append(imageryProvider.Attribution);
                        break;
                    }
                }
            }
            return(stringBuilder.ToString());
        }