int maxPixelInCurrentZoomLevel = (int)Math.Pow(2, zoomLevel) * 256 - 1; PointShape ddCenter = canvas.CurrentWorldExtent.GetCenterPoint(); PointShape projectedCenter = projection.ConvertToExternalProjection(ddCenter) as PointShape; RectangleShape maxExtentInMeter = BingMapsTileSystem.GetMaxExtentInMeter(projection); if (ddCenter.X < maxExtentInMeter.UpperLeftPoint.X) { projectedCenter.X -= 360; } if (ddCenter.X > maxExtentInMeter.LowerRightPoint.X) { projectedCenter.X += 360; } BingMapsTileSystem.LatLongToPixelXY(projectedCenter.Y, projectedCenter.X, zoomLevel, out pixelCenterX, out pixelCenterY); int minX = (int)Math.Ceiling(pixelCenterX - canvas.Width * 0.5); int minY = (int)Math.Ceiling(pixelCenterY - canvas.Height * 0.5); int maxX = (int)Math.Floor(pixelCenterX + canvas.Width * 0.5); int maxY = (int)Math.Floor(pixelCenterY + canvas.Height * 0.5); if (minX < 0) { minX = 0; } if (minY < 0) { minY = 0; } if (maxX > maxPixelInCurrentZoomLevel) { maxX = maxPixelInCurrentZoomLevel; } if (maxY > maxPixelInCurrentZoomLevel) { maxY = maxPixelInCurrentZoomLevel; } int startTileColumn = (int)Math.Floor(minX / (double)TileWidth); int endTileColumn = (int)Math.Ceiling(maxX / (double)TileWidth); int startTileRow = (int)Math.Floor(minY / (double)TileHeight); int endTileRow = (int)Math.Ceiling(maxY / (double)TileHeight); public static void LatLongToPixelXY(double latitude, double longitude, int levelOfDetail, out int pixelX, out int pixelY) { double sinLatitude = Math.Sin(latitude * Math.PI / 180); double x = (longitude + 180) / 360; double y = 0.5 - Math.Log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI); uint mapSize = MapSize(levelOfDetail); pixelX = (int)(x * mapSize + 0.5); pixelY = (int)(y * mapSize + 0.5); }